3

I am executing a program containing the following lines:

def write_log(callback, name, loss, batch_no):
    """
    Write training summary to TensorBoard
    """
    summary = tf.Summary()
    summary_value = summary.value.add()
    summary_value.simple_value = loss
    summary_value.tag = name
    callback.writer.add_summary(summary, batch_no)
    callback.writer.flush()

summary = tf.Summary() is causing the following error

Error: AttributeError: module 'tensorflow' has no attribute 'Summary'

Tensorflow version I am using is 2.3.0. Remaining functions related to 'TensorFlow' are working fine.

How can I fix this?

2
  • Can you provide information such as the error message and the version of TensorFlow you are using? Commented Nov 23, 2020 at 7:15
  • Yeah Updated @Panther314 Commented Nov 23, 2020 at 7:21

1 Answer 1

6

Looking at the documentation of tensorflow, the usage of the tensorboard summary is different now:

writer = tf.summary.create_file_writer("/tmp/mylogs")
with writer.as_default():
  for step in range(100):
    # other model code would go here
    tf.summary.scalar("my_metric", 0.5, step=step)
    writer.flush()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.