Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write to TensorBoard every x samples. #11152

Merged
merged 17 commits into from
Oct 1, 2018
Merged

Write to TensorBoard every x samples. #11152

merged 17 commits into from
Oct 1, 2018

Conversation

gabrieldemarmiesse
Copy link
Contributor

@gabrieldemarmiesse gabrieldemarmiesse commented Sep 16, 2018

Summary

Closes #7617 .
This PR is an update of #7617. Credit goes to @sameermanek for his work.

The goal of the PR is to be able to see the metrics and losses in a per-batch basis instead of a per-epoch basis.

Related Issues

#6692

PR Overview

This PR is backward compatible

A new argument has been added to the constructor of the TensorBoard callback. Here is the description that I added in the docs:

write_step:
'batch' or 'epoch' or integer. When using 'batch', writes
the losses and metrics to TensorBoard after each batch. The same
applies for 'epoch'. If using an integer, let's say 10000,
the callback will write the metrics and losses to TensorBoard every
10000 samples. Note that writing too frequently to TensorBoard
can slow down your training.

Feedback welcome. Especially from @fchollet since the API has been changed.

  • This PR requires new unit tests [y/n] (make sure tests are included)
  • This PR requires to update the documentation [y/n] (make sure the docs are up-to-date)
  • This PR is backwards compatible [y/n]
  • This PR changes the current API [y/n] (all API changes need to be approved by fchollet)

@gabrieldemarmiesse gabrieldemarmiesse changed the title [WIP] Logging the number of batches seen in TensorBoard. [WIP] Write to TensorBoard after every batch. Sep 16, 2018
@gabrieldemarmiesse gabrieldemarmiesse changed the title [WIP] Write to TensorBoard after every batch. Write to TensorBoard after every batch. Sep 16, 2018
@gabrieldemarmiesse gabrieldemarmiesse changed the title Write to TensorBoard after every batch. Write to TensorBoard every x samples. Sep 16, 2018
Copy link
Member

@fchollet fchollet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a useful feature, thanks for the PR. @omalleyt12 would you mind taking a look? Thank you.

@@ -715,6 +715,12 @@ class TensorBoard(Callback):
`embeddings_layer_names`. Numpy array (if the model has a single
input) or list of Numpy arrays (if the model has multiple inputs).
Learn [more about embeddings](https://www.tensorflow.org/programmers_guide/embedding)
write_step: `'batch'` or `'epoch'` or integer. When using `'batch'`, writes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's already a embeddings_freq argument, and this new argument write_step is not consistent with it. Maybe write_freq or update_freq would be better. Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming things is as hard as ever.
I like update_freq since we "abstract" the writing to the file in this case. The user doesn't really care (take this with a grain of salt) what happens to the file. He/she wants to see the plot being updated. That's what matters.

@gabrieldemarmiesse
Copy link
Contributor Author

write_step became update_freq.

@gabrieldemarmiesse
Copy link
Contributor Author

ping @omalleyt12

@ahundt
Copy link
Contributor

ahundt commented Sep 30, 2018

LGTM, a useful feature and a nice improvement over the pr it is based on. The new param names + options are much better.

Copy link
Contributor

@omalleyt12 omalleyt12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM!

Copy link
Member

@fchollet fchollet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Note that we will need to port that same feature to tf.keras as well.

@fchollet fchollet merged commit ecbf73f into keras-team:master Oct 1, 2018
@gabrieldemarmiesse
Copy link
Contributor Author

gabrieldemarmiesse commented Oct 1, 2018

Thanks. I don't think I'll make the PR in the Tensorflow repo because of lack of time. I'll let someone else do it if you don't mind.

@bersbersbers
Copy link

bersbersbers commented Oct 10, 2018

I just recently switched from Keras to tf.keras, and noticed that TensorBoard summaries looked a little bit different there: With tensorflow-gpu==1.11.0 and tensorboard==1.11.0, I no longer have data in val_loss, but in epoch_val_loss; and in addition to loss, there are epoch_loss and batch_loss. Is that a difference between the two Keras version? Will it impact porting of this feature here to tf.keras?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants