Challenge: Implementing Linear Regression
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.
- Convert these columns into PyTorch tensors, and reshape them to ensure they are 2D with shapes
[N, 1]
. - Define a simple linear regression model.
- Use MSE as the loss function.
- Define
optimizer
as SGD with the learning rate equal to0.01
. - 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.
- Compute predictions on
- Access the model's parameters (weights and bias).
Ratkaisu
Kiitos palautteestasi!
single
Kysy tekoälyä
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme
Awesome!
Completion rate improved to 5Awesome!
Completion rate improved to 5
Challenge: Implementing Linear Regression
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.
- Convert these columns into PyTorch tensors, and reshape them to ensure they are 2D with shapes
[N, 1]
. - Define a simple linear regression model.
- Use MSE as the loss function.
- Define
optimizer
as SGD with the learning rate equal to0.01
. - 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.
- Compute predictions on
- Access the model's parameters (weights and bias).
Ratkaisu
Kiitos palautteestasi!
single
Awesome!
Completion rate improved to 5
Challenge: Implementing Linear Regression
Pyyhkäise näyttääksesi valikon
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.
- Convert these columns into PyTorch tensors, and reshape them to ensure they are 2D with shapes
[N, 1]
. - Define a simple linear regression model.
- Use MSE as the loss function.
- Define
optimizer
as SGD with the learning rate equal to0.01
. - 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.
- Compute predictions on
- Access the model's parameters (weights and bias).
Ratkaisu
Kiitos palautteestasi!