Text classification with an RNN with the tutorial:
https://www.tensorflow.org/tutorials/text/text_classification_rnn
Description of the bug.
Environment information
tensorflow-datasets/tfds-nightly version: 1.3.2tensorflow/tensorflow-gpu/tf-nightly/tf-nightly-gpu version: <2.0.0Reproduction instructions
from __future__ import absolute_import, division, print_function, unicode_literals
import tensorflow_datasets as tfds
import tensorflow as tf
dataset, info = tfds.load('imdb_reviews/subwords8k', with_info=True, as_supervised=True)
train_dataset, test_dataset = dataset['train'], dataset['test']
encoder = info.features['text'].encoder
BUFFER_SIZE = 10000
BATCH_SIZE = 64
train_dataset = train_dataset.shuffle(BUFFER_SIZE)
train_dataset = train_dataset.padded_batch(BATCH_SIZE, train_dataset.output_shapes)
test_dataset = test_dataset.padded_batch(BATCH_SIZE, test_dataset.output_shapes)
Link to logs
2019-12-08 17:20:18.271202: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
Traceback (most recent call last):
File "C:/Users/Oskar/Desktop/Twitter/analiza/main1.py", line 51, in
train_dataset = train_dataset.padded_batch(BATCH_SIZE, train_dataset.output_shapes)
AttributeError: 'ShuffleDataset' object has no attribute 'output_shapes'
Expected behavior
Should go run the above code without any error.
change "train_dataset.output_shapes" to "tf.compat.v1.data.get_output_shapes(train_dataset)"
output_shapes is deprecated in TF2, you can use the compat.v1 or use ds.element_spec: https://www.tensorflow.org/api_docs/python/tf/data/Dataset#element_spec
shapes = tf.nest.map_structure(
lambda spec: spec.shape,
ds.element_spec,
)
change "train_dataset.output_shapes" to "tf.compat.v1.data.get_output_shapes(train_dataset)"
worked for me! thanks to zaabek
Thanks it woked for me too.
thanks a lot!
Most helpful comment
change "train_dataset.output_shapes" to "tf.compat.v1.data.get_output_shapes(train_dataset)"