keras-team / keras-io

Keras documentation, hosted live at keras.io
Apache License 2.0
2.76k stars 2.04k forks source link

INVALID_ARGUMENT: required broadcastable shapes in Classification Loss #1131

Closed nikeshdevkota closed 2 months ago

nikeshdevkota commented 1 year ago

Hi, I am trying to run RetinaNet on a custom dataset. To generate the dataset, I am using tf.data.Dataset.from_generator().

During model training, I run into INVALID_ARGUMENT: required broadcastable shapes while calculating classification loss and I can't seem to find any solution on the internet. I would appreciate it if I could get directions on how to solve this problem. I have uploaded the full error shown during model training below. Custom Generator

I had made some changes in the code and the deviations from the original code are as follows:

  1. For the custom generator, data_list is a list containing multiple dictionaries in the format [{"image":image,"image/filename":filenames, "objects": {"bbox":bbox,"label":labels}}] is passed to the tf.data.Dataset.from_generator() function.
  2. The custom dataset has only 3 classes in total.
  3. I have changed the area, aspect_ratio, and scale to fit my dataset.
  4. I haven't used horizontal flip as I don't want to flip the image.
  5. I want to have my shorter side of the image to be 256 pixels, so I have changed the min_side to 256 in the "resize_and_pad_image" function. However, I don't understand the function of stride, so I would appreciate it if I could get some explanation of it.
  6. I checked the maximum IOU returned for a limited sample of the dataset. Based on the limited data, on average, I was getting a maximum IOU of greater than 0.5 on 90% of the data.

Resize and Pad Full_Error Full_Error_1 Full_Error_2 Full_Error_3 @srihari-humbarwadi

sachinprasadhs commented 3 months ago

Could you please provide some sample reproducible code. Thanks

github-actions[bot] commented 2 months ago

This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.

github-actions[bot] commented 2 months ago

This issue was closed because it has been inactive for 28 days. Please reopen if you'd like to work on this further.

github-actions[bot] commented 2 months ago

Are you satisfied with the resolution of your issue? Yes No