Loss Functions in RavML
Loss functions are crucial for building your Machine learning algorithms as they measure the difference between the target output and the predicted output. Different use cases require different loss functions and it’s essential to use them.
RavML supports various loss functions which can be utilized while building your various machine learning and deep learning models in the Ravenverse. You can import these loss functions from the Ravml library which also has several ML algorithms which will support these loss functions.
Loss functions in the RavML library are written using the RavOP library for distributing the associated computations through the Ravenverse framework.
The loss functions return the output in the form of a Ravop tensor on which you can perform further operations using the tensor operations present in the Ravop library.
Supported Loss functions, their parameters, and return values are mentioned below.
- Mean absolute error
Parameters :
y_true : array-like of shape (n_samples,) or (n_samples, n_outputs).Ground truth (correct) target values.
y_pred : array-like of shape (n_samples,) or (n_samples, n_outputs). Estimated target values.
Returns:
Ravop Tensor
from ravml.losses import mean_absolute_error
2. Mean squared error
Parameters :
y_true : array-like of shape (n_samples,) or (n_samples, n_outputs).Ground truth (correct) target values.
y_pred : array-like of shape (n_samples,) or (n_samples, n_outputs). Estimated target values.
Returns:
Ravop Tensor
from ravml.losses import mean_squared_error
3. Root mean squared error
Parameters :
y_true : array-like of shape (n_samples,) or (n_samples, n_outputs).Ground truth (correct) target values.
y_pred : array-like of shape (n_samples,) or (n_samples, n_outputs). Estimated target values.
Returns:
Ravop Tensor
4. One hot cross entropy
One hot cross entropy is denoted by the following equation:
Parameters :
y_true : array-like of shape (n_samples,) or (n_samples, n_outputs).Ground truth (correct) target values.
y_pred : array-like of shape (n_samples,) or (n_samples, n_outputs). Estimated target values.
with_logit : Boolean value denoting whether to add a softmax function on the predicted values.
Returns:
Ravop Tensor
5. Kullback - Leibler divergence loss
Parameters :
y_true : array-like of shape (n_samples,) or (n_samples, n_outputs).Ground truth (correct) target values.
y_pred : array-like of shape (n_samples,) or (n_samples, n_outputs). Estimated target values.
Returns:
Ravop Tensor
6. Poisson Loss
Parameters :
y_true : array-like of shape (n_samples,) or (n_samples, n_outputs).Ground truth (correct) target values.
y_pred : array-like of shape (n_samples,) or (n_samples, n_outputs). Estimated target values.
Returns:
Ravop Tensor
7. Huber Loss
Parameters :
y_true : array-like of shape (n_samples,) or (n_samples, n_outputs).Ground truth (correct) target values.
y_pred : array-like of shape (n_samples,) or (n_samples, n_outputs). Estimated target values.
Returns:
Ravop Tensor
8. Categorical Hinge Loss
Parameters :
y_true : array-like of shape (n_samples,) or (n_samples, n_outputs).Ground truth (correct) target values.
y_pred : array-like of shape (n_samples,) or (n_samples, n_outputs). Estimated target values.
Returns:
Ravop Tensor
9. Log loss
y_true : array-like of shape (n_samples,) or (n_samples, n_outputs).Ground truth (correct) target values.
y_pred : array-like of shape (n_samples,) or (n_samples, n_outputs). Estimated target values.
Returns:
Ravop Tensor
10. Root Mean squared Log error
y_true : array-like of shape (n_samples,) or (n_samples, n_outputs).Ground truth (correct) target values.
y_pred : array-like of shape (n_samples,) or (n_samples, n_outputs). Estimated target values.
Returns:
Ravop Tensor
Check RavML’s GitHub Repository to learn more about these functions and their usage. If you have some functions in mind that you wish to contribute, fork the repository and raise a pull request.
Join Raven Protocol’s Discord and telegram group to connect with the Ravenverse community and contribute to the GitHub repository.