💡 [REQUEST] - Clarification of requires_grad about beginner/nn_tutorial.html
Mantenedores costumam responder em até 2 dias
Ninguém assumiu esta issue ainda.
- #3717 de @FlightVin — fechado sem integrar
Avaliação
- Dificuldade
- 1/5
- Tempo estimado
- Menos de uma hora
- Facilidade para iniciantes
- 55/100
- Tipo de issue
- Documentação
- Clareza
- Claramente especificada
- Status de atividade
- Estagnada
- Domínio
- documentation
Direção de pesquisa
Abra o código-fonte de beginner/nn_tutorial.html e localize a seção “Neural Net from Scratch without torch.nn”. Atualize o comentário existente sobre os pesos e o bias para explicar por que requires_grad é adiado para os pesos após os cálculos de inicialização; considera-se concluído quando a distinção entre tensores leaf e non-leaf estiver clara no tutorial renderizado.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
🚀 Describe the improvement or the new tutorial
It was challenging for me to initially grasp why requires_grad was done after weights, but in the same line as bias under https://docs.pytorch.org/tutorials/beginner/nn_tutorial.html#neural-net-from-scratch-without-torch-nn
At first glance, the code looks inconsistent:
weightsinitialization is split into two lines.biasinitialization is done in one line.
The Logic Gap
The tutorial currently explains that we do it, but not exactly why the distinction exists between these two specific variables.
- The Bias is created using a factory function (
torch.zeros) with no subsequent mathematical operations. It is born as a "Leaf Node" (a source parameter). - The Weights involve a mathematical operation (
/ math.sqrt(...)). If we setrequires_grad=Trueinsidetorch.randn(), PyTorch records the division as a computational step. The resultingweightsvariable becomes a non-leaf node (a calculated outcome), which the optimizer cannot update.
Proposed Improvement
I propose modifying the comment block to explicitly mention that requires_grad must be deferred until after the initialization math is complete to preserve the tensor as a trainable parameter (Leaf Node).
Existing tutorials on this topic
- https://docs.pytorch.org/tutorials/beginner/nn_tutorial.html
- https://docs.pytorch.org/tutorials/beginner/nn_tutorial.html#neural-net-from-scratch-without-torch-nn
Additional context
- Linguagem predominante
- Python
- Estrelas
- 9.5k
- Forks
- 4.5k
- Merge médio
- 1d 20h
- PRs com merge (30d)
- 2
Preparar o ambiente
Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de pytorch/tutorials
-
module: vulkan
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 2 dias
-
Feedback about Datasets & DataLoadersTalvez já em andamento @hippi345 assumiu há 47 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
Mantenedores costumam responder em até 2 dias
-
💡 [REQUEST] - Add model.eval() after loading the mdoelTalvez já em andamento @Justee21 assumiu há 71 dias. Aberta
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 2 dias
-
[BUG] Captum tutorial fails when visualize_image_attr() receives None for original_imageTalvez já em andamento @manjirisharma assumiu há 41 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
pytorch/tutorials#3963 · 1 comentário ·
Mantenedores costumam responder em até 2 dias
-
[BUG] - Incorrect ResNet18 preprocessing in Captum tutorialTalvez já em andamento @austxu assumiu há 130 dias. Abertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
Mantenedores costumam responder em até 2 dias
Todas as issues de pytorch/tutorials
Issues semelhantes
-
[19.0] pos_sale: settling an order with a 0 down payment line crashes (reading 'reward_id') and leaves a wrong amount dueTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 79/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 79/100
developmentseed/titiler-covjson#164 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
awslabs/visual-asset-management-system#2164 ·
Mantenedores costumam responder em até 1 dia
-
needs-triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 86/100
MakazhanAlpamys/Soup#3589 ·
Mantenedores costumam responder em até 1 dia
-
channels status reports the wrong Enabled value for Feishu instances and default-enabled WebSocketAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 86/100
Mantenedores costumam responder em até 1 dia