tensorflow 版本报错
TensorFlow报错:AttributeError: module 'tensorflow._api.v1.train' has no attribute 'SummaryWriter'等
TensorFlow报错:AttributeError: module ‘tensorflow._api.v1.train’ has no attribute 'SummaryWriter’等
分析:版本更新,方法调用方式改变
import tensorflow.compat.v1 as tf
tf.disable_eager_execution()
解决方式:
报错 | 原方法 | 更改后方法 |
---|---|---|
AttributeError: module ‘tensorflow._api.v1.train’ has no attribute ‘SummaryWriter’ | tf.train.SummaryWriter() | tf.summary.FileWriter() |
AttributeError: module ‘tensorflow’ has no attribute ‘merge_all_summaries’ | tf.merge_all_summaries() | tf.summary.merge_all() |
AttributeError: module ‘tensorflow’ has no attribute ‘histogram_summary’ | tf.histogram_summary() | tf.summary.histogram() |
AttributeError: module ‘tensorflow’ has no attribute ‘scalar_summary’ | tf.scalar_summary() | tf.summary.scalar() |
AttributeError: module ‘tensorflow’ has no attribute ‘image_summary’ | tf.image_summary() | tf.summary.image() |
AttributeError: module ‘tensorflow’ has no attribute 'audio_summary | tf.audio_summary() | tf.summary.audio() |
AttributeError: module ‘tensorflow’ has no attribute ‘merge_summary’ | tf.merge_summary() | tf.summary.merge() |