C3 W1 assignment some issue in my code?

When I am doing training, my predicted bounding boxes somehow end up in the top left corner of the image and very bad IOU results. I am a bit perplexed, because my model summary agrees with the “expected result” model and data preparation was done by instructor initial code… I thought that I changed something by mistake and reloaded the code and retyped all necessary exercises but the result repeated itself… Any suggestion where to look further? Thanks!!!

When I train the model, this is the command line:
history = model.fit(training_dataset, epochs=EPOCHS, validation_data = validation_dataset, batch_size=BATCH_SIZE, validation_steps=validation_steps, steps_per_epoch=steps_per_epoch, verbose=1)

That’s the only place where training_dataset and validation_dataset are used, and they are prepared using instructor’s code. So I do not see how can predicted bounding boxes get shifted to top left corner. When I use different number of batches, epochs, different optimization, add dropout, keep getting the same problem. Also, I see that training error is much smaller validation error; there is overfitting. So may be problem with validation set only, not training set? But preliminary plots with labels all look good, only predicted boxes and IOU are bad. The model seems no issue because model.summary looks exactly as expected. Any suggestion? I can share more code.
Thanks!

Hello @Dennis_Sinitsky

Please DM your notebook with renamed as Dennis copy.

Regards
DP

Hi Deepti,
thank you, I just sent to you.
Dennis

1 Like

Hello @Dennis_Sinitsky

Errors or correction required in your notebook.

  1. For the exercise 3, bounding box regression, you are only suppose to add units and the name as mentioned the instructions, the reason you do not require activation for this layer as it is using from the previous dense layer and passed into this function as the variable x.

  2. For the exercise 5, in defining and compiling model, while defining input layer, you are recalling it by incorrect tf model layer function call, please include layers. (this was probably a mistake as I see you are good at programming)

  3. In the same exercise 5, your model compile statement you have hard code path, also in the instruction it only mentions you to use loss and optimizer, so you do not require metric parameter for compile statement. Another correction kindly use ‘mse’ instead of mean squared error for loss.

  4. In your exercise 6, prepare to train model, your epoch set right now can be changed if not getting desired iou. the notebook you sent, you are using epoch of 30, so increasing a bit will be helpful.(hint, I see you using the correct number of epoch too but you have # it )

  5. In the exercise 7, fit the model, if you read carefully instruction the batch size for this assignment is basically converted into steps per epochs, so really do not need batch_size inclusion to the history code statement.

  6. Also Dennis, the most important statement these assignment had been updated recently for model update, so in the end you will find the below statement before you download the model, so do follows those instructions carefully for successful submission of your assignment grading.

Wait for the cell above to complete. After that, go to Runtime > Restart Session and wait for the kernel to reconnect. This is necessary so you can reload Tensorflow with the version installed above. Run the next cell to check if you have the correct version. You will get an AssertionError if you didn’t restart the session.

Let me know if your issue is resolved. (P.S. you have post few more doubts on this courses, will respond soon there, keep learning and being an inquisitive learner.

Regards
DP

Thanks, Deepti!
I guess, your comment 2 solved my problem. Both tf.keras.Input and tf.keras.layers.Input are valid classes and have very similar syntax; this is so misleading! :exploding_head:

1 Like

Hello @Dennis_Sinitsky

Yes they look similar but there is a difference

InputLayer is a layer. Input is a tensor .

So you know why one needs to use what tf function call based on instructions.

Keep Learning!!!

Regards
DP