简体   繁体   中英

How to use Tensorboard to create histogram of acitvations with Keras functional API

I use the Keras functional API to create the following network:

input = Input(shape=input_shape)
x = Conv2D(filters=32, kernel_size=(3, 3), activation='relu')(input)
tf.summary.histogram(name="conv1", data=x)
x = Conv2D(filters=64, kernel_size=(3, 3), activation='relu')(x)
tf.summary.histogram(name="conv2", data=x)
x = MaxPool2D(pool_size=(2, 2))(x)
x = Flatten()(x)
x = Dense(units=128, activation='relu')(x)
tf.summary.histogram(name="dense1", data=x)
x = Dense(units=num_classes, activation='softmax')(x)
tf.summary.histogram(name="demse1", data=x)
model = Model(inputs=inp, outputs=x)

I used tf.summary.histogram to extract information regarding the activations of different layers. However, the layer's activation histograms do not appear in Tensorboard.

What do I do wrong?

You can use tensorboard callback to get histogram.

tensorboard_callback = tf.keras.callbacks.TensorBoard(
    log_dir='logs', histogram_freq=1, profile_batch = 0
)

model.fit(x,y, epochs = 5, callbacks = tensorboard_callback)

For complete documentation see here

Tensorboard Histogram -

模型

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM