Week 1 : Programming Assignment, ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (10,) + inhomogeneous part

Hello everyone,
I ran the codes from Week 1 : Programming Assignment, Predicting Bounding Boxes on my computer,
But in this part code:

(visualization_training_images, visualization_training_bboxes) = dataset_to_numpy_util(visualization_training_dataset, N=10)

I ran into this problem:

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (10,) + inhomogeneous part.

I searched a lot to solve my problem and couldn’t solve it.

I would appreciate it if someone could help me solve my problem.

hi @help

can you post screenshot of the complete error you got. please make sure not to post any codes here

Regards
DP

Hello @Deepti_Prasad
This is my error :

hi @help
in exercise 5, def compile model

places to check, your input shape, what tf function you used as it should be tf.keras.layers.Input

But the expected error should for the length of training and validation dataset mismatch. I am sharing a screenshot from the assignment notebook where it mentions about this.

So make sure you have calculated these both in the same way for validation dataset and training dataset and implement the steps per epoch for both of them same way. as using different function for one and another function for different dataset can also throw such error

So if you have used math.ceil for steps per epoch for training dataset, then use the same way for validation dataset.

if you have used if statement for length of training dataset % BATCH_SIZE > 0, then used the same way for the validation dataset.

Regards
DP

Hi @Deepti_Prasad
I encountered the problem before solving the exercises
( after load caltech_birds2010 datasets )

I got an error in this part :

ok so this could be version issue. can you check which tf and keras version is your notebook working on?

a similar issue thread

version keras = 2.8.0
version tensorflow = 2.8.0
version tensorflow_datasets = 4.4.0
version numpy = 1.21.5

Is it possible that this error is related to the version of Numpy?
( If your answer is yes, what does the Numpy vesion should be installed? )

did you try going back to the classroom page, refresh and reopen the notebook?

thanks, I solved my error

1 Like

@help did refreshing resolve your issue or you had to change the version?

do mention how you resolved your issue as future learner facing similar issues can seek help from your learning journey too.

Regards
DP

Hi @Deepti_Prasad
I did not change the versions
I solved my problem based on the same versions I mentions above.
I updated my jupyter notebook and then
I realized that part of my code was wrong and I fixed that part and my error was resolved
Regards,
H