Softmax Functions

class complextorch.nn.modules.softmax.CVSoftMax(dim: int | None = None)

Split Complex-Valued Softmax Layer

Simple real/image split softmax function. Applies SoftMax to the real and imaginary parts of the input tensor.

Note: this naive implementation can cause significant phase changes and the relationship between the real and iamginary parts of the complex-valued signal are ignored in the two SoftMax computations.

Implements the following operation:

\[G(\mathbf{z}) = \texttt{SoftMax}(\mathbf{x}) + j \texttt{SoftMax}(\mathbf{y}),\]

where \(\mathbf{z} = \mathbf{x} + j\mathbf{y}\)

forward(input: CVTensor) CVTensor

Computes softmax over the real and imaginary parts of the input tensor separately

Parameters:

input (CVTensor) – input tensor

Returns:

\(\texttt{SoftMax}(\mathbf{x}) + j \texttt{SoftMax}(\mathbf{y})\)

Return type:

CVTensor

class complextorch.nn.modules.softmax.MagSoftMax(dim: int | None = None)

Magnitude Softmax Layer

Ignores phase and applies SoftMax to the magnitude.

Implements the following operation:

\[G(\mathbf{z}) = \texttt{SoftMax}(|\mathbf{z}|)\]
forward(input: CVTensor) CVTensor

Ignores phase and applies SoftMax function to magnitude.

Parameters:

input (CVTensor) – input tensor

Returns:

\(\texttt{SoftMax}(|\mathbf{z}|)\)

Return type:

CVTensor

class complextorch.nn.modules.softmax.PhaseSoftMax(dim: int | None = None)

Phase-Preserving Complex-Valued Softmax Layer

Retains phase and applies SoftMax function to magnitude.

Implements the following operation:

\[G(\mathbf{z}) = \texttt{SoftMax}(|\mathbf{z}|) \odot \mathbf{z} / |\mathbf{z}|\]
forward(input: CVTensor) CVTensor

Retains phase and applies SoftMax function to magnitude.

Parameters:

input (CVTensor) – input tensor

Returns:

\(\texttt{SoftMax}(|\mathbf{z}|) \odot \mathbf{z} / |\mathbf{z}|\)

Return type:

CVTensor