Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Challenge: Implementing Linear Regression | More Advanced Concepts
PyTorch Essentials
course content

Kurssisisältö

PyTorch Essentials

PyTorch Essentials

1. PyTorch Introduction
2. More Advanced Concepts
3. Neural Networks in PyTorch

book
Challenge: Implementing Linear Regression

Tehtävä

Swipe to start coding

You are provided with a dataset that contains information about the number of hours students studied and their corresponding test scores. Your task is to train a linear regression model on this data.

  1. Convert these columns into PyTorch tensors, and reshape them to ensure they are 2D with shapes [N, 1].
  2. Define a simple linear regression model.
  3. Use MSE as the loss function.
  4. Define optimizer as SGD with the learning rate equal to 0.01.
  5. Train the linear regression model to predict test scores based on the number of hours studied. At each epoch:
    • Compute predictions on X_tensor;
    • Compute the loss;
    • Reset the gradient;
    • Perform backward pass;
    • Update the parameters.
  6. Access the model's parameters (weights and bias).

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 2. Luku 4
toggle bottom row

book
Challenge: Implementing Linear Regression

Tehtävä

Swipe to start coding

You are provided with a dataset that contains information about the number of hours students studied and their corresponding test scores. Your task is to train a linear regression model on this data.

  1. Convert these columns into PyTorch tensors, and reshape them to ensure they are 2D with shapes [N, 1].
  2. Define a simple linear regression model.
  3. Use MSE as the loss function.
  4. Define optimizer as SGD with the learning rate equal to 0.01.
  5. Train the linear regression model to predict test scores based on the number of hours studied. At each epoch:
    • Compute predictions on X_tensor;
    • Compute the loss;
    • Reset the gradient;
    • Perform backward pass;
    • Update the parameters.
  6. Access the model's parameters (weights and bias).

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 2. Luku 4
Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Pahoittelemme, että jotain meni pieleen. Mitä tapahtui?
some-alt