Tensorflow:'module'对象没有属性'FixedLenFeature'

时间:2016-03-25 06:47:34

标签: python tensorflow

我正在使用Google的Tensorflow的fully_connected_reader.py示例(我已经执行了convert_to_record.py,源代码在这里:

https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/how_tos/reading_data):

python fully_connected_reader.py 
I tensorflow/stream_executor/dso_loader.cc:101] successfully opened CUDA library libcublas.so.7.0 locally
I tensorflow/stream_executor/dso_loader.cc:101] successfully opened CUDA library libcudnn.so.6.5 locally
I tensorflow/stream_executor/dso_loader.cc:101] successfully opened CUDA library libcufft.so.7.0 locally
I tensorflow/stream_executor/dso_loader.cc:101] successfully opened CUDA library libcuda.so locally
I tensorflow/stream_executor/dso_loader.cc:101] successfully opened CUDA library libcurand.so.7.0 locally
Traceback (most recent call last):
  File "fully_connected_reader.py", line 198, in <module>
    tf.app.run()
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/default/_app.py", line 30, in run
    sys.exit(main(sys.argv))
  File "fully_connected_reader.py", line 194, in main
    run_training()
  File "fully_connected_reader.py", line 135, in run_training
    num_epochs=FLAGS.num_epochs)
  File "fully_connected_reader.py", line 114, in inputs
    image, label = read_and_decode(filename_queue)
  File "fully_connected_reader.py", line 62, in read_and_decode
    'image_raw': tf.FixedLenFeature([], tf.string),
AttributeError: 'module' object has no attribute 'FixedLenFeature'

任何人都有任何想法? (它从最新的github版本开始运行。)

3 个答案:

答案 0 :(得分:5)

如果您使用的是TensorFlow 2.x,则FixedLenFeature已从tf.FixedLenFeature移至tf.io.FixedLenFeature

在以前的版本中,已将tf.FixedLenFeature的使用标记为已弃用。

答案 1 :(得分:2)

added中的{p> FixedLenFeatureTensorFlow 0.7.0。您已安装早期版本。您可以使用print tf.__version__检查您的版本。

答案 2 :(得分:2)

改为使用tf.io.FixedLenFeatureVarLenFeature也一样(使用tf.io.VarLenFeature)。