How to implement the last batch?

Hi I am stuck with implementing the W2 exercise 2.

I was not sure why the last batch is outside the for loop of the code. Or in other words, why there is no for loop in the if statement, which does some division check for the size of dataset…

Also, with my limited background on math, I do not really understand why we cannot just use m as the index for the last batch.

I am talking about the following part of the instruction.

Blockquote

In the code cell, I see there are two chunks to fill my code in. I think the first one makes sense, I can use the increment to progressively slice the shuffled dataset. Then, I am not sure how to implement the adjustment for the last-batch in the if statement, which is outside the for loop, nor does not have any for loop inside.

Does my question make sense to any of you? I appreciate any suggestion on this!

I managed to solve the issue here! So the for-loop is doing first batch to the second-to-the-last batch. Then, if-statement implements the last batch, so I was right to use the dataset size m. The instruction I copied was not relevant to my specific question!

1 Like