Peter Teoh
Peter Teoh

Reputation: 6723

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

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).

Upvotes: 6

Views: 8543

Answers (3)

Khaled.
Khaled.

Reputation: 59

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

Upvotes: 2

Dylan Hogg
Dylan Hogg

Reputation: 3398

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.

Upvotes: 13

Daniel Darabos
Daniel Darabos

Reputation: 27455

FixedLenFeature was added in TensorFlow 0.7.0. You have an earlier version installed. You can check your version with print tf.__version__.

Upvotes: 4

Related Questions