module emote.utils.math
Functions
def truncated_linear(min_x, max_x, min_y, max_y, x) -> float
Truncated linear function. Implements the following function:
\[ \begin{cases} f1(x) = \frac{min_y + (x - min_x)}{ (max_x - min_x) * (max_y - min_y)} \\ f(x) = min(max_y, max(min_y, f1(x))) \end{cases} \] If max_x - min_x < 1e-10, then it behaves as the constant \(f(x) = max_y\)
Arguments:
min_x(float)
max_x(float)
min_y(float)
max_y(float)
x(float)
def truncated_normal_(tensor, mean, std) -> torch.Tensor
Samples from a truncated normal distribution in-place.
Arguments:
tensor(torch.Tensor)
: the tensor in which sampled values will be stored.mean(float)
: the desired mean (default = 0).std(float)
: the desired standard deviation (default = 1). (default: 1)
Returns:
- the tensor with the stored values. Note that this modifies the input tensor in place, so this is just a pointer to the same object.