Issue
I'm trying to load images into a model using datasets. However, I keep getting an error that my tensor slices don't have the get_shape() attribute. I have confirmed that they don't by trying to call it within my code. What am I doing wrong?
I'm using: Spyder 4.1.5 on Anaconda | Keras 2.3.1 | Tensorflow 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'
Solution
Turns out I just needed to setup a new Python environment on Anaconda and install Tensorflow and Keras. My existing environment was already setup with these, but various other posts mentioned that doing this can help, and it did.
Answered By - Christopher Mills
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.