Skip to content
Discussion options

You must be logged in to vote

Hi,
your code seems to be correct, I run it and the result is reasonable. Since I don't know what is your model_0 and dataset, I just assume you're following the video and using a simple y = W*x+b linear model.

import torch
from torch import nn
import matplotlib.pyplot as plt
torch.__version__

device = "cuda" if torch.cuda.is_available() else "cpu"
print(f"Using device: {device}")

weight = 0.7
bias = 0.3

start = 0
end = 1
step = 0.02
X = torch.arange(start, end, step).unsqueeze(dim=1)
y = weight * X + bias
print(f"\nthe head of X: {X[:10]}")
print(f"\nthe head of y: {y[:10]}")

train_split = int(0.8 * len(X))
X_train, y_train = X[:train_split], y[:train_split]
X_test, y_test = X[train_…

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@Perian-Yan
Comment options

@Perian-Yan
Comment options

@Aditi4AI
Comment options

@Perian-Yan
Comment options

Answer selected by Aditi4AI
@Aditi4AI
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants