| 124 | |
| 125 | |
| 126 | def get_projected_grid(in_sz, out_sz, scale_factor, fw, by_convs, device=None): |
| 127 | # we start by having the ouput coordinates which are just integer locations |
| 128 | # in the special case when usin by_convs, we only need two cycles of grid |
| 129 | # points. the first and last. |
| 130 | grid_sz = out_sz if not by_convs else scale_factor.numerator |
| 131 | out_coordinates = fw_arange(grid_sz, fw, device) |
| 132 | |
| 133 | # This is projecting the ouput pixel locations in 1d to the input tensor, |
| 134 | # as non-integer locations. |
| 135 | # the following fomrula is derived in the paper |
| 136 | # "From Discrete to Continuous Convolutions" by Shocher et al. |
| 137 | return (out_coordinates / float(scale_factor) + |
| 138 | (in_sz - 1) / 2 - (out_sz - 1) / (2 * float(scale_factor))) |
| 139 | |
| 140 | |
| 141 | def get_field_of_view(projected_grid, cur_support_sz, fw, eps, device): |