Per-sample weights or label fractions

Hi there.

Just wondering if per-sample weighting is currently possible? For our project we need to apply fractional weights to each sample.

Alternatively can DL4J handle having a fraction specified for label values for each sample? This example would indicate that it can: deeplearning4j-examples/ImageDrawer.java at master · eclipse/deeplearning4j-examples · GitHub

However, the Constructor for DataSet specifies that labels must be binarized: https://deeplearning4j.org/api/latest/org/nd4j/linalg/dataset/DataSet.html#DataSet-org.nd4j.linalg.api.ndarray.INDArray-org.nd4j.linalg.api.ndarray.INDArray-org.nd4j.linalg.api.ndarray.INDArray-org.nd4j.linalg.api.ndarray.INDArray-

I’m confused as this seems to be contradictory.

Any advice is greatly appreciated.

I’m facing the same problem, did you solve it?

@arthur-dai-618 depending on whether you’re using samediff or dl4j yes both are possible. Can you clarify which API you’re using?

I’m using dl4j, how to do it?

@arthur-dai-618 here’s weighted labels:

For per example weights, you’d have to implement custom loss:

You could also look in to different sampling techniques as well.

That helps me a lot, thank you very much!