Model Pipeline - Batching and shuffling
This pipeline shows how data is prepared by grouping it into batches and mixing the order randomly before training a model. This helps the model learn better by seeing varied examples in each step.
Jump into concepts and practice - no test required
This pipeline shows how data is prepared by grouping it into batches and mixing the order randomly before training a model. This helps the model learn better by seeing varied examples in each step.
Loss
1.0 |*
0.8 | **
0.6 | ***
0.4 | ****
0.2 | ***
0.0 +---------
1 2 3 4 5
Epochs| Epoch | Loss ↓ | Accuracy ↑ | Observation |
|---|---|---|---|
| 1 | 0.85 | 0.60 | Loss starts high; accuracy is low as model begins learning |
| 2 | 0.65 | 0.72 | Loss decreases; accuracy improves as model sees shuffled batches |
| 3 | 0.50 | 0.80 | Model learns better with varied batches; loss drops further |
| 4 | 0.40 | 0.85 | Continued improvement; shuffling helps avoid overfitting |
| 5 | 0.35 | 0.88 | Loss stabilizes; accuracy nears good performance |
ds with batch size 32?batched_ds = ds.batch(20)
for batch in batched_ds:
print(batch.shape)ds = tf.data.Dataset.range(10) ds = ds.batch(2).shuffle(5)
ds.shuffle(50).batch(20)