How to reweight the input to a neural network?

For example, I read a set of images into a CNN. And the default weight of these images is 1.
How can I reweight these images so that they have different weights?
Can ‘DataLoader’ achieve this goal?

What do you really mean by the weight of an image?

Just like in adaboost, we need to reweight the input in each iteration. The weight is the same meaning here.

Well, I see two possibilities:

  1. you define a custom loss function, providing weights for each sample as you like.
  2. you repeat samples in your training set, which will result in more frequent samples having a higher weight in your loss.

As far as I know, there is no other way to do this in PyTorch, but maybe I’m wrong…


Thank you very much!