Skip to content

Commit b8120b0

Browse files
committed
Move evaluation on test set to the end.
1 parent 581415f commit b8120b0

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

episodes/05-train_eval.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -200,29 +200,6 @@ Remember to retrain your model after making this change.
200200

201201
:::::::::::::::::::::::::::::::::::::::
202202

203-
## Evaluating your model on the held-out test set
204-
205-
In this step, we present the unseen test dataset to our trained network and evaluate the performance.
206-
207-
```python
208-
from tensorflow.keras.models import load_model
209-
210-
# Open the best model saved during training
211-
best_model = load_model('best_model.keras')
212-
print('\nNeural network weights updated to the best epoch.')
213-
```
214-
215-
Now that we've loaded the best model, we can evaluate the accuracy on our test data.
216-
217-
```python
218-
# We use the evaluate function to evaluate the accuracy of our model in the test group
219-
print(f"Accuracy in test group: {best_model.evaluate(dataset_test, labels_test, verbose=0)[1]}")
220-
```
221-
222-
```output
223-
Accuracy in test group: 0.80
224-
```
225-
226203
## Choosing and modifying the architecture
227204

228205
There is no single “correct” architecture for a neural network. The best design depends on your data, task, and computational constraints. Here is a systematic approach to designing and improving your model architecture:
@@ -263,6 +240,29 @@ To reduce overfitting, consider:
263240
- Data augmentation
264241
- Early stopping
265242

243+
## Evaluating your model on the held-out test set
244+
245+
In this step, we present the unseen test dataset to our trained network and evaluate the performance.
246+
247+
```python
248+
from tensorflow.keras.models import load_model
249+
250+
# Open the best model saved during training
251+
best_model = load_model('best_model.keras')
252+
print('\nNeural network weights updated to the best epoch.')
253+
```
254+
255+
Now that we've loaded the best model, we can evaluate the accuracy on our test data.
256+
257+
```python
258+
# We use the evaluate function to evaluate the accuracy of our model in the test group
259+
print(f"Accuracy in test group: {best_model.evaluate(dataset_test, labels_test, verbose=0)[1]}")
260+
```
261+
262+
```output
263+
Accuracy in test group: 0.80
264+
```
265+
266266
:::::::::::::::::::::::::::::::::::::::: keypoints
267267

268268
- Neural networks are trained by adjusting weights to minimize a loss function using optimization algorithms like Adam.

0 commit comments

Comments
 (0)