使用chainer记录tensorboard事件

tensorboard-chainer的Python项目详细描述


Build Statuscodecov

Code Climate

PyPI version

张力板链器

用简单的命令编写tensorboard事件。 包括标量、图像、直方图、音频、文本、图形和嵌入。

这是基于tensorboard-pytorch

用法

安装Tensorflow。

pip install tensorflow

执行demo.py和tensorboard。 在浏览器中访问“localhost:6006”。

cd examples
python demo.py
tensorboard --logdir runs

标量示例

graph

直方图示例

graph

图表示例

graph

名称范围

与tensorflow一样,图中的节点可以在名称空间中组合在一起,以便于查看

importchainerimportchainer.functionsasFimportchainer.linksasLfromtb_chainerimportname_scope,within_name_scopeclassMLP(chainer.Chain):def__init__(self,n_units,n_out):super(MLP,self).__init__()withself.init_scope():self.l1=L.Linear(None,n_units)# n_in -> n_unitsself.l2=L.Linear(None,n_units)# n_units -> n_unitsself.l3=L.Linear(None,n_out)# n_units -> n_out@within_name_scope('MLP')def__call__(self,x):withname_scope('linear1',self.l1.params()):h1=F.relu(self.l1(x))withname_scope('linear2',self.l2.params()):h2=F.relu(self.l2(h1))withname_scope('linear3',self.l3.params()):o=self.l3(h2)returno

如何使用此模型保存日志如下所示。 add_all_variable_images是一个函数,它将变量的数据保存在与模式匹配的模型中作为图像。 add_all_parameter_histograms是在与模式匹配的模型中保存参数数据直方图的函数。

fromdatetimeimportdatetimefromtb_chainerimportSummaryWritermodel=L.Classifier(MLP(1000,10))res=model(chainer.Variable(np.random.rand(1,784).astype(np.float32)),chainer.Variable(np.random.rand(1).astype(np.int32)))writer=SummaryWriter('runs/'+datetime.now().strftime('%B%d  %H:%M:%S'))writer.add_graph([res])writer.add_all_variable_images([res],pattern='.*MLP.*')writer.add_all_parameter_histograms([res],pattern='.*MLP.*')writer.close()

参考

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java调用Python函数作为TEID中的UDF   java Android。支持v4导入不工作   java如何影响具有静态属性的类   java如何在从glTexImage2D()分配后编辑纹理的像素颜色   javaspringboot+rediscache+@Cacheable适用于某些方法,而不适用于其他方法   java无法将动态Web模块方面从3.0更改为2.5   java如何在新选项卡中显示打印的文档?   java Google Cloud Endpoints API方法仅在删除用户参数时成功调用   java为什么我可以使用Stack<Double>但不能使用Stack<Double>?   java JDBC PreparedStatement似乎忽略了占位符   java如何设置JInternalFrame的标准图标化位置?   Java文件。copy()不复制文件   基于另一个类的java显示arraylist?   java Android Studio:错误:非法字符:'\u2028'   对象(Java)无法实例化类型映像?   javascript错误:飞行前响应的HTTP状态代码401无效   java确保泛型vararg参数具有相同的类型