Skip to content

Conversation

@richardxiong
Copy link

Summary:
Add Huber loss as a new option for regression training

huber loss

def huber(true, pred, delta):
loss = np.where(np.abs(true-pred) < delta , 0.5*((true-pred)2), deltanp.abs(true - pred) - 0.5(delta2))
return np.sum(loss)

As a combination of MSE loss (x < delta) and MAE loss (x >= delta), the advantage of Huber loss is to reduce the training dependence on outlier.

One thing worth to note is that Huber loss is not 2nd differential at x = delta. To further address this problem, one could consider adopt the loss of LOG(cosh(x)).

Differential Revision: D15524377

@pytorchbot pytorchbot added caffe2 module: pybind Related to our Python bindings / interactions with other Python libraries labels May 29, 2019
Summary:
Pull Request resolved: pytorch#21080

Add Huber loss as a new option for regression training (refer to TensorFlow implementation: https://fburl.com/9va71wwo)
  # huber loss
  def huber(true, pred, delta):
    error = abs(true-pred)
    loss = 0.5 * min(error, delta)^2 + delta * max(error - delta, 0)
    return mean(loss)

As a combination of MSE loss (`x < delta`) and MAE loss (`x >= delta`), the advantage of Huber loss is to reduce the training dependence on outlier.

One thing worth to note is that Huber loss is not 2nd differential at `x = delta`. To further address this problem, one could consider adopt the loss of `LOG(cosh(x))`.

Differential Revision: D15524377

fbshipit-source-id: 4a7b0f69b859de3ca903f3bb070c318e0d1f298a
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 76a250d.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

caffe2 Merged module: pybind Related to our Python bindings / interactions with other Python libraries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants