C3W1 - Error in 5.3 : intersection_over_union

Hello,
Can someone help with the C3W1 Programming Assignment in Section 5.3. My model created successfully with pretty low training and validation errors. Here’s the loss
31/31 [==============================] - 6s 187ms/step - loss: 0.0206 - bounding_box_loss: 0.0206
Loss: [0.02055751346051693, 0.02055751346051693]
However, when I proceed to the next section : 5.3 Evaluate performance using IoU, the function is throwing an error :

16/16 [==============================] - 3s 89ms/step

TypeError Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/numpy/lib/shape_base.py in split(ary, indices_or_sections, axis)
858 try:
→ 859 len(indices_or_sections)
860 except TypeError:

TypeError: object of type ‘int’ has no len()

During handling of the above exception, another exception occurred:

AttributeError Traceback (most recent call last)
2 frames
/usr/local/lib/python3.10/dist-packages/numpy/lib/shape_base.py in split(ary, indices_or_sections, axis)
860 except TypeError:
861 sections = indices_or_sections
→ 862 N = ary.shape[axis]
863 if N % sections:
864 raise ValueError(

AttributeError: ‘list’ object has no attribute ‘shape’

This function was not defined by me, which leads me to believe that something isn’t right with the model. However, you can see from my starting comment that the model compiles, trains, and validates fine. Please advise.

Hello @AnilA

Please DM your notebook for review. Click on my name and then message.

Regards
DP

Hello @AnilA

Corrections required

  1. In exercise 4 while defining final model,
    define the TensorFlow Keras model using the inputs and outputs to your model
    your output code is incorrect.
    Notice the highlighted last instructions in pic below

CODE Removed_output = bounding_box_regression(X)
so your output cannot be combination of last dense layer and bounding box output??

  1. for exercise in def define_and_compile_mode
    loss = {‘bounding_box’ : ‘mse’}, I am seeing first time using output to the loss, please only use ‘mse’ as per instructions given before the grader cell
  • Set the loss function of SGD to mean squared error (see the SGD documentation for an example of how to choose mean squared error loss).
  1. 4.1 Prepare to Train the Model
  • BATCH_SIZE: Set the BATCH_SIZE to an appropriate value. You can look at the ungraded labs from this week for some examples.
    So was the batch_size used as per ungraded lab?? Extra hint: try to reduce your batch size in case you are not getting desire IOU
  1. Now comes to the section you got error, I suppose either by mistake you have delete an import code cell from your notebook, I am sharing the screenshot Notice in your notebook, there is no 5.2 Save your Model for Grading.

By any case, I highly recommend you to use a fresh copy, and then copy your codes to the new notebook and then do the assignment

Please let me know once your issue gets resolved.

Regards
DP

Hello @Deepti_Prasad…I sincerely appreciate your quick response. I was able to fix the issue by removing the unnecessary item from the outputs of my model. Everything went well right after that, and the submission was successful. Thank you very much.

1 Like