Skip to content
Discussion options

You must be logged in to vote

Hi @lobachevscki ,

I read your code and thought this is strange... because your code looks fine.

Then I went through it line by line and found a silent error.

A small typo in your __init__() method.

Your code:

class LinearRegressionModelV2(nn.Module):
    def __int__(self): # "int" not "init"

Corrected code:

class LinearRegressionModelV2(nn.Module):
    def __init__(self):

A small error but it is causing exactly the error you're talking about.

Full example:

import torch
from torch import nn
import matplotlib.pyplot as plt
device = 'cuda' if torch.cuda.is_available() else 'cpu'

weight = 0.7
bias = 0.23

start = 0
end = 1

step = 0.01

X = torch.arange(start, end, step).unsqueeze(dim = 1)
y =

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@lobachevscki
Comment options

@shisirkha
Comment options

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