Week 2 Exercise 2 - Random Mini Batches (wrong values)


I keep getting an error with wrong values and I am struggling to find the cause. I’ve looked over the indexes I am using and I’m not sure what’s missing. Any pointers would be helpful and I can send a code snippet privately if needed.

Also, I am a little confused on the syntax “mini_batches[-1][0][-1][0:3]” and what the negatives mean exactly.

The -1 means the last axis for that dimension!

You may send the code for random_mini_batches function in private, I can have a loot at it!

My guess is that it is the last partial minibatch that is wrong. That is the first place to look to make sure that you calculated the starting index for that correctly. Add print statements to your code to show the start index and length for each minibatch.

1 Like