Skip to content
Snippets Groups Projects
Select Git revision
  • 480414873f45779911f3ca8f1f8150ee15a924fb
  • 2023 default
  • pages protected
  • 2022-matse
  • 2022
  • 2021
  • 2019
  • master
8 results

Introduction-to-Pandas--master.ipynb

Blame
  • loss.py 526 B
    """Collection of different customised loss functions."""
    
    from keras import backend as K
    
    from typing import Callable
    
    
    def l_p_loss(power: int) -> Callable:
        """
        Calculate the L<p> loss for given power p.
    
        L1 (p=1) is equal to mean absolute error (MAE), L2 (p=2) is to mean squared error (MSE), ...
    
        :param power: set the power of the error calculus
    
        :return: loss for given power
        """
    
        def loss(y_true, y_pred):
            return K.mean(K.pow(K.abs(y_pred - y_true), power), axis=-1)
    
        return loss