Created
April 9, 2023 12:05
-
-
Save doleron/03ff2dadf90ad841877aca76f69e7f43 to your computer and use it in GitHub Desktop.
This file contains 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
class Custom_Precision(tf.keras.metrics.Precision): | |
def update_state(self, y_true, y_pred, sample_weight=None): | |
y_pred_fix = tf.math.less(y_pred, 0.5) | |
y_pred_fix = tf.cast(y_pred_fix, y_pred.dtype) | |
return super().update_state(y_true, y_pred_fix, sample_weight) | |
class Custom_Recall(tf.keras.metrics.Recall): | |
def update_state(self, y_true, y_pred, sample_weight=None): | |
y_pred_fix = tf.math.less(y_pred, 0.5) | |
y_pred_fix = tf.cast(y_pred_fix, y_pred.dtype) | |
return super().update_state(y_true, y_pred_fix, sample_weight) | |
class Custom_Accuracy(tf.keras.metrics.Accuracy): | |
def update_state(self, y_true, y_pred, sample_weight=None): | |
y_pred_fix = tf.math.less(y_pred, 0.5) | |
y_pred_fix = tf.cast(y_pred_fix, y_pred.dtype) | |
return super().update_state(y_true, y_pred_fix, sample_weight) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment