Tensorflow: 'module' object has no attribute 'FixedLenFeature'

Viewed 6845

I was running through Google's Tensorflow's fully_connected_reader.py example (I have executed convert_to_record.py, and source code is here:

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'

Anyone got any idea? (it is running from the latest github version).

3 Answers

If you are using TensorFlow 2.x, FixedLenFeature has moved from tf.FixedLenFeature into tf.io.FixedLenFeature.

The use of tf.FixedLenFeature was marked as deprecated in previous versions.

Use tf.io.FixedLenFeature instead. Same goes for VarLenFeature (use tf.io.VarLenFeature).

Related