Towards Data Science, Artificial Intelligence, TensorFlow, Machine Learning, Deep Learning.
δ is the threshold, a is the error ( we will calculate a , difference between label and prediction ) So, when |a| ≤δ, loss = 1/2*(a)² and when, |a|>δ, loss = δ(|a| — (1/2)*δ) Code: import tensorflow as tf def my_huber_loss(y_true, y_pred): threshold = 1 error = y_true - y_pred is_small_error =