Example scenario You want to classify a photo as a cat, dog, or bird. How should targets and predictions be represented so the model can distinguish these three categories?
Description
Assign a Class ID to each category and configure the model to output a score for each category.
Class IDs are identifiers. Their magnitude does not imply category order or distance.
02 Prediction confidence
Does choosing one category mean that the model distinguishes it confidently? When would you want to withhold a decision?
Description
The position of the largest score specifies the predicted Class
Score differences and a separate confidence assessment are needed. A Logit itself is not a probability
Practice
1. Check CSV inputs
Run the data-loading cell. Print the shape, dtype, and first five rows of x_raw and x separately. Label the outputs before and after preprocessing.
In the same cell, print the shape, dtype, and first five values of labels and y. Find where Labels are converted to the form required by Loss.
Explain why you must reuse the training data's mean and scale to predict new samples, relating this to the scale of each Feature fed to the model.
2. Run baseline training
Call train_classifier with Learning Rates , each for 1000 epochs. Keep the Seed and model initialization inside the function.
Tabulate the final Loss and Training Accuracy returned by each call for each Learning Rate. Compare the two returned histories at the same epoch when examining changes in Loss and Accuracy.
If Loss decreases while Accuracy remains unchanged, select and mark one such interval. Explain it using the difference between the Probability of the correct Class and the final Class decision. If no such interval exists, state that.
3. Interpret the output
Find the prediction-results code cell in the practice notebook that contains logits=model(x). Keep the model trained in the preceding activity.
Record sample indices 0–9 as 10 rows, with four columns: logits, probabilities, predicted label, and target label. Read the values from logits[:10], probability[:10], prediction[:10], and labels[:10], respectively.
In a separate cell, print the return value of the torch.allclose call inside the provided assert statement; record the probability-sum check across all samples as true or false. Then compare logits.argmax(1) with probability.argmax(1) element by element and record whether they agree.
Select up to 3 misclassified samples and record each sample index, target label, and predicted label. If there are none, record ‘none’.
Submission and saving
Include code, actual outputs and plots, and your own interpretation. Submit through KLAS; check the semester schedule and latest announcements for the deadline.
Filename: Name_StudentID_Week8.ipynb.
Restart the runtime, run all code from the top, then save.
Optional practice
When Class indices are passed as a Float Tensor
After training the model, add a Code Cell at the bottom of the notebook and run the following code.