💡 [REQUEST] - Clarification of requires_grad about beginner/nn_tutorial.html
Los mantenedores suelen responder en 2 días
Nadie ha tomado este issue todavía.
- #3717 de @FlightVin — cerrado sin fusionar
Evaluación
- Dificultad
- 1/5
- Tiempo estimado
- Menos de una hora
- Aptitud para principiantes
- 55/100
- Tipo de issue
- Documentación
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Área
- documentation
Línea de trabajo
Abre el código fuente de beginner/nn_tutorial.html y localiza la sección “Neural Net from Scratch without torch.nn”. Actualiza el comentario existente sobre los pesos y el bias para explicar por qué requires_grad se difiere para los pesos después de los cálculos de inicialización; se considera terminado cuando la distinción entre tensores leaf y non-leaf quede clara en el tutorial renderizado.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
🚀 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
- Lenguaje dominante
- Python
- Estrellas
- 9.5k
- Forks
- 4.5k
- Merge medio
- 1 d 20 h
- PR fusionados (30 d)
- 2
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de pytorch/tutorials
-
module: vulkan
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 2 días
-
Feedback about Datasets & DataLoadersPosiblemente ocupada @hippi345 la tomó hace 47 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 2 días
-
💡 [REQUEST] - Add model.eval() after loading the mdoelPosiblemente ocupada @Justee21 la tomó hace 71 días. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
Los mantenedores suelen responder en 2 días
-
[BUG] Captum tutorial fails when visualize_image_attr() receives None for original_imagePosiblemente ocupada @manjirisharma la tomó hace 41 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
pytorch/tutorials#3963 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
[BUG] - Incorrect ResNet18 preprocessing in Captum tutorialPosiblemente ocupada @austxu la tomó hace 130 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 2 días
Todos los issues de pytorch/tutorials
Issues similares
-
needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
MakazhanAlpamys/Soup#3589 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
ClickHouse/clickhouse-connect#1266 ·
Los mantenedores suelen responder en 1 día
-
AutoGrowth: new time column nameAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
biosustain/growthcurves_app#89 ·
Los mantenedores suelen responder en 1 día
-
`LogProxyConsumer._on_relation_departed` raises `APIError` when the promtail service does not existAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
canonical/loki-k8s-operator#695 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día