Skip to content

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

Description

@Iwillsd

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

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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions