Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Feedback about What is torch.nn really?

Aperta
#3,666 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

  • #3667 di @patrocinio — chiusa senza merge

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
45/100
Tipo di issue
Documentazione
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python, pytorch
Ambito
documentation

Direzione di ricerca

Apri la pagina nn_tutorial.html collegata e analizza la sezione “Neural net from scratch (without torch.nn)”, in particolare le valutazioni della loss pre-training e della loss finale. Traccia come cambiano xb e yb nel ciclo di training, quindi aggiorna il tutorial in modo che il confronto utilizzi un batch di valutazione coerente oppure utilizzi esplicitamente il dataset di test. Verifica che l’esempio visualizzato di loss e accuracy rimanga coerente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

core

There is the following issue on this page: https://docs.pytorch.org/tutorials/beginner/nn_tutorial.html

In the section "Neural net from scratch (without torch.nn)" there is a pre-training loss function evaluation on a batch of 64 instances,

yb = y_train[0:bs]
print(loss_func(preds, yb))

then training is performed (comments my own)

for epoch in range(epochs):
    for i in range((n - 1) // bs + 1):
        #         set_trace()
        start_i = i * bs
        end_i = start_i + bs
        xb = x_train[start_i:end_i] # note that xb gets redefined
        yb = y_train[start_i:end_i] # note that yb gets redefined
        pred = model(xb)
        loss = loss_func(pred, yb)

        loss.backward()
        with torch.no_grad():
            weights -= weights.grad * lr
            bias -= bias.grad * lr
            weights.grad.zero_()
            bias.grad.zero_()

and the loss function is evaluated again to demonstrate a reduction in loss.

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

The final evaluation is not applied to the same data as the first though. Both invoke xb and yb, but xb and yb in the pre-training evaluation are the first 64 instances from the set, during training these variables are updated with subsequent batches and the final evaluation is performed on the final batch.

Pre and post-training evaluations should be performed on the same batch, either the original 64 instances from the first training batch, or (if the intent is to demonstrate generalization loss) the test dataset.

cc @albanD @jbschlosser

Lingua principale
Python
Stelle
9.4k
Fork
4.4k
Merge medio
3g 5h
PR unite (30g)
4

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di pytorch/tutorials

Tutte le issue di pytorch/tutorials

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.