(B, Y, X, norm=False, device='cuda')
| 128 | return grid_y, grid_x |
| 129 | |
| 130 | def gridcloud2d(B, Y, X, norm=False, device='cuda'): |
| 131 | # we want to sample for each location in the grid |
| 132 | grid_y, grid_x = meshgrid2d(B, Y, X, device=device) |
| 133 | x = torch.reshape(grid_x, [B, -1]) |
| 134 | y = torch.reshape(grid_y, [B, -1]) |
| 135 | # these are B x N |
| 136 | xy = torch.stack([x, y], dim=2) |
| 137 | # this is B x N x 2 |
| 138 | return xy |
| 139 | |
| 140 | def reduce_masked_mean(x, mask, dim=None, keepdim=False, broadcast=False): |
| 141 | # x and mask are the same shape, or at least broadcastably so < actually it's safer if you disallow broadcasting |
no test coverage detected