I'm just starting to approach ml, and I'm trying to train a model on an image dataset obtained from directories of images using tf.keras.utils.image_dataset_from_directory (then pickling it), so that it can predict which letter is fingerspelled in the image.
#PICKLE LOAD
#TRAIN
#images
with open('x_train.pkl', 'rb') as x_train_pickle:
x_train_data = pickle.load(x_train_pickle)
#labels
with open('y_train.pkl', 'rb') as y_train_pickle:
y_train_data = pickle.load(y_train_pickle)
#VALIDATION
with open('x_val.pkl', 'rb') as x_val_pickle:
x_val_data = pickle.load(x_val_pickle)
with open('y_val.pkl', 'rb') as y_val_pickle:
y_val_data = pickle.load(y_val_pickle)
#TEST
with open('x_test.pkl', 'rb') as x_test_pickle:
x_test_data = pickle.load(x_test_pickle)
with open('y_test.pkl', 'rb') as y_test_pickle:
y_test_data = pickle.load(y_test_pickle)
You are giving 5D data to Conv2d instead of 4D.So, either your data should be in the shape (batch_size*32, 180, 180, 3) or You can use the TimeDistributed layer wrapper to apply the same convolution layer on all the images in the 5D tensor. For example:
model = Sequential()
model.add(tf.keras.layers.TimeDistributed(tf.keras.layers.Conv2D(32, 3, activation='relu')))
model.summary()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.