Hyunji

math

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)