Models: AttributeError: module 'tensorflow' has no attribute 'data'

Created on 23 Nov 2017  路  8Comments  路  Source: tensorflow/models

Why runing mnist.py has:
dataset = tf.data.TFRecordDataset([filename])
AttributeError: module 'tensorflow' has no attribute 'data'

My env is ubuntu and a conda installed tensrflow

Most helpful comment

Yes, as @blairjordan mentions, tf.contrib.data has been upgraded to just tf.data in TensorFlow v1.4. So you need to make sure you're using v1.4.

Also check out the differences between the old and new API:
https://github.com/tensorflow/tensorflow/blob/r1.4/tensorflow/contrib/data/README.md

@baimin1 does that resolve your issue?

All 8 comments

another:
dataset = dataset.map(example_parser).prefetch(batch_size)
AttributeError: 'MapDataset' object has no attribute 'prefetch'

Apparently it's part of the core tensorflow API. I've checked my version (1.4.0) and still require tf.contrib.data. Not sure why.

See release https://github.com/tensorflow/tensorflow/releases/tag/v1.4.0

The arguments accepted by the Dataset.map() transformation have also changed:

dataset.map(..., output_buffer_size=B) is now dataset.map(...).prefetch(B).

I'd check that you have the latest version. In my case, I still need to use the old tf.contrib.data.

Yes, as @blairjordan mentions, tf.contrib.data has been upgraded to just tf.data in TensorFlow v1.4. So you need to make sure you're using v1.4.

Also check out the differences between the old and new API:
https://github.com/tensorflow/tensorflow/blob/r1.4/tensorflow/contrib/data/README.md

@baimin1 does that resolve your issue?

Does this mean that the config-file named cloud.yml in object_detection/samples/cloud/ should have runtime-version 1.4? This does not seem correct either. Running this with version 1.4 with the above command removes the error with the missing 'data' module, as suggested above. However, it does introduce a new error, something like
AttributeError: 'module' object has no attribute 'parallel_interleave' tensorflow

At least to me, on June 1st 2018, everything works by upgrading to runtime-version 1.5 with

From tensorflow/models/research/

gcloud ml-engine jobs submit trainingwhoami_object_detection_date +%s\
--runtime-version 1.5 \
--job-dir=gs://${YOUR_GCS_BUCKET}/train \
--packages dist/object_detection-0.1.tar.gz,slim/dist/slim-0.1.tar.gz \
--module-name object_detection.train \
--region us-central1 \
--config object_detection/samples/cloud/cloud.yml \
-- \
--train_dir=gs://${YOUR_GCS_BUCKET}/train \
--pipeline_config_path=gs://${YOUR_GCS_BUCKET}/data/faster_rcnn_resnet101_pets.config

Hopefully this works for others, too!

Closing as the issue is resolved

under tf 1.4 use tf.contrib.data instead of tf.data

I had the same issue and reinstalling tf 1.15.0 with conda (conda install tensorflow-gpu==1.15.0) seems to fix the problem. No need to use tf.contrib.data either (tf.data works for me)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nmfisher picture nmfisher  路  3Comments

Mostafaghelich picture Mostafaghelich  路  3Comments

kamal4493 picture kamal4493  路  3Comments

noumanriazkhan picture noumanriazkhan  路  3Comments

airmak picture airmak  路  3Comments