Skip to content

tf.summary.histogram fails with TypeError: __init__() got an unexpected keyword argument 'values' #1993

@Daniel451

Description

@Daniel451
  • TensorBoard version (from pip package, also printed out when running tensorboard)
    -- TensorBoard 1.14.0a20190301
  • TensorFlow version if different from TensorBoard
    -- TensorFlow-gpu 2.0-alpha
  • OS Platform and version (e.g., Linux Ubuntu 16.04)
    -- Linux, Arch, Kernel 4.19
  • Python version (e.g. 2.7, 3.5)
    -- Python 3.6.7

I have built a GAN with TF 2.0-alpha using tf.keras. I am using TensorBoard via train_writer = tf.summary.create_file_writer("log-train"). Adding scalars with tf.summary.scalar("loss g", loss_g, step=batch_id) and storing predicted images with tf.summary.image("g pred", prediction[0:3], step=batch_id) works without any problems.

However, when I try to add the generator's weights to TensorBoard with tf.summary.histogram it fails.

for layer in G_model.layers:
    for weight in layer.weights:
        tf.summary.histogram(weight.name, weight, step=batch_id)

G_model is a tf.keras model created with the functional API.

The exception seems to be TensorBoard-specific:

Traceback (most recent call last):
  File "train.py", line 84, in <module>
    tf.summary.histogram(weight.name, weight, step=batch_id)
  File "(...)/python3.6/site-packages/tensorboard/plugins/histogram/summary_v2.py", line 73, in histogram
    tensor = _buckets(data, bucket_count=buckets)
  File "(...)/python3.6/site-packages/tensorboard/plugins/histogram/summary_v2.py", line 91, in _buckets
    with tf.name_scope('buckets', values=[data, bucket_count]):
TypeError: __init__() got an unexpected keyword argument 'values'

If I simply delete , values=[data, bucket_count] in summary_v2.py (line 91) it works, weights are showing up correctly in TensorBoard then.

Thus, original code of summary_v2.py in line 91:

with tf.name_scope('buckets', values=[data, bucket_count]):

throws the exception posted above, while this code:

with tf.name_scope('buckets'):

is working properly.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions