Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: module 'torch.nn' has no attribute 'linear' #234

Open
Iwillsd opened this issue Aug 22, 2021 · 2 comments
Open

AttributeError: module 'torch.nn' has no attribute 'linear' #234

Iwillsd opened this issue Aug 22, 2021 · 2 comments

Comments

@Iwillsd
Copy link

Iwillsd commented Aug 22, 2021

#=============================================#

2.Basic autogard example2

#=============================================#

Create tensors of shape (10,3) and (10,2)

x = torch.randn(10, 3)
y = torch.randn(10, 2)

Build a fully connected layer

linear = nn.linear(3, 2)
print('w:', linear.weight)
print('b:', linear.bias)

Build loss function and optimizer

loss = nn.MSELoss()
optimizer = torch.optim.SGD(linear.parameters(), lr=0.01)

Please help answer this question, thank you very much!

@Yozh2
Copy link

Yozh2 commented Apr 5, 2022

It's nn.Linear, with a capital L.

linear = nn.Linear(3, 2)

@NourSoltani
Copy link

NourSoltani commented Nov 23, 2022

it's with capital L in Linear isn't it?
If it's the case, I think this issue should be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants