Showing
1 changed file
with
18 additions
and
0 deletions
2DCNN/lib/utils/math.py
0 → 100644
1 | +""" Mathematical formulae for different expressions""" | ||
2 | + | ||
3 | +import torch | ||
4 | + | ||
5 | +from .torch_utils import EPSILON | ||
6 | + | ||
7 | + | ||
8 | +def echo_mi(f, s): | ||
9 | + N = s.shape[0] | ||
10 | + s = s.view(N, -1) | ||
11 | + return -torch.log(torch.abs(s) + EPSILON).sum(dim=1) | ||
12 | + | ||
13 | + | ||
14 | +def get_echo_clip_factor(num_samples): | ||
15 | + max_fx = 1 | ||
16 | + d_max = num_samples | ||
17 | + | ||
18 | + return (2 ** (-23) / max_fx) ** (1.0 / d_max) |
-
Please register or login to post a comment