pytorch / pytorch/pytorch.github.io
Code example at https://pytorch.org/features/ is incorrect
Open
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 285
- Forks
- 317
- PR merge metrics
- No merged PRs in 30d
Description
📚 Documentation
The first code shown in https://pytorch.org/features is
import torch
class MyModule(torch.nn.Module):
def __init__(self, N, M):
super(MyModule, self).__init__()
self.weight = torch.nn.Parameter(torch.rand(N, M))
def forward(self, input):
if input.sum() > 0:
output = self.weight.mv(input)
else:
output = self.weight + input
return output
# Compile the model code to a static representation
my_script_module = torch.jit.script(MyModule(3, 4))
# Save the compiled code and model data so it can be loaded elsewhere
my_script_module.save("my_script_module.pt")
This is incorrect Python as the last four lines should be outdented and not in the body of MyModule.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open the first code example on https://pytorch.org/features/ and inspect its indentation. Move the final four compilation and save lines outside the MyModule class, then verify the displayed example is valid Python.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100