nerva_torch.softmax_functions

Softmax and log-softmax functions together with stable variants.

This module provides both function-only forms and simple callable classes.

Functions

log_softmax(X)

Row-wise log-softmax (numerically unsafe version).

log_softmax_jacobian(x)

Jacobian matrix of log_softmax for a single row vector.

softmax(X)

Row-wise softmax with explicit normalization (numerically unsafe).

softmax_jacobian(x)

Jacobian matrix of softmax for a single row vector.

stable_log_softmax(X)

Row-wise log-softmax with max-subtraction for stability.

stable_log_softmax_jacobian(x)

Jacobian matrix of stable log_softmax (same as log_softmax).

stable_softmax(X)

Row-wise softmax using max-subtraction for numerical stability.

stable_softmax_jacobian(x)

Jacobian matrix of stable softmax for a single row vector.

Classes

LogSoftmaxFunction()

Callable implementing row-wise log-softmax and its Jacobian.

SoftmaxFunction()

Callable implementing row-wise softmax and its Jacobian.

StableLogSoftmaxFunction()

Callable implementing numerically stable row-wise log-softmax and its Jacobian.

StableSoftmaxFunction()

Callable implementing numerically stable row-wise softmax and its Jacobian.

nerva_torch.softmax_functions.softmax(X: torch.Tensor) torch.Tensor[source]

Row-wise softmax with explicit normalization (numerically unsafe).

nerva_torch.softmax_functions.softmax_jacobian(x: torch.Tensor) torch.Tensor[source]

Jacobian matrix of softmax for a single row vector.

nerva_torch.softmax_functions.stable_softmax(X: torch.Tensor) torch.Tensor[source]

Row-wise softmax using max-subtraction for numerical stability.

nerva_torch.softmax_functions.stable_softmax_jacobian(x: torch.Tensor) torch.Tensor[source]

Jacobian matrix of stable softmax for a single row vector.

nerva_torch.softmax_functions.log_softmax(X: torch.Tensor) torch.Tensor[source]

Row-wise log-softmax (numerically unsafe version).

nerva_torch.softmax_functions.log_softmax_jacobian(x: torch.Tensor) torch.Tensor[source]

Jacobian matrix of log_softmax for a single row vector.

nerva_torch.softmax_functions.stable_log_softmax(X: torch.Tensor) torch.Tensor[source]

Row-wise log-softmax with max-subtraction for stability.

nerva_torch.softmax_functions.stable_log_softmax_jacobian(x: torch.Tensor) torch.Tensor[source]

Jacobian matrix of stable log_softmax (same as log_softmax).

class nerva_torch.softmax_functions.SoftmaxFunction[source]

Bases: object

Callable implementing row-wise softmax and its Jacobian.

jacobian(X: torch.Tensor) torch.Tensor[source]
class nerva_torch.softmax_functions.StableSoftmaxFunction[source]

Bases: object

Callable implementing numerically stable row-wise softmax and its Jacobian.

jacobian(X: torch.Tensor) torch.Tensor[source]
class nerva_torch.softmax_functions.LogSoftmaxFunction[source]

Bases: object

Callable implementing row-wise log-softmax and its Jacobian.

jacobian(X: torch.Tensor) torch.Tensor[source]
class nerva_torch.softmax_functions.StableLogSoftmaxFunction[source]

Bases: object

Callable implementing numerically stable row-wise log-softmax and its Jacobian.

jacobian(X: torch.Tensor) torch.Tensor[source]