Deep Learning Concepts and K-means Implementation (Onsite ML Interview)
Part A: CNNs vs RNNs and LSTMs
Contrast CNNs and RNNs for the following modalities:
-
(i) 224×224 RGB images
-
(ii) Variable-length text
Explain and compare:
-
Inductive biases: translation equivariance, locality (spatial/temporal), temporal order
-
Parameter sharing
-
Receptive-field growth
-
Ability to model long-range dependencies
-
When a 1D CNN can replace an RNN/Transformer (assumptions and caveats)
For LSTMs:
-
Write the gate equations and define all symbols and shapes
-
Show mathematically how the cell state helps mitigate vanishing gradients
-
Compute output shapes for input (batch=32, seq_len=100, feat=64), hidden size=128 for unidirectional vs bidirectional cases (assume a single layer)
Part B: K-means From Scratch
Implement K-means with the following requirements:
-
k-means++ initialization
-
Vectorized assignment and update steps
-
Convergence based on decrease of the objective (sum of squared distances)
Also discuss:
-
Time complexity O(n·k·d) per iteration and memory trade-offs
-
Handling empty clusters
-
Feature scaling and outliers
-
Choosing k (silhouette, elbow, BIC)
-
Prove the objective is non-increasing per iteration
-
Propose a mini-batch variant and when you would use it