Closed idc9 closed 6 years ago
line 86 of IsotropicTVRegulariser's _regulariser_2d function in parameter.py is missing a :
parameter.py
:
It currently reads
(parameter[:, 1:, 1:] - parameter[:, -1, 1:]).pow(2)*self._scaling[0]
when it should read
(parameter[:, 1:, 1:] - parameter[:, :-1, 1:]).pow(2)*self._scaling[0]
The same typo appears in line 94 of _regulariser_3d. Note this is implemented correctly in the displacement regularizer class (e.g. see line 58).
You can check this using the following simple test case and the formula on page 3 from this paper where the answer should be 2 * sqrt(10)
2 * sqrt(10)
X = np.array([[0, 1, 2], [3, 4, 5]]) T = torch.from_numpy(X).unsqueeze(0).float() def current_incorrect(T): dx = (T[:, 1:, 1:] - T[:, -1, 1:]).pow(2) dy = (T[:, 1:, 1:] - T[:, 1:, :-1]).pow(2) return torch.sqrt(dx + dy).sum() def correct_isotropic_TV(T): dx = (T[:, 1:, 1:] - T[:, :-1, 1:]).pow(2) dy = (T[:, 1:, 1:] - T[:, 1:, :-1]).pow(2) return torch.sqrt(dx + dy).sum()
np.allclose(current_incorrect(T).data.numpy(), 2*np.sqrt(10)) False
np.allclose(correct_isotropic_TV(T).data.numpy(), 2*np.sqrt(10)) True
Thank you very much. We fixed it.
line 86 of IsotropicTVRegulariser's _regulariser_2d function in
parameter.py
is missing a:
It currently reads
when it should read
The same typo appears in line 94 of _regulariser_3d. Note this is implemented correctly in the displacement regularizer class (e.g. see line 58).
Test case
You can check this using the following simple test case and the formula on page 3 from this paper where the answer should be
2 * sqrt(10)