SteiMi / denseweight

The imbalanced regression method DenseWeight produces sample weights for data points in regression tasks so that there is a higher emphasis on ML model performance for rare (and often extreme) data points in comparison to common data points. This repository provides a Python package with which one can easily use DenseWeight.
GNU General Public License v3.0
37 stars 5 forks source link

How to use DenseLoss in Pytorch #2

Open spree1010 opened 2 years ago

spree1010 commented 2 years ago

Hi, I am very interested with this algorithm and want to have a try with DenseLoss in Pytorch, is there some sample code?

Thank you very much! Kun

SteiMi commented 2 years ago

Hi Kun,

You can use it when you define a custom loss function, for example. You can take a look here (starting at line 123) for example, where a loss function is defined that basically applies DenseWeights to a simple MSE loss. In this example, DenseWeight's weights are called "relevance" but this "relevance" is basically the same that this package produces.