safetyduck
safetyduck

Reputation: 6834

How to use tensorboard with tensorflow 2.0?

The following seems to be the new way of creating a FileWriter but I am not sure how to add_graph or do other things to get the model graph showing up in tensorboard.

train_writer = tf.summary.create_file_writer('logs/1/train')

Upvotes: 0

Views: 530

Answers (1)

Rohan Rajput
Rohan Rajput

Reputation: 11

You can do it by using tf.keras.callback.TensorBoard(/path/to/log/dir) in following way.

  1. Create a build model function

def build_model():
    model = keras.Sequential([
        layers.Dense(64, activation='relu', input_shape=[len(train_dataset[col_to_norm].keys())]),
        layers.Dense(64, activation="relu"),
        layers.Dense(1)
    ])

    optimizer = tf.keras.optimizers.RMSprop(0.001)

    model.compile(loss='mse', 
                 optimizer=optimizer,
                 metrics=['mae', 'mse'])
    return model

2 . assign to a variable

model = build_model()
  1. Fit the model using fit method
model.fit(
  normalized_train_data, train_labels,
  epochs=EPOCHS, validation_split = 0.2, verbose=0,
  callbacks=[tf.keras.callbacks.TensorBoard('logs/1/train')])

Upvotes: 1

Related Questions