Which statement best describes how increasing the batch size affects the training speed of a neural network?
Think about how processing more samples at once affects computation and memory.
Larger batch sizes process more samples in parallel, which can speed up training per epoch but require more memory. Smaller batches use less memory but may be slower overall.
Consider a dataset with 1000 samples. You train a model for 5 epochs with batch size 100. How many weight updates occur during training?
dataset_size = 1000 batch_size = 100 epochs = 5 updates = (dataset_size // batch_size) * epochs print(updates)
Calculate how many batches fit in one epoch, then multiply by epochs.
Each epoch has 1000/100 = 10 batches. Over 5 epochs, total updates = 10 * 5 = 50.
You want to train a deep neural network on a GPU with limited memory. Which batch size choice is best to avoid out-of-memory errors while maintaining reasonable training speed?
Think about balancing memory limits and training efficiency.
The largest batch size that fits in memory maximizes GPU usage and speeds training without causing errors. Too small batches slow training; too large cause memory errors.
You train a model for 10 epochs and observe training accuracy improves but validation accuracy plateaus after 5 epochs. What does this indicate?
Consider what happens when training accuracy improves but validation does not.
When training accuracy improves but validation accuracy stops improving, the model is likely overfitting the training data.
Given the code below, what will be the printed output for the number of batches processed per epoch?
import tensorflow as tf # Dataset with 120 samples x = tf.random.normal([120, 10]) y = tf.random.uniform([120], maxval=2, dtype=tf.int32) batch_size = 25 epochs = 3 dataset = tf.data.Dataset.from_tensor_slices((x, y)).batch(batch_size) for epoch in range(epochs): batch_count = 0 for batch_x, batch_y in dataset: batch_count += 1 print(f"Epoch {epoch+1} batches: {batch_count}")
Calculate how many batches of size 25 fit into 120 samples.
120 samples divided by batch size 25 gives 4 full batches (25*4=100) plus 1 batch with remaining 20 samples, totaling 5 batches per epoch.