Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is batch size in machine learning?
Batch size is the number of training examples the model looks at before updating its internal settings (weights). It controls how many samples are processed together in one go.
Click to reveal answer
beginner
Define epoch in the context of training a model.
An epoch is one full pass through the entire training dataset. After one epoch, the model has seen every training example once.
Click to reveal answer
intermediate
How does increasing batch size affect training speed and memory?
Increasing batch size usually speeds up training because more data is processed at once, but it also uses more memory. Very large batches may reduce the model's ability to learn well.
Click to reveal answer
intermediate
What happens if you increase the number of epochs too much?
If you train for too many epochs, the model might memorize the training data and perform poorly on new data. This is called overfitting.
Click to reveal answer
beginner
In TensorFlow, how do you specify batch size and epochs when training a model?
You specify batch size and epochs in the model's fit() method like this: model.fit(x_train, y_train, batch_size=32, epochs=10). This trains the model with batches of 32 samples for 10 full passes over the data.
Click to reveal answer
What does one epoch represent in training?
AOne batch of data processed
BOne update of model weights
COne pass through the entire training dataset
DOne prediction made by the model
✗ Incorrect
An epoch means the model has seen all training samples once.
If batch size is 64, what does this mean?
AThe model trains on 64 epochs
BThe model updates weights after every 64 samples
CThe model sees 64 batches per epoch
DThe model uses 64 layers
✗ Incorrect
Batch size defines how many samples are processed before updating the model.
What is a risk of training with too many epochs?
AOverfitting the data
BLess memory usage
CFaster training
DUnderfitting the data
✗ Incorrect
Too many epochs can cause the model to memorize training data and not generalize well.
Which of these is true about increasing batch size?
AIt decreases the number of epochs needed
BIt reduces memory usage
CIt always improves model accuracy
DIt can speed up training but uses more memory
✗ Incorrect
Larger batch sizes process more data at once, speeding training but using more memory.
How do you set batch size and epochs in TensorFlow's model.fit()?
What is the most likely reason for the slow training?
medium
A. Using batch_size=1 disables GPU acceleration
B. Epochs set to 10 is too low to train well
C. Batch size should be larger than number of epochs
D. Batch size of 1 causes frequent weight updates, slowing training
Solution
Step 1: Understand effect of batch size 1
Batch size 1 means model updates weights after every single sample, causing overhead.
Step 2: Evaluate other options
Epochs=10 is normal; batch size does not need to be larger than epochs; batch size 1 does not disable GPU.
Final Answer:
Batch size of 1 causes frequent weight updates, slowing training -> Option D
Quick Check:
Small batch size = slower training due to many updates [OK]
Hint: Very small batch size slows training due to many updates [OK]
Common Mistakes:
Thinking epochs number causes slowness
Believing batch size must be bigger than epochs
Assuming batch size disables GPU
5. You have a dataset of 10,000 samples. You want to train a model efficiently and avoid overfitting. Which combination of batch size and epochs is best?
hard
A. Batch size = 1000, epochs = 5
B. Batch size = 10, epochs = 1000
C. Batch size = 1, epochs = 10000
D. Batch size = 500, epochs = 50
Solution
Step 1: Consider batch size impact
Large batch sizes (like 1000) speed training and provide stable updates.
Step 2: Consider epochs and overfitting
Too many epochs (like 1000 or 10000) risk overfitting; fewer epochs with larger batches balance training.
Step 3: Evaluate options
Batch size = 1000, epochs = 5 balances batch size and epochs for efficient training and less overfitting.
Final Answer:
Batch size = 1000, epochs = 5 -> Option A
Quick Check:
Balanced batch size and epochs avoid overfitting [OK]
Hint: Large batch + fewer epochs = efficient, less overfitting [OK]
Common Mistakes:
Choosing very small batch sizes with many epochs
Ignoring overfitting risk with too many epochs
Assuming bigger batch size always means better accuracy