BioMedIA/deepali

Fix calculation of divergence_loss()

Closed this issue · 0 comments

The divergence loss as implemented takes the sum of all first order derivatives.

derivs = spatial_derivatives(u, mode=mode, order=1, sigma=sigma, spacing=spacing)
derivs = torch.cat([deriv.unsqueeze(-1) for deriv in derivs.values()], dim=-1)
loss = derivs.sum(dim=-1)

Instead, only the trace of the Jacobian matrix should be computed.