jactorch.functional.loglinear
Linear algebra functions in the log space.
Functions
Functions
-
batch_logmatmulexp(mat1, mat2, use_mm=False)[source]
Computes torch.bmm(mat1.exp(), mat2.exp()).log()
in a numerically stable way.
- Parameters:
mat1 (Tensor) – the first tensor of shape [B, N, M].
mat2 (Tensor) – the second tensor of shape [B, M, K].
use_mm (bool) – whether to use torch.bmm internally.
- Returns:
the output of shape [B, N, K].
- Return type:
Tensor
-
log1mexp(x)[source]
Computes log(1 - exp(x))
in a numerically stable way.
- Parameters:
x (Tensor)
- Return type:
Tensor
-
logaddexp(x, y)[source]
Computes log(exp(x) + exp(y))
in a numerically stable way.
- Parameters:
-
- Return type:
Tensor
-
logits_and(x, y)[source]
Computes logit(sigmoid(x) * sigmoid(y))
in a numerically stable way.
- Parameters:
-
- Return type:
Tensor
-
logits_or(x, y)[source]
Computes logit(sigmoid(x) + sigmoid(y) - sigmoid(x) * sigmoid(y))
in a numerically stable way.
- Parameters:
-
- Return type:
Tensor
-
logmatmulexp(mat1, mat2, use_mm=False)[source]
Computes torch.matmul(mat1.exp(), mat2.exp()).log()
in a numerically stable way.
- Parameters:
-
- Return type:
Tensor
-
logsumexp(tensor, dim=None, keepdim=False)[source]
Computes tensor.exp().sum(dim, keepdim).log()
in a numerically stable way.
- Parameters:
-
- Return type:
Tensor