属性错误:模块'tensorflow.python.summary.summary'没有属性'histogram'



我正在遵循"TensorFlow for Poets"教程,当我尝试运行这个命令时,我被困在图像再训练上:

sudo python3 tensorflow/tensorflow/examples/image_retraining/retrain.py 
--bottleneck_dir=/tf_files/bottlenecks 
--how_many_training_steps 500 
--model_dir=/tf_files/inception --output_graph=/tf_files/retrained_graph.pb 
--output_labels=/tf_files/retrained_labels.txt 
--image_dir tf_files/flower_photos

看起来运行正常,比如

Creating bottleneck at /tf_files/bottlenecks/roses/5960270643_1b8a94822e_m.jpg.txt
Creating bottleneck at /tf_files/bottlenecks/roses/8032328803_30afac8b07_m.jpg.txt
Creating bottleneck at /tf_files/bottlenecks/roses/14176042519_5792b37555.jpg.txt
...

但是最后,我得到了一个错误,

Traceback (most recent call last):
File "tensorflow/tensorflow/examples/image_retraining/retrain.py", line 1014, in <module>
tf.app.run()
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/platform/app.py", line 30, in run
sys.exit(main(sys.argv[:1] + flags_passthrough))
File "tensorflow/tensorflow/examples/image_retraining/retrain.py", line 789, in main
bottleneck_tensor)
File "tensorflow/tensorflow/examples/image_retraining/retrain.py", line 698, in add_final_training_ops
variable_summaries(layer_weights)
File "tensorflow/tensorflow/examples/image_retraining/retrain.py", line 660, in variable_summaries
tf.summary.histogram('histogram', var)
AttributeError: module 'tensorflow.python.summary.summary' has no attribute 'histogram'

我在linux上使用TensorFlow,我没有安装Docker,因为它不是必要的。我不知道如何解决这个问题,因为我是初学者。

显然,问题是您正在调用对象tensorflow.python.summary.summay上不存在的属性。运行dir(tensorflow.python.summary.summay)以获得一个包含该对象的所有方法和属性的列表,因为它可能在新版本中更改了名称。

也测试你是否使用正确的类(因为summary.summary对我来说似乎很奇怪)

似乎是早期版本中的一个bug。更新tensorflow python包(sudo pip install tensorflow——upgrade)。

最新更新