构造Keras Tensorboard图 [英] Structure a Keras Tensorboard graph

查看:278
本文介绍了构造Keras Tensorboard图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我创建一个简单的Keras模型时

When I create a simple Keras Model

model = Sequential()
model.add(Dense(10, activation='tanh', input_dim=1))
model.add(Dense(1, activation='linear'))
model.compile(loss='mean_squared_error', optimizer='adam', metrics=['mean_squared_error'])

并回调到Tensorboard

and do a callback to Tensorboard

tensorboard = TensorBoard(log_dir='c:/temp/tensorboard/run1', histogram_freq=1, write_graph=True, write_images=False)
model.fit(x, y, epochs=1000, batch_size=1, callbacks=[tensorboard])

Tensorboard中的输出如下所示:

The output in Tensorboard looks like this:

换句话说,这是一团糟.

In other words, it's a complete mess.

  1. 有什么我可以做的使图形输出看起来更有条理吗?
  2. 如何使用Keras和Tensorboard创建权重的直方图?

推荐答案

您可以使用K.name_scope('name_scope')创建名称范围以对模型中的图层进行分组.

You can create a name scope to group layers in your model using with K.name_scope('name_scope').

示例:

with K.name_scope('CustomLayer'):
  # add first layer in new scope
  x = GlobalAveragePooling2D()(x)
  # add a second fully connected layer
  x = Dense(1024, activation='relu')(x)

感谢 https://github.com/fchollet/keras/pull/4233#issuecomment-316954784

这篇关于构造Keras Tensorboard图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆