[9e8054]: / aggmap / aggmodel / loss.py

Download this file

23 lines (13 with data), 604 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import tensorflow as tf
from sklearn.metrics import roc_auc_score
import numpy as np
########### classification ##############
def cross_entropy(y_true, y_pred):
cost = tf.nn.sigmoid_cross_entropy_with_logits(labels=labels, logits=logits)
return cost
def weighted_cross_entropy(y_true, y_pred, pos_weight):
cost = tf.nn.weighted_cross_entropy_with_logits(labels=labels, logits=logits,
pos_weight = pos_weight)
return cost
def MALE(y_obs, y_pred):
return tf.keras.backend.log(0.5 + tf.keras.backend.abs(y_pred - y_obs))