可视化训练数据批次中的训练图像train_images,train_labels = next(train_data.as_numpy_iterator())show_25_images(train_images,train_labels)
typeError Traceback(most recent call last)in 1 #可视化训练数据批次中的训练图像-> 2 train_images,train_labels = next(train_data.as_numpy_iterator())3 show_25_images(train_images,train_labels)
/usr/local/lib/python3.8/dist-packages/tensorflow/python/data/ops/dataset_ops.py in as_numpy_iterator(self)614 component_spec,615(tensor_spec.TensorSpec,ragged_tensor.RaggedTensorSpec)):--> 616 raise TypeError(617 f”tf.data.Dataset.as_numpy_iterator()
is not supported for“618 f“datasets that produce values of type {component_spec.value_type}”)
TypeError:tf.data.Dataset.as_numpy_iterator()
不支持生成<class 'tensorflow.python.data.util.structure. NoneTensor'>类型值的数据集
图像集
1条答案
按热度按时间cnjp1d6j1#
您需要将数据集传递给
tf.data.Dataset.from_tensor_slices()
或tf.data.Dataset.from_tensors()
以创建tf.data.Dataset
。例如:
字符串
然后可以通过
as_numpy_iterator()
迭代tf.data.dataset
型
或者是
型