Hi Sainath!



 sapra24:

does (loss * 1.5).backward() actually work


It works fine.
Here is a quick example that shows both the gradient and the
optimizer step:
>>> import torch
>>> torch.__version__
'1.7.1'
>>> ta = torch.tensor ([1.0], requires_grad = True)
>>> tb = torch.tensor ([1.0], requires_grad = True)
>>> opta = torch.optim.SGD ([ta], lr = 0.1)
>>> optb = torch.optim.SGD ([tb], lr = 0.1)
>>> ta.backward()
>>> ta.grad
tensor([1.])
>>> opta.step()
>>> ta
tensor([0.9000], requires_grad=True)
>>> (1.5 * tb).backward()
>>> tb.grad
tensor([1.5000])
>>> optb.step()
>>> tb
tensor([0.8500], requires_grad=True)

Best.
K. Frank