lr = 0.1
num_epochs = 3
net = linreg
loss = squared_loss
num_inputs = 2
num_examples = 1000
features = torch.randn(size = (num_examples,num_inputs))
w = Variable(tdist.Normal(torch.tensor([0.0]),torch.tensor([0.01])).sample((num_inputs,)),requires_grad=True)
b = Variable(torch.zeros(size = (1,1)),requires_grad=True)
l =torch.empty(10,1, requires_grad=False)
for epoch in range(num_epochs):
i = 0
for X, y in data_iter(batch_size,features,labels):
i += 1
l[:] = loss(net(X,w,b),y)
if i ==1 :
  l.backward(torch.ones(l.size()))
sgd([w],lr,batch_size)

train_loss = loss(net(features,w,b),labels)
print(‘epoch %d, loss %f’ % (epoch + 1, train_loss.mean()))
i want solve problem what should do … please save me
i think Variable w has something wrong