Open
Description
During the process of adding back - propagation gradients, I found that the output of the model in the BaseCAM function, self.outputs, has a size of (25200, 85). When continuing with the gradient calculation, how should I select the output tensors to calculate the loss and complete the back - propagation?
if self.uses_gradients:
self.model.zero_grad()
# for param in self.model.parameters(): # 设置requires_grad=True
# if not param.requires_grad:
# param.requires_grad = True
for name, param in self.model.named_parameters():
print(f"Parameter name: {name}, requires_grad: {param.requires_grad}")
loss = sum([target(output) for target, output in zip(targets, outputs)])
loss.backward(retain_graph=True)
if 'hpu' in str(self.device):
self.__htcore.mark_step()
outputs, has a size of (25200, 85).
Metadata
Metadata
Assignees
Labels
No labels