Compare CNN/RNN/LSTM and implement K-means
Company: Microsoft
Role: Data Scientist
Category: Machine Learning
Difficulty: hard
Interview Round: Onsite
Part A (concepts): Contrast CNNs and RNNs for (i) 224×224 RGB images and (ii) variable-length text. Explain inductive biases (translation equivariance, locality, temporal order), parameter sharing, receptive-field growth, and ability to model long-range dependencies; when can a 1D CNN replace an RNN/Transformer? For LSTMs, write the gate equations, show how the cell state mitigates vanishing gradients, and compute output shapes for input (batch=32, seq_len=100, feat=64) with hidden size 128 for unidirectional vs bidirectional cases. Part B (coding): Implement K-means from scratch with k-means++ initialization, vectorized assignment/update steps, and convergence on objective decrease. Discuss O(n·k·d) time and memory trade-offs, handling empty clusters, feature scaling and outliers, choosing k (silhouette/elbow/BIC), and prove the objective is non-increasing per iteration. Propose a mini-batch variant and when you’d use it.
Quick Answer: This question evaluates understanding of deep learning architectures (CNN, RNN, LSTM) and unsupervised clustering implementation (K-means), covering inductive biases, parameter sharing and receptive fields, LSTM gating and vanishing-gradient behavior, tensor shape reasoning, algorithmic complexity, initialization, and cluster handling.