MCPcopy Create free account
hub / github.com/OpenGVLab/HumanBench / myloss

Function myloss

PATH/core/models/decoders/pose_decodes/pose_decoder.py:73–94  ·  view source on GitHub ↗

Forward function.

(output, target, target_weight)

Source from the content-addressed store, hash-verified

71
72
73def myloss(output, target, target_weight):
74 """Forward function."""
75 use_target_weight = True
76 batch_size = output.size(0)
77 num_joints = output.size(1)
78
79 heatmaps_pred = output.reshape(
80 (batch_size, num_joints, -1)).split(1, 1)
81 heatmaps_gt = target.reshape((batch_size, num_joints, -1)).split(1, 1)
82
83 loss = 0.
84
85 for idx in range(num_joints):
86 heatmap_pred = heatmaps_pred[idx].squeeze(1)
87 heatmap_gt = heatmaps_gt[idx].squeeze(1)
88 if use_target_weight:
89 loss += criterion(heatmap_pred * target_weight[:, idx],
90 heatmap_gt * target_weight[:, idx])
91 else:
92 loss += criterion(heatmap_pred, heatmap_gt)
93
94 return loss / num_joints * 1.0
95
96
97def _get_max_preds(heatmaps):

Callers 1

forwardMethod · 0.85

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected