How can i resolve this errors?

When I train my dataset, which consists of 3 folders: train, valid, test, where each folder contains 2 subfolders: images (containing images) and labels (containing label files), I use the following packages: TensorFlow, Keras, patchify, OpenCV, and scikit-learn.
Epoch 1/500
in user code:
File “C:\Users\Dell\PycharmProjects\pythonProject\venv\lib\site-packages\keras\engine\”, line 1284, in train_function *
return step_function(self, iterator)
File “C:\Users\Dell\PycharmProjects\pythonProject\venv\lib\site-packages\keras\engine\”, line 1268, in step_function **
outputs =, args=(data,))
File “C:\Users\Dell\PycharmProjects\pythonProject\venv\lib\site-packages\keras\engine\”, line 1249, in run_step **
outputs = model.train_step(data)
File “C:\Users\Dell\PycharmProjects\pythonProject\venv\lib\site-packages\keras\engine\”, line 1055, in train_step
return self.compute_metrics(x, y, y_pred, sample_weight)
File “C:\Users\Dell\PycharmProjects\pythonProject\venv\lib\site-packages\keras\engine\”, line 1149, in compute_metrics
self.compiled_metrics.update_state(y, y_pred, sample_weight)
File “C:\Users\Dell\PycharmProjects\pythonProject\venv\lib\site-packages\keras\engine\”, line 577, in update_state, y_true)
File “C:\Users\Dell\PycharmProjects\pythonProject\venv\lib\site-packages\keras\engine\”, line 483, in build
self._metrics = tf.internal.nest.map_structure_up_to(
File “C:\Users\Dell\PycharmProjects\pythonProject\venv\lib\site-packages\keras\engine\”, line 631, in _get_metric_objects
return [self._get_metric_object(m, y_t, y_p) for m in metrics]
File “C:\Users\Dell\PycharmProjects\pythonProject\venv\lib\site-packages\keras\engine\”, line 631, in
return [self._get_metric_object(m, y_t, y_p) for m in metrics]
File “C:\Users\Dell\PycharmProjects\pythonProject\venv\lib\site-packages\keras\engine\”, line 652, in _get_metric_object
y_t_rank = len(y_t.shape.as_list())
ValueError: as_list() is not defined on an unknown TensorShape.

Hi @Mira_Bitou, Could you please provide the standalone code to reproduce the issue. Thank You.

Hello @Mira_Bitou Your code is bit cluttered and it’s difficult to point which filename particularly the code is causing the issues. Can you upload your code somewhere (like Google Drive, GitHub, (Removed by moderator) for us to evaluate it better? From the code it seems that there is some issue related to the shape of the inputs provided or something.

I will import the project into the drive and send it to you.

Give me your email so that I can send you the codes I have used because downloading in driver an entire project takes a lot of time , And the dataset that I’m using .

Apparently sharing mail is not allowed here. You may upload the whole code and only few instances of dataset for me to look at. I don’t need entire dataset for debug purposes. Thank you.

Just include a link to a public Colab Notebook with a runnable code snippet.

If required you may upload some of the dataset to the cloud (s3, drive, etc.) and test that both is public and runs the snippet.