简体   繁体   中英

How to use callbacks in keras subclassed model?

I instantiate keras subclassed model, as tensorflow guide ,

To be able to use .fit to my model class, I need to create compute_output_shape . Nevertheless, using callbacks for fitted model throw NotImplementedError .

So, what can I do to use callbacks in keras subclassed model, such as tensorboard, checkpoints, etc ?

You can try this:

model = SubclassModel()
# Callbacks you can define
tensorboard_callback = tf.keras.callbacks.TensorBoard(log_dir='model')
# Add callbacks to fit parameter
model.fit(data, labels, batch_size=100, epochs=5, callbacks=[tensorboard_callback])

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