spine.math.base
Numba JIT compiled implementation of basic functions.
Most of these functions are implemented here because vanilla numba does not support optional arguments, such as axis for most functions or return_counts for the unique function.
Functions
|
Numba implementation of np.all(x, axis). |
|
Numba implementation of np.amax(x, axis). |
|
Numba implementation of np.amin(x, axis). |
|
Numba implementation of np.argmax(x, axis). |
|
Numba implementation of np.argmin(x, axis). |
|
Numba implementation of cross-entropy loss. |
|
Numba implementation of np.mean(x, axis). |
|
Numba implementation of scipy.stats.mode(x). |
|
Sets the numpy random seed for all Numba jitted functions. |
|
Numba implementation of scipy.special.softmax(x, axis). |
|
Numba implementation of np.sum(x, axis). |
|
Numba implementation of np.unique(x, return_counts=True). |
- spine.math.base.seed(seed_value: int) None[source]
Sets the numpy random seed for all Numba jitted functions.
Note that setting the seed using np.random.seed outside a Numba jitted function does not set the seed of Numba functions.
- Parameters:
seed_value (int) – Random number generator seed
- spine.math.base.unique(x: ndarray) tuple[ndarray, ndarray][source]
Numba implementation of np.unique(x, return_counts=True).
- Parameters:
x (np.ndarray) – (N,) array of values
- Returns:
np.ndarray – (U,) array of unique values
np.ndarray – (U,) array of counts of each unique value in the original array
- spine.math.base.sum(x: ndarray, axis: int) ndarray[source]
Numba implementation of np.sum(x, axis).
- Parameters:
x (np.ndarray) – (N, M) array of values
axis (int) – Array axis ID
- Returns:
(N,) or (M,) array of sum values
- Return type:
np.ndarray
- spine.math.base.mean(x: ndarray, axis: int) ndarray[source]
Numba implementation of np.mean(x, axis).
- Parameters:
x (np.ndarray) – (N, M) array of values
axis (int) – Array axis ID
- Returns:
(N,) or (M,) array of mean values
- Return type:
np.ndarray
- spine.math.base.mode(x: ndarray) int[source]
Numba implementation of scipy.stats.mode(x).
- Parameters:
x (np.ndarray) – (N,) array of values
- Returns:
Most-probable value in the array
- Return type:
int
- spine.math.base.argmax(x: ndarray, axis: int) ndarray[source]
Numba implementation of np.argmax(x, axis).
- Parameters:
x (np.ndarray) – (N, M) array of values
axis (int) – Array axis ID
- Returns:
(N,) or (M,) array of argmax values
- Return type:
np.ndarray
- spine.math.base.argmin(x: ndarray, axis: int) ndarray[source]
Numba implementation of np.argmin(x, axis).
- Parameters:
x (np.ndarray) – (N, M) array of values
axis (int) – Array axis ID
- Returns:
(N,) or (M,) array of argmin values
- Return type:
np.ndarray
- spine.math.base.amax(x: ndarray, axis: int) ndarray[source]
Numba implementation of np.amax(x, axis).
- Parameters:
x (np.ndarray) – (N, M) array of values
axis (int) – Array axis ID
- Returns:
(N,) or (M,) array of max values
- Return type:
np.ndarray
- spine.math.base.amin(x: ndarray, axis: int) ndarray[source]
Numba implementation of np.amin(x, axis).
- Parameters:
x (np.ndarray) – (N, M) array of values
axis (int) – Array axis ID
- Returns:
(N,) or (M,) array of min values
- Return type:
np.ndarray
- spine.math.base.all(x: ndarray, axis: int) ndarray[source]
Numba implementation of np.all(x, axis).
- Parameters:
x (np.ndarray) – (N, M) Array of values
axis (int) – Array axis ID
- Returns:
(N,) or (M,) array of all outputs
- Return type:
np.ndarray