Do you have a loss function? Normally, one should do:
net = Net()
pred = net(X)
loss = loss_fn(pred, y)
loss.backward()
optim.step()

If you did not calculate the error, pytorch does not know how to update the parameters…