C2W2: Random_mini_batches

Hello people! Hope you are fine.

I’m reading the topics regarding random_mini_batches and it seems to help but I still getting trouble to construct the last mini batch. I answred the topic already created but I decided to post a new one here because the discussion is a bit old.

I believe the the complete minibatch are correct. But the message I receive is in attach below.

Is missing this part of the code to finish the Week 2.
Thanks in advance.


Is this the Machine Learning Specialization?
Course 2 Week 2: Neural Networks for Multiclass classification lab?

Hello @SamReiswig . Thank you for the reply.
In fact is Neural Network specialization. Sorry for the mistake.
Course 2: Improving Deep Neural Networks: Hyperparameter Tuning, Regularization and Optimization

I already corrected the topic.
Thanks again

Hi, Vivian.

I agree with your analysis of the failure: it looks like your first minibatch is correct, but the last one is not. Of course this test case is specifically set up to test your logic in the case that the last minibatch is “partial”. Have you checked the “start index” value for each minibatch? In this test case, the m value is 148 and the batch size is 64, so we should end up with 3 minibatches:

Start index 0, length 64.
Start index 64, length 64.
Start index 128, length 20.

So a good first debugging step is to add print statements to your logic to show all those values. Do they agree with what I showed? If not, then you’ve got a pretty good clue as to where to look :nerd_face: … If they agree, then the problem must be more subtle. But debugging is always “one step at a time”, right?


1 Like