losses

losses

Functions

Name Description
L1_entropy Entropy of the basis \(\phi\).
L1_norm L1 norm of the basis \(\phi\).
mae Mean absolute error
mse Mean squared error
rmse Root mean squared error
total_loss Total loss function.

L1_entropy

losses.L1_entropy(L1_norm)

Entropy of the basis \(\phi\).

\[ - \sum_{i=1}^{N} \phi_i \log \left( \phi_i \right) \]

Parameters

Name Type Description Default
L1_norm Array L1 norm of the basis with shape (\(N\),) required

Returns

Name Type Description
Array Array entropy of the basis with shape (\(N\),)

L1_norm

losses.L1_norm(phi)

L1 norm of the basis \(\phi\).

Parameters

Name Type Description Default
phi Array basis with shape (\(D\), \(N\)) required

Returns

Name Type Description
Array Array L1 norm of the basis with shape (\(N\),)

mae

losses.mae(y_train, y_pred)

Mean absolute error

\[ \mathrm{MAE} = \frac{1}{D} \sum_{i=1}^D |y_i - \hat{y}_i| \]

Parameters

Name Type Description Default
y_train Array target value with shape (D, 1) required
y_pred Array prediction with shape (D, 1) required

Returns

Name Type Description
Array Array mean absolute error with shape (1,)

mse

losses.mse(y_train, y_pred)

Mean squared error

\[ \mathrm{MSE} = \frac{1}{D} \sum_{i=1}^D (y_i - \hat{y}_i)^2 \]

Parameters

Name Type Description Default
y_train Array target value with shape (D, 1) required
y_pred Array prediction with shape (D, 1) required

Returns

Name Type Description
Array Array mean squared error with shape (1,)

rmse

losses.rmse(y_train, y_pred)

Root mean squared error

\[ \mathrm{RMSE} = \sqrt{\frac{1}{D} \sum_{i=1}^D (y_i - \hat{y}_i)^2} \]

Parameters

Name Type Description Default
y_train Array target value with shape (D, 1) required
y_pred Array prediction with shape (D, 1) required

Returns

Name Type Description
Array Array root mean squared error with shape (1,)

total_loss

losses.total_loss(y_train, y_pred, basis, lambda1=0.01, mu1=1.0, mu2=1.0)

Total loss function.

\[ \mathrm{total\_loss} = \mathrm{MSE} + \lambda (\mu_1 \mathrm{L1\_entropy} + \mu_2 \mathrm{L1\_entropy}) \]

Parameters

Name Type Description Default
y_train Array target value with shape (D, 1) required
y_pred Array prediction with shape (D, 1) required
basis list[Array] basis with shape (D, N) required

Returns

Name Type Description
Array Array total loss with shape (1,)