bioneuralnet.network.pysmccnet.math_helpers¶
Functions
|
Finds penalty parameter such that L1 norm of normalized argument equals sumabs. |
|
Computes the L2 norm of a vector; returns 0.05 if norm is zero. |
|
Numpy scaling using sample standard deviation. |
Pytorch scaling using sample standard deviation. |
|
|
Computes element-wise multiplication and sum with vector recycling. |
|
Applies soft thresholding to input x with threshold d. |
- bioneuralnet.network.pysmccnet.math_helpers.binary_search(argu: ndarray | list, sumabs: float) float[source]¶
Finds penalty parameter such that L1 norm of normalized argument equals sumabs.
- bioneuralnet.network.pysmccnet.math_helpers.l2n(vec: ndarray | list) float[source]¶
Computes the L2 norm of a vector; returns 0.05 if norm is zero.
- bioneuralnet.network.pysmccnet.math_helpers.r_scale(x: ndarray | list) ndarray[source]¶
Numpy scaling using sample standard deviation.
- Parameters:
x (np.ndarray | list) – Input data matrix.
- Returns:
Scaled data where each column has mean 0 and sample std 1.
- Return type:
np.ndarray
- bioneuralnet.network.pysmccnet.math_helpers.r_scale_torch(x: torch.Tensor | ndarray | list) torch.Tensor[source]¶
Pytorch scaling using sample standard deviation.
- Parameters:
x (torch.Tensor | np.ndarray | list) – Input data; converted to float32 tensor if not already.
- Returns:
Centered and scaled data tensor.
- Return type:
- bioneuralnet.network.pysmccnet.math_helpers.r_vec_mult_sum(v1: torch.Tensor | ndarray | list, v2: torch.Tensor | ndarray | list) float[source]¶
Computes element-wise multiplication and sum with vector recycling.
- Parameters:
v1 (torch.Tensor | np.ndarray | list) – First input vector.
v2 (torch.Tensor | np.ndarray | list) – Second input vector.
- Returns:
Sum of element-wise product after recycling to matching lengths.
- Return type: