[Solved] AttributeError: module ‘tensorboard.summary._tf.summary‘ has no attribute ‘merge‘

The environment is TensorFlow2.9

The code to be run on github The TensorFlow environment is 1.x

Many apis cannot be called

Original code

train_summary_op = tf.summary.merge([loss_summary])

Error reporting in method 1

train_summary_op = tf.compat.v1.summary.merge([loss_summary])

display

TypeError: Tensors in list passed to 'inputs' of 'MergeSummary' Op have types [bool] that do not match expected type string.

If it can’t be solved, I will try

import tensorflow as tf

Modified as

import tensorflow._api.v2.compat.v1 as tf
tf.disable_v2_behavior()

Finally, solve the problem successfully

Read More: