I am testing tensorflow tf.data.Dataset
method as_numpy_iterator
using tensorflow 2.0.0
. According to the official documentation https://www.tensorflow.org/api_docs/python/tf/data/Dataset?version=stable#as_numpy_iterator, this function allows directly inspecting the content of a tensorflow dataset. But when I try the given example:
dataset = tf.data.Dataset.from_tensor_slices([1, 2, 3])
for element in dataset.as_numpy_iterator():
print(element)
There occurs an error: AttributeError: 'TensorSliceDataset' object has no attribute 'as_numpy_iteractor'
. I am wondering if this method is just newly added, beyond the support of tensorflow 2.0.0. If so, is there an alternative to checking the dataset content as the as_numpy_iterator()
?
The link to the documentation that you provided points to
TensorFlow Core r2.1
Updating your tensorflow
version to version 2.1
should solve the issue;
The method .as_numpy_iterator()
is not present in TensorFlow 2.0, but only in TensorFlow >= 2.1