AttributeError: 'TensorSliceDataset' object has no attribute 'get_shape'
AttributeError: 'TensorSliceDataset' object has no attribute 'get_shape'
我正在尝试使用数据集将图像加载到模型中。但是,我不断收到错误消息,指出我的张量切片没有 get_shape() 属性。我已经确认他们不会尝试在我的代码中调用它。我做错了什么?
我正在使用:
Anaconda 上的 Spyder 4.1.5 |
喀拉斯 2.3.1 |
张量流 2.1.0
# load dataset
dataset = h5py.File('3dshapes.h5', 'r')
print(dataset.keys())
images = dataset['images'] # array shape [480000,64,64,3], uint8 in range(256)
labels = dataset['labels'] # array shape [480000,6], float64
train_dataset = tf.data.Dataset.from_tensor_slices((images[1:10], labels[1:10]))
test_dataset = tf.data.Dataset.from_tensor_slices((images[10:20], labels[10:20]))
print("train_dataset", train_dataset)
print("test_dataset", test_dataset)
train_dataset <TensorSliceDataset shapes: ((64, 64, 3), (6,)), types:
(tf.uint8, tf.float64)>
test_dataset <TensorSliceDataset shapes: ((64, 64, 3), (6,)), types: (tf.uint8, tf.float64)>
File "C:\Users\Administration
User.conda\envs\Keras\lib\site-packages\tensorflow_core\python\keras\layers\convolutional.py",
line 192, in call
call_input_shape = inputs.get_shape()
AttributeError: 'TensorSliceDataset' object has no attribute
'get_shape'
原来我只需要在 Anaconda 上设置一个新的 Python 环境并安装 Tensorflow 和 Keras。我现有的环境已经设置好了这些,但是其他各种帖子都提到这样做会有所帮助,而且确实如此。
我正在尝试使用数据集将图像加载到模型中。但是,我不断收到错误消息,指出我的张量切片没有 get_shape() 属性。我已经确认他们不会尝试在我的代码中调用它。我做错了什么?
我正在使用: Anaconda 上的 Spyder 4.1.5 | 喀拉斯 2.3.1 | 张量流 2.1.0
# load dataset
dataset = h5py.File('3dshapes.h5', 'r')
print(dataset.keys())
images = dataset['images'] # array shape [480000,64,64,3], uint8 in range(256)
labels = dataset['labels'] # array shape [480000,6], float64
train_dataset = tf.data.Dataset.from_tensor_slices((images[1:10], labels[1:10]))
test_dataset = tf.data.Dataset.from_tensor_slices((images[10:20], labels[10:20]))
print("train_dataset", train_dataset)
print("test_dataset", test_dataset)
train_dataset <TensorSliceDataset shapes: ((64, 64, 3), (6,)), types: (tf.uint8, tf.float64)>
test_dataset <TensorSliceDataset shapes: ((64, 64, 3), (6,)), types: (tf.uint8, tf.float64)>
File "C:\Users\Administration User.conda\envs\Keras\lib\site-packages\tensorflow_core\python\keras\layers\convolutional.py", line 192, in call call_input_shape = inputs.get_shape()
AttributeError: 'TensorSliceDataset' object has no attribute 'get_shape'
原来我只需要在 Anaconda 上设置一个新的 Python 环境并安装 Tensorflow 和 Keras。我现有的环境已经设置好了这些,但是其他各种帖子都提到这样做会有所帮助,而且确实如此。