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
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
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!
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)
Most helpful comment
Yes, as @blairjordan mentions,
tf.contrib.data
has been upgraded to justtf.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?