Skip to content

AttributeError: module 'tensorflow' has no attribute 'data' #2879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
baimin1 opened this issue Nov 23, 2017 · 11 comments
Closed

AttributeError: module 'tensorflow' has no attribute 'data' #2879

baimin1 opened this issue Nov 23, 2017 · 11 comments

Comments

@baimin1
Copy link

baimin1 commented Nov 23, 2017

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

@baimin1
Copy link
Author

baimin1 commented Nov 23, 2017

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

@blairjordan
Copy link

blairjordan commented Nov 23, 2017

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

@blairjordan
Copy link

blairjordan commented Nov 23, 2017

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.

@tatatodd
Copy link

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?

@tatatodd tatatodd added the stat:awaiting response Waiting on input from the contributor label Nov 29, 2017
@sweapon
Copy link

sweapon commented Jun 1, 2018

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 training whoami_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!

@wt-huang
Copy link

Closing as the issue is resolved

@yu7856288
Copy link

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

@pablomp3
Copy link

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)

@marksandler2 marksandler2 removed the stat:awaiting response Waiting on input from the contributor label May 29, 2020
@JanaranjaniPalaniswamy
Copy link

I am using tensorflow version 2.3.0 and facing the same issue. Can anyone tell me what exactly is the fix?

@bayma-1
Copy link

bayma-1 commented Sep 20, 2022

I faced the same issue and fixed it by: pip install tensorflow-io

@Yongbobloomington
Copy link

I faced the same issue and fixed it by: pip install tensorflow-io

doesn't work for me, unfortunately

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests