(fea1, fea2, num_groups)
| 103 | return x |
| 104 | |
| 105 | def groupwise_difference(fea1, fea2, num_groups): |
| 106 | B, C, H, W = fea1.shape |
| 107 | assert C % num_groups == 0 |
| 108 | channels_per_group = C // num_groups |
| 109 | fea1 = fea1.view([B, num_groups, channels_per_group, H, W]) |
| 110 | fea2 = fea2.view([B, num_groups, channels_per_group, H, W]) |
| 111 | cost = torch.pow((fea1 - fea2), 2).sum(2) |
| 112 | assert cost.shape == (B, num_groups, H, W) |
| 113 | return cost |
| 114 | |
| 115 | |
| 116 | def build_substract_volume(refimg_fea, targetimg_fea, maxdisp, num_groups): |
no outgoing calls
no test coverage detected