I want to train learnable parameter w to re-weight loss.
But w is never changed.
What`s wrong?
w = nn.Parameter(torch.tensor(0.1), requires_grad=True).cuda()
optimizer = optim.SGD(list(network.parameters()), lr=0.1, momentum=0.9, weight_decay=5e-4)
...
loss = loss * w
optimizer.zero_grad()
loss.backward()
optimizer.step()