Compute iint w[i] w[j] |t[i] - t[j]| di dj.
(t, w)
| 295 | |
| 296 | |
| 297 | def lossfun_distortion(t, w): |
| 298 | """Compute iint w[i] w[j] |t[i] - t[j]| di dj.""" |
| 299 | # The loss incurred between all pairs of intervals. |
| 300 | ut = (t[..., 1:] + t[..., :-1]) / 2 |
| 301 | dut = torch.abs(ut[..., :, None] - ut[..., None, :]) |
| 302 | loss_inter = torch.sum(w * torch.sum(w[..., None, :] * dut, dim=-1), dim=-1) |
| 303 | |
| 304 | # The loss incurred within each individual interval with itself. |
| 305 | loss_intra = torch.sum(w ** 2 * (t[..., 1:] - t[..., :-1]), dim=-1) / 3 |
| 306 | |
| 307 | return loss_inter + loss_intra |
| 308 | |
| 309 | |
| 310 | def interval_distortion(t0_lo, t0_hi, t1_lo, t1_hi): |
nothing calls this directly
no outgoing calls
no test coverage detected