← LinkedIn Interview Insights

LinkedIn·Machine Learning Engineer·Technical Phone Screen·Senior

Senior
Apr 2026

Summary

LinkedIn ML engineer screen that was basically one big pseudocode question about gradient descent variants. Pretty focused, no fluff, just write the algorithm and be ready to talk tradeoffs.

Questions Asked (1)

Q1

Write pseudocode for mini-batch gradient descent covering: sampling the training set into mini-batches of size B, the forward pass and loss computation, backprop and gradient calculation, the parameter update with learning rate η, and looping over epochs with a convergence check. Also contrast it with full-batch gradient descent and SGD.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This is more involved than it looks on the surface.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

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.

1. Outline the algorithm structure

Briefly describe the overall flow: loop over epochs, shuffle data, iterate over mini-batches, compute gradients, update parameters, and check convergence.

2. Write pseudocode for mini-batch gradient descent

Provide clear pseudocode covering initialization, epoch loop, mini-batch sampling, forward pass, loss computation, backpropagation, parameter update, and convergence check.

3. Explain key components

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.

4. Contrast with full-batch and SGD

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.

5. Discuss practical considerations

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.

Key Points to Mention

  • Mini-batch size B is a hyperparameter; common values are 32, 64, 128, etc.
  • Shuffling the training set before each epoch ensures random sampling.
  • Forward pass computes predictions and loss; backprop computes gradients via chain rule.
  • Parameter update: θ = θ - η * ∇θ L(θ; mini-batch).
  • Convergence check can be based on loss plateau, gradient norm, or validation performance.
  • Full-batch gradient descent uses entire dataset per update, leading to stable but slow convergence; SGD uses one sample, leading to noisy updates but faster iterations.
  • Mini-batch balances the two: efficient use of vectorized operations and stable convergence.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.