Unknown error: Graph execution error

I’m running into this error while training the model. Couldn’t find any resources online on how to solve it.

Link to the complete code - Colab link

this is the error message -
Epoch 1/100
1/1 [==============================] - 2s 2s/step
Original: set white with c seven again
Prediction: la e e e on

Original: place blue in o six please
Prediction: la e e e o o

450/450 [==============================] - 915s 2s/step - loss: 84.2043 - val_loss: 70.6985 - lr: 1.0000e-04
Epoch 2/100
450/450 [==============================] - ETA: 0s - loss: 71.3770

UnknownError Traceback (most recent call last)
in <cell line: 1>()
----> 1 model.fit(train, validation_data=test, epochs=100, callbacks=[checkpoint_callback, schedule_callback, example_callback])

1 frames
/usr/local/lib/python3.10/dist-packages/tensorflow/python/eager/execute.py 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:

UnknownError: Graph execution error:

Detected at node EagerPyFunc defined at (most recent call last):

Detected at node EagerPyFunc defined at (most recent call last):

2 root error(s) found.
(0) UNKNOWN: InvalidArgumentError: {{function_node _wrapped__Reshape_device/job:localhost/replica:0/task:0/device:GPU:0}} Input to reshape is a tensor with 311040 values, but the requested shape has 3 [Op:Reshape]
Traceback (most recent call last):

File “/usr/local/lib/python3.10/dist-packages/tensorflow/python/ops/script_ops.py”, line 268, in call
return func(device, token, args)

File “/usr/local/lib/python3.10/dist-packages/tensorflow/python/ops/script_ops.py”, line 146, in call
outputs = self._call(device, args)

File “/usr/local/lib/python3.10/dist-packages/tensorflow/python/ops/script_ops.py”, line 153, in _call
ret = self._func(*args)

File “/usr/local/lib/python3.10/dist-packages/tensorflow/python/autograph/impl/api.py”, line 643, in wrapper
return func(*args, **kwargs)

File “”, line 8, in load_data
frames = load_video(video_path)

File “”, line 8, in load_video
frame = tf.image.rgb_to_grayscale(frame)

File “/usr/local/lib/python3.10/dist-packages/tensorflow/python/util/traceback_utils.py”, line 153, in error_handler
raise e.with_traceback(filtered_tb) from None

File “/usr/local/lib/python3.10/dist-packages/tensorflow/python/eager/execute.py”, line 53, in quick_execute
tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,

tensorflow.python.framework.errors_impl.InvalidArgumentError: {{function_node _wrapped__Reshape_device/job:localhost/replica:0/task:0/device:GPU:0}} Input to reshape is a tensor with 311040 values, but the requested shape has 3 [Op:Reshape]

 [[{{node EagerPyFunc}}]]
 [[IteratorGetNext]]
 [[CTCLoss/Shape_3/_4]]

(1) UNKNOWN: InvalidArgumentError: {{function_node _wrapped__Reshape_device/job:localhost/replica:0/task:0/device:GPU:0}} Input to reshape is a tensor with 311040 values, but the requested shape has 3 [Op:Reshape]
Traceback (most recent call last):

File “/usr/local/lib/python3.10/dist-packages/tensorflow/python/ops/script_ops.py”, line 268, in call
return func(device, token, args)

File “/usr/local/lib/python3.10/dist-packages/tensorflow/python/ops/script_ops.py”, line 146, in call
outputs = self._call(device, args)

File “/usr/local/lib/python3.10/dist-packages/tensorflow/python/ops/script_ops.py”, line 153, in _call
ret = self._func(*args)

File “/usr/local/lib/python3.10/dist-packages/tensorflow/python/autograph/impl/api.py”, line 643, in wrapper
return func(*args, **kwargs)

File “”, line 8, in load_data
frames = load_video(video_path)

File “”, line 8, in load_video
frame = tf.image.rgb_to_grayscale(frame)

File “/usr/local/lib/python3.10/dist-packages/tensorflow/python/util/traceback_utils.py”, line 153, in error_handler
raise e.with_traceback(filtered_tb) from None

File “/usr/local/lib/python3.10/dist-packages/tensorflow/python/eager/execute.py”, line 53, in quick_execute
tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,

tensorflow.python.framework.errors_impl.InvalidArgumentError: {{function_node _wrapped__Reshape_device/job:localhost/replica:0/task:0/device:GPU:0}} Input to reshape is a tensor with 311040 values, but the requested shape has 3 [Op:Reshape]

 [[{{node EagerPyFunc}}]]
 [[IteratorGetNext]]

0 successful operations.
0 derived errors ignored. [Op:__inference_test_function_1515170]

Hi @Gayathri, Apologies for the delayed response.
It looks like the error is due to shape mismatch. Make sure your input is resized correctly, and matches the exact shape that your model expects.
Also, the Colab link you shared isn’t accessible. If you’re still facing issue, please provide the reproducible code to replicate and understand the issue.
Thanks!