pytorch / pytorch/tutorials

adding layer size calc to Neural Networkstutorial

Open
#498 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

It would have saved me a lot of wasted hours when moving from the tutorial to our own scenarios to explain the layer size calculation implicit in https://pytorch.org/tutorials/beginner/blitz/neural_networks_tutorial.html .

This was explained clearly in https://stackoverflow.com/questions/53784998/how-are-the-pytorch-dimensions-for-linear-layers-calculated

Could perhaps be a short addition to the "Note" section at the bottom?

(If that seems like a good solution / no one else gets to it, I should be able to get to this in mid-June)


Additionally: I don't think it belong in this tutorial tutorial, but there is a debugging tip that this common error message number is actually dependent on your batch size(!):
"RuntimeError: shape '[-1, 62500]' is invalid for input of size 11289600"
If you put in .view(-1, 11289600) the code will "run" further and then choke on the loss calculation; however, actually the original batch size issue has not been solved (as it should be set to 11289600 / batchsize), so attempting to address the loss error message does no good.

I'm not sure where this should go, but it's definitely pertinent for moving from the tutorial to real life (which the tutorials should give you the skills to do hopefully)

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

Start with the Neural Networks tutorial linked in the issue and review its Note section alongside the referenced Stack Overflow explanation. Clarify the layer-size calculation in the tutorial, then decide whether the batch-size debugging advice belongs there or should be documented elsewhere. Done means the tutorial explains the calculation accurately and the documentation scope is resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.