DEEP LEARNING OPTIMIZATION AND
REGULARIZATION EXAM SCRIPT WITH
VERIFIED QUESTIONS AND ANSWERS
●● 2 Python collection complexity
Answer: List indexing is O(1). Dictionary and set lookup are O(1) on
average. Heap insertion and removal are O(log n).
●● 3 Generators
Answer: A generator yields values lazily. It reduces memory from
storing an entire sequence and is useful for streaming large datasets.
●● 4 NumPy shapes axes and dtypes
Answer: An axis identifies the dimension reduced or transformed. Track
every tensor shape explicitly and choose dtypes carefully because
integer overflow and low precision can cause bugs.
●● 5 Broadcasting
Answer: Align shapes from the right. Each aligned dimension must
match or one must equal 1. Missing leading dimensions behave like size
1.
●● 6 NumPy views and copies
,Answer: Basic slicing and transpose usually create views. Advanced
indexing and Boolean indexing create copies. Mutating a writable view
can change the original array.
●● 7 Reshape and transpose
Answer: Reshape changes dimension grouping while transpose changes
axis order. Squeeze removes size 1 axes and expand_dims inserts a size
1 axis.
●● 8 Matrix multiplication and einsum
Answer: Elementwise multiplication requires broadcast-compatible
shapes. Matrix multiplication contracts an inner dimension. Einsum
expresses named axis contractions and can replace complex transpose
and sum code.
●● 9 Stable vectorized tensor operations
Answer: Prefer vectorized batched operations. Subtract maxima before
exponentiation. Protect zero denominators. Mask invalid values before
top k or softmax and use take_along_axis for batched gathers.
●● 10 Why convolution works for images
Answer: Convolution uses locality and parameter sharing. It learns
spatial patterns with far fewer parameters than a fully connected layer
and is translation equivariant away from boundary effects.
, ●● 11 Convolution tensor shapes
Answer: For NCHW input X has shape B Cin Hin Win. Weights have
shape Cout Cin divided by groups Kh Kw. Output has shape B Cout
Hout Wout.
●● 12 Convolution output formula
Answer: For each spatial axis use floor of open parenthesis input plus 2P
minus D times open parenthesis K minus 1 close parenthesis minus 1
close parenthesis divided by S plus 1.
●● 13 Stride padding and dilation
Answer: Stride skips output positions and downsamples. Padding
controls boundary coverage and output size. Dilation spaces kernel
elements apart and enlarges the effective receptive field.
●● 14 Grouped convolution
Answer: With G groups each output channel connects to Cin divided by
G input channels. Cin and Cout must both be divisible by G.
●● 15 Depthwise separable convolution
Answer: Depthwise convolution applies a spatial filter per input channel.
A following 1 by 1 pointwise convolution mixes channels and greatly
reduces parameters and MACs.
REGULARIZATION EXAM SCRIPT WITH
VERIFIED QUESTIONS AND ANSWERS
●● 2 Python collection complexity
Answer: List indexing is O(1). Dictionary and set lookup are O(1) on
average. Heap insertion and removal are O(log n).
●● 3 Generators
Answer: A generator yields values lazily. It reduces memory from
storing an entire sequence and is useful for streaming large datasets.
●● 4 NumPy shapes axes and dtypes
Answer: An axis identifies the dimension reduced or transformed. Track
every tensor shape explicitly and choose dtypes carefully because
integer overflow and low precision can cause bugs.
●● 5 Broadcasting
Answer: Align shapes from the right. Each aligned dimension must
match or one must equal 1. Missing leading dimensions behave like size
1.
●● 6 NumPy views and copies
,Answer: Basic slicing and transpose usually create views. Advanced
indexing and Boolean indexing create copies. Mutating a writable view
can change the original array.
●● 7 Reshape and transpose
Answer: Reshape changes dimension grouping while transpose changes
axis order. Squeeze removes size 1 axes and expand_dims inserts a size
1 axis.
●● 8 Matrix multiplication and einsum
Answer: Elementwise multiplication requires broadcast-compatible
shapes. Matrix multiplication contracts an inner dimension. Einsum
expresses named axis contractions and can replace complex transpose
and sum code.
●● 9 Stable vectorized tensor operations
Answer: Prefer vectorized batched operations. Subtract maxima before
exponentiation. Protect zero denominators. Mask invalid values before
top k or softmax and use take_along_axis for batched gathers.
●● 10 Why convolution works for images
Answer: Convolution uses locality and parameter sharing. It learns
spatial patterns with far fewer parameters than a fully connected layer
and is translation equivariant away from boundary effects.
, ●● 11 Convolution tensor shapes
Answer: For NCHW input X has shape B Cin Hin Win. Weights have
shape Cout Cin divided by groups Kh Kw. Output has shape B Cout
Hout Wout.
●● 12 Convolution output formula
Answer: For each spatial axis use floor of open parenthesis input plus 2P
minus D times open parenthesis K minus 1 close parenthesis minus 1
close parenthesis divided by S plus 1.
●● 13 Stride padding and dilation
Answer: Stride skips output positions and downsamples. Padding
controls boundary coverage and output size. Dilation spaces kernel
elements apart and enlarges the effective receptive field.
●● 14 Grouped convolution
Answer: With G groups each output channel connects to Cin divided by
G input channels. Cin and Cout must both be divisible by G.
●● 15 Depthwise separable convolution
Answer: Depthwise convolution applies a spatial filter per input channel.
A following 1 by 1 pointwise convolution mixes channels and greatly
reduces parameters and MACs.