Pytorch, Torch, Torchvision, Deep Learning, Python.
print("loss value: % f " % (float(loss))) grad = out.grad(pred) print("Grad:", grad) params = params - lr * grad >> loss value: 3.018057 Grad: tensor([-0.4668, 3.0181], grad_fn=<StackBackward0>) loss value: 3.001167 Grad: tensor([-0.4642, 3.0012], grad_fn=<StackBackward0>) loss value: 2.986313