Simple tutorial of pytorch avoid use of inner function

I look for full simple tutorial/example of pytorch avoid use of inner function except autograd such as…

Linear.

I have shown tutorials which are most works are automated as below.

class Net(nn.Module):
    def __init__(self):
        super.__init__()
        fc1 = linear(10,20)
   
    def forward(x):
        return fc1(x)

net =Net()

...
loss.backward()
opim.step()

I want to learn manual code(hard code) as below.

class Net(nn.Module):
    def __init__(self):
        super.__init__()
        w1 = torch.rand(10)
        b1 = torch.zeros(10)
   
    def forward(x):
        return torch.mm(x, w1) + b1

net =Net()
...
loss.backward()
opim.step()

etc…

Hi,

Sorry I’m not sure to understand your question.
Could you rephrase it please?

sorry for that
additionally described

So first, you never want to use .data.

If you want to do your weight update manually, you can do:

loss.backward()
with torch.no_grad():
  w1 -=  learning_rate * w1.grad