Giter Site home page Giter Site logo

Comments (4)

PiotrCzapla avatar PiotrCzapla commented on August 18, 2024

Out of curiosity do you have a minimal example maybe that shows the issue?

from course22p2.

waterboy96 avatar waterboy96 commented on August 18, 2024

Hi @PiotrCzapla

Right before the random sampling section we define fit as:

def fit():
    for epoch in range(epochs):
        for xb,yb in train_dl:
            pred = model(xb)
            loss = loss_func(pred, yb)
            loss.backward()
            opt.step()
            opt.zero_grad()
        report(loss, preds, yb)

We define pred on line 4 in our loop, but we call report on preds in the last line. In most of the other fit functions it assigns the prediction to preds correctly such as the first fit function in the same notebook:

def fit():
    for epoch in range(epochs):
        for i in range(0, n, bs):
            s = slice(i, min(n,i+bs))
            xb,yb = x_train[s],y_train[s]
            preds = model(xb)
            loss = loss_func(preds, yb)
            loss.backward()
            with torch.no_grad():
                for p in model.parameters(): p -= p.grad * lr
                model.zero_grad()
        report(loss, preds, yb)

from course22p2.

PiotrCzapla avatar PiotrCzapla commented on August 18, 2024

I see what you mean, it is in 04_minibatch_training just before jupyter chapter "Random sampling". :) I made a fix #19 with github.dev it is super easy nowadays to make such changes directly in the browser even to notebooks ! :)

Thank you.

from course22p2.

waterboy96 avatar waterboy96 commented on August 18, 2024

I did not know that. Thanks, I will try it next time!

from course22p2.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.