构建 Keras Tensorboard 图

2024-04-01

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

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 进行回调

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])

The output in Tensorboard looks like this: enter image description here

换句话说,这完全是一团糟。

  1. 我可以做些什么来使图表输出看起来更加结构化吗?
  2. 如何使用 Keras 和 Tensorboard 创建权重直方图?

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

Example:

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 https://github.com/fchollet/keras/pull/4233#issuecomment-316954784

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

构建 Keras Tensorboard 图 的相关文章

随机推荐