-
Notifications
You must be signed in to change notification settings - Fork 3
/
objectives.py
51 lines (40 loc) · 1.02 KB
/
objectives.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""Loss functions."""
import tensorflow as tf
import semver
def huber_loss(y_true, y_pred, max_grad=1.):
"""Calculate the huber loss.
See https://en.wikipedia.org/wiki/Huber_loss
Parameters
----------
y_true: np.array, tf.Tensor
Target value.
y_pred: np.array, tf.Tensor
Predicted value.
max_grad: float, optional
Positive floating point value. Represents the maximum possible
gradient magnitude.
Returns
-------
tf.Tensor
The huber loss.
"""
pass
def mean_huber_loss(y_true, y_pred, max_grad=1.):
"""Return mean huber loss.
Same as huber_loss, but takes the mean over all values in the
output tensor.
Parameters
----------
y_true: np.array, tf.Tensor
Target value.
y_pred: np.array, tf.Tensor
Predicted value.
max_grad: float, optional
Positive floating point value. Represents the maximum possible
gradient magnitude.
Returns
-------
tf.Tensor
The mean huber loss.
"""
pass