I was trying to run a deep learning project related to lip reading based on this Youtube video.
The entire code is on github.
The developer used the following versions of modules:
- opencv-python -4.0.6.66
- imageio-2.23.0
- matplotlib-3.6.2
- tensorflow-2.10.1
While I was trying to fit the model. I was getting time distributed and flatten related errors.
I was earlier running python version-3.12 but later I also tried on python:3.9.13 but still I was getting same errors. I was also using the same versions for all modules, except for Tensorflow, I was using 2.18(even tried on 2.16) because 2.10.1 was unavailable.
I was getting the following error during fitting:(I removed the callback part for checkpoints)
InvalidArgumentError Traceback (most recent call last)
Cell In[49], line 1----> 1 model.fit(data, epochs=100)
File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\keras\src\utils\traceback_utils.py:122, in filter_traceback.<locals>.error_handler(*args, **kwargs) 119 filtered_tb = _process_traceback_frames(e.__traceback__) 120 # To get the full stack trace, call: 121 # `keras.config.disable_traceback_filtering()`--> 122 raise e.with_traceback(filtered_tb) from None 123 finally: 124 del filtered_tb
File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\tensorflow\python\eager\execute.py:53, in quick_execute(op_name, num_outputs, inputs, attrs, ctx, name) 51 try: 52 ctx.ensure_initialized()---> 53 tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name, 54 inputs, attrs, num_outputs) 55 except core._NotOkStatusException as e: 56 if name is not None:InvalidArgumentError: Graph execution error:
Detected at node sequential_1_1/time_distributed_1_1/Reshape_63 defined at (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
Only one input size may be -1, not both 0 and 1 [[{{node sequential_1_1/time_distributed_1_1/Reshape}}]] [Op:__inference_one_step_on_iterator_55026]
The code snippet I guess I am getting the error is in this part:
model = Sequential()
model.add(Conv3D(128, 3, input_shape=(75,46,140,1), padding='same'))
model.add(Activation('relu'))
model.add(MaxPool3D((1,2,2)))
model.add(Conv3D(256, 3, padding='same'))
model.add(Activation('relu'))
model.add(MaxPool3D((1,2,2)))
model.add(Conv3D(75, 3, padding='same'))
model.add(Activation('relu'))
model.add(MaxPool3D((1,2,2)))
model.add(TimeDistributed(Flatten()))
model.add(Bidirectional(LSTM(128, kernel_initializer='Orthogonal', return_sequences=True)))
model.add(Dropout(.5))
model.add(Bidirectional(LSTM(128, kernel_initializer='Orthogonal', return_sequences=True)))
model.add(Dropout(.5))
model.add(Dense(char_to_num.vocabulary_size()+1, kernel_initializer='he_normal', activation='softmax'))
The input shape is: (None,75,46,140,1) The output shape is: (None,75,41)
I imported the following modules:
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Conv3D, LSTM, Dense, Dropout, Bidirectional, MaxPool3D, Activation, Reshape, SpatialDropout3D, BatchNormalization, TimeDistributed, Flatten
from tensorflow.keras.optimizers import Adam
from tensorflow.keras.callbacks import ModelCheckpoint, LearningRateScheduler
The data was imported using the following code:
data = tf.data.Dataset.list_files('./data/s1/*.mpg')
data = data.shuffle(500, reshuffle_each_iteration=False)
data = data.map(mappable_function)
data = data.padded_batch(2, padded_shapes=([75,None,None,None],[40]))
data = data.prefetch(tf.data.AUTOTUNE)
The type of data is:
tensorflow.python.data.ops.dataset_ops._OptionsDataset
You can view the entire code here.
what changes need to I make for this code to work?