This is more involved than it looks on the surface.
Start by outlining the high-level structure of mini-batch gradient descent, then write clear pseudocode with comments for each component. Finally, contrast it with full-batch and SGD by discussing computational efficiency, convergence behavior, and memory usage.
Pro tip: Mention that mini-batch size B is a hyperparameter that trades off between the stability of full-batch and the speed of SGD, and that in practice, we often use a learning rate schedule or adaptive optimizers like Adam.
Briefly describe the overall flow: loop over epochs, shuffle data, iterate over mini-batches, compute gradients, update parameters, and check convergence.
Provide clear pseudocode covering initialization, epoch loop, mini-batch sampling, forward pass, loss computation, backpropagation, parameter update, and convergence check.
Comment on the purpose of each part: sampling ensures stochasticity, forward/backward passes compute gradients, update uses learning rate η, and convergence check stops training early.
Compare mini-batch with full-batch (uses entire dataset per update, stable but slow) and SGD (uses single sample, noisy but fast), highlighting trade-offs in computation, memory, and convergence.
Mention hyperparameters like batch size and learning rate, and how they affect training; note that mini-batch is standard in deep learning due to GPU efficiency.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.