Next, we will update the row selector with the following steps:
- Our next step will be to reset the first_row value to get a different subset of the real_image data during the subsequent iteration. We reset the first_row value using the following code:
first_row <- first_row + 20 if (first_row > (nrow(image_array) - 20)) first_row <- sample(1:10,1)first_row
- After this code is run, the first_row value will either be set to the previous value plus the batch size of 20, or if that number would result in a subset that is out of bounds, then the first_row value is set to a randomly drawn value between 1 and 10. In this case, the value will be set to 21. You will see a printout to your console, as in the following screenshot: ...