question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Assertion error when using histogram_freq>0 in TensorBoard callback

See original GitHub issue

Hey guys, I’m trying to get Keras to work with TensorBoard, but when I set histogram_freq to something different then 0, I get the following AssertionError:

File "/home/projects/keras/keras/callbacks.py", line 925, in on_epoch_end
    assert len(val_data) == len(tensors)

from here. The objects whose lengths are compared are created a few lines above like so:

val_data = self.validation_data
tensors = (self.model.inputs +
                  self.model.targets +
                  self.model.sample_weights)

Honestly, I don’t really see why this assertion makes sense, at least not with weights involved in the tensors. Might be obvious, but its my first time using Keras and I’m happy to learn.

The implementation can be found here. The version online works if you check it out, but changing histogram_freq in this line makes the code crash after the first epoch.

I’m using the master branch, tested with the (currently) newest commit, but this error is present longer, at least since last weekend.

TensorFlow is version 1.11.0 from pip.

Also, as I’m new to Keras, general comments / advice about my code is very welcome.

Edit: #11044 seems to have the same problem.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
kwaegelcommented, Jun 19, 2019

Bumping this to indicate continued interest. This is the fifth still-open, 9-month-old Keras bug I’ve encountered in the past two weeks.

2reactions
tik0commented, Jan 9, 2019

It seems that the tensors list is full of None entries in some cases (for me it was the Keras vanilla VAE example as well). However, removing all None entries before the assertion fixed the bug for me:

Content of keras/callbacks.py:

...
tensors = [t for t in tensors if t is not None] # Add this line
assert len(val_data) == len(tensors)
...
Read more comments on GitHub >

github_iconTop Results From Across the Web

tf.keras.callbacks.TensorBoard | TensorFlow v2.11.0
If set to 0, histograms won't be computed. Validation data (or split) must be specified for histogram visualizations. whether to visualize the graph...
Read more >
Keras Tensorboard Error when Histogram Frequency active
I am running a simple Neural Network with Keras, backend Tensorflow, when trying to use Tesorboard to monitor training. My model is the ......
Read more >
keras.callbacks — pysparkdl documentation
TRAIN): """Configures callbacks for use in various training loops. ... to run per training epoch. samples: Number of training samples. verbose: int, 0...
Read more >
Release 2.12.0
TensorBoard callback, so that summaries logged automatically for model weights now include either a /histogram or /image suffix in their tag names, ...
Read more >
Training & evaluation with the built-in methods
Description: Complete guide to training & evaluation with fit() and ... tf from tensorflow import keras from tensorflow.keras import layers ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found