mokka.functional
Functions which do not fit anywhere else.
Functions that do not fit anywhere else - in PyTorch.
- mokka.functional.torch.Jones2Mueller(J)
Takes a 2x2 complex Jones matrix and returns a 4x4 real Mueller matrix
- mokka.functional.torch.convolve(signal, kernel, mode='full')
Calculate the 1-D convolution using the torch.conv1d function.
This function is a convenience to assist using the torch convolution function within a signal processing context. The convolution function provided by PyTorch has image processing in mind and therefore some parameters of this function can be simplfied.
- Parameters:
signal – signal in the time domain.
kernel – second signal in the time domain, must be shorter.
mode – either “full”, “same” or “valid”.
- Returns:
convolution between signal and kernel.
- mokka.functional.torch.convolve_overlap_save(signal, kernel, mode='full')
Calculate the 1-D convolution using FFT overlap-save method.
This is only efficient for very long signals, where signal length >> 10*kernel length
- mokka.functional.torch.distribution_quant_gumbel_softmax(probs, n, temp=0.1)
Compute a quantized distribution for given probabilities with Gumbel-Softmax.
This uses the Gumbel-Softmax sampling method to provide a differentiable way to embed the information about the distribution into the sequence. We use the straight-through trick to retain the gradients of softmax but actually use the values from a argmax for calculation.
- Parameters:
probs – probabilities of occurence for each element
n – length of the sequence to sample
temp – temperature of Softmax.
- Returns:
sampled indices in as sequence of length n
- mokka.functional.torch.distribution_quantization(probs, n)
Compute a quantized distribution for given probabilities.
This function uses an algorithm introduced for calculating a discrete distribution minimizing the KL divergence for CCDM.
- Parameters:
probs – probabilities of occurence for each element.
n – length of the full sequence.
- Returns:
number of ocurrences for each element in the sequence.
- mokka.functional.torch.unwrap(p, discont=3.141592653589793, dim=-1, period=6.283185307179586)
Perform phase unwrapping in PyTorch.
This implementation follows the NumPy implementation closely.
- Parameters:
p – tensor with angle values
discont – discontinuity to unwrap
dim – dimension to unwrap
period – which periodicity the signal has
- mokka.functional.torch.unwrap_torch(*args)
Perform phase unwrapping in PyTorch.
This implementation follows the NumPy implementation closely.
- Parameters:
p – tensor with angle values
discont – discontinuity to unwrap
dim – dimension to unwrap
period – which periodicity the signal has