Loss Functions
- class gwu_nn.loss_functions.LossFunction
Abstract Class for loss functions
- abstract loss(y_true, y_pred)
Calculates the loss for the given network.
- Args:
y_true (np.array): the true values y_pred (np.array): the predicted values
- Returns:
np.array(np.array): the network’s loss
- abstract loss_partial_derivative(y_true, y_pred)
Calculates the derivative of the loss for the given network.
- Args:
y_true (np.array): the true values y_pred (np.array): the predicted values
- Returns:
np.array(np.array): the partial derivative for the network’s loss
- class gwu_nn.loss_functions.MSE
Class for implementing the MSE loss function. Inheirits loss and loss_partial_derivative from LossFunction
- classmethod loss(y_true, y_pred)
Calculates the MSE for the true vs predicted values
- Returns:
np.array: MSE for each input
- classmethod loss_partial_derivative(y_true, y_pred)
Calculates the derivative of the MSE for each prediction
- Returns:
np.array: Partial derivative of the MSE
- class gwu_nn.loss_functions.LogLoss
Class for implementing the LogLoss loss function. Inheirits loss and loss_partial_derivative from LossFunction
- classmethod loss(y_true, y_pred)
Calculates the LogLoss for the true vs predicted values
- Returns:
np.array: LogLoss for each input
- classmethod loss_partial_derivative(y_true, y_pred)
Calculates the derivative of the LogLoss for each prediction
- Returns:
np.array: Partial derivative of the LogLoss
- class gwu_nn.loss_functions.CrossEntropy
Class for implementing the CrossEntropy loss function. Inheirits loss and loss_partial_derivative from LossFunction
- classmethod loss(y_true, y_pred)
Calculates the CrossEntropy for the true vs predicted classes
- Returns:
np.array: CrossEntropy for each input/class
- classmethod loss_partial_derivative(y_true, y_pred)
Calculates the derivative of the CrossEntropy for each prediction
- Returns:
np.array: Partial derivative of the CrossEntropy