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