This works but the weights and bias values are random. How can I assign values to them without training over samples?
# nn.Linear
x = Variable(torch.Tensor([[1], [4]]), requires_grad=True)
# creates a wx + b layer 
f = nn.Linear(1,1)
print(f.weight, f.bias)

y = f(x)
print(y)

I have tried the following to assign values to ‘weight’ and ‘bias’
f.weight = 2.0
f.bias = 1.0


f.weight = torch.Tensor([2])
f.bias = torch.Tensor([1])


f.weight = nn.Parameter(torch.Tensor([2]))
f.bias = nn.Parameter(torch.Tensor([1]))

None seems to work.