pytorch / pytorch/tutorials

nn_tutorial.py loss and accuracy being measured only on last mini-batch as opposed to entire batch, which may be confusing for learners

Open
#522 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
9.3k
Forks
4.4k
Avg merge
1d 21h
Merged PRs (30d)
4

Description

The tutorial tests loss and accuracy with

print(loss_func(model(xb), yb), accuracy(model(xb), yb))

which is ok but only measures those functions on the last mini-batch used in training, which is somewhat arbitrary and may be counter-intuitive to learners.

I suggest replacing all instances of loss_func and accuracy calls by

loss_func(model(x_train), y_train)
and
accuracy(model(x_train), y_train))

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open nn_tutorial.py and locate all loss_func and accuracy calls. Compare the current mini-batch inputs with the suggested x_train and y_train inputs, then update the tutorial's measurements so they evaluate the full training data. Done means the relevant displayed loss and accuracy values no longer depend only on the last mini-batch.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation, machine-learning
Issue type
Documentation
Difficulty
1/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.