1
$\begingroup$

Suppose after being randomized samples in a dataset can be written $\{x_i\}_{i = 0}^n$ and are put into a batch for mini-batch gradient descent. Are the samples drawn randomly into a batch, or are the batches like a sliding window of size batch size, such that if the batch size is 32, then for the first batch samples $\{x_i\}_{i = 0}^{31}$ are used, we take a step towards the loss function's global minimum, then for the second samples $\{x_i\}_{i = 32}^{64}$ samples are used, another step, and so on. For the last batch, samples $\{x_i\}_{i = n-32}^{n}$ are used. Once $n$ samples are used, the dataset has ran through a full epoch, the samples are randomized again, and the process is repeated.

Is this the correct way of thinking about how the mini-batch GD process works, or is it gone about a different way, like randomly sampling 32 samples each time?

What happens differently when replacement is allowed?

$\endgroup$

1 Answer 1

1
$\begingroup$

Yes, one way to think about it is what you described. Another way is: the samples are randomly sorted, then the first 32 are taken, next 32 and so on. Once the epoch is complete, they are randomly sorted and the first 32 are selected, and basically the process repeats.

In some variations replacement is allowed, but most of the time it is not, as far as I know.

$\endgroup$
3
  • $\begingroup$ How is what you described different from what I detailed? That sound exactly like what I just described. What happens when replacement is allowed? $\endgroup$
    – sangstar
    Commented Mar 21, 2022 at 14:33
  • $\begingroup$ Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center. $\endgroup$
    – Community Bot
    Commented Mar 21, 2022 at 15:52
  • $\begingroup$ It isn't different, it is what you described. When replacement is allowed, then the first batch might be $\{x_i\}_{i=0}^{31}$ and the second batch could contain elements from the first batch, for example, $\{x_i\}_{i=27}^{58}$. $\endgroup$
    – Schach21
    Commented Mar 21, 2022 at 16:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.