Created
September 23, 2022 04:57
-
-
Save Eligijus112/f574f7eb19a604c695435cf7fdba2a2d to your computer and use it in GitHub Desktop.
Custom MSE loss for tensorflow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Importing the package | |
import tensorflow as tf | |
class NMSE(tf.keras.losses.Loss): | |
def __init__(self): | |
super().__init__() | |
def call(self, y_true, y_pred): | |
# Calculating the mse; | |
# Adding an additional division by 2 to mimic sklearn | |
return tf.reduce_mean(tf.square(y_true - y_pred)) / 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment