(spatial_size, ref, **kwargs)
| 39 | |
| 40 | |
| 41 | def make_coordinate_grid(spatial_size, ref, **kwargs): |
| 42 | d, h, w = spatial_size |
| 43 | x = torch.arange(w).type(ref.dtype).to(ref.device) |
| 44 | y = torch.arange(h).type(ref.dtype).to(ref.device) |
| 45 | z = torch.arange(d).type(ref.dtype).to(ref.device) |
| 46 | |
| 47 | # NOTE: must be right-down-in |
| 48 | x = (2 * (x / (w - 1)) - 1) # the x axis faces to the right |
| 49 | y = (2 * (y / (h - 1)) - 1) # the y axis faces to the bottom |
| 50 | z = (2 * (z / (d - 1)) - 1) # the z axis faces to the inner |
| 51 | |
| 52 | yy = y.view(1, -1, 1).repeat(d, 1, w) |
| 53 | xx = x.view(1, 1, -1).repeat(d, h, 1) |
| 54 | zz = z.view(-1, 1, 1).repeat(1, h, w) |
| 55 | |
| 56 | meshed = torch.cat([xx.unsqueeze_(3), yy.unsqueeze_(3), zz.unsqueeze_(3)], 3) |
| 57 | |
| 58 | return meshed |
| 59 | |
| 60 | |
| 61 | class ConvT2d(nn.Module): |
no test coverage detected