albanD:

The weight parameter is usually with respect to labels, not batch samples !


Oh~~~
Like here (def cross_entropy) 4 said,

weight (Tensor, optional): a manual rescaling weight given to each class. If given, has to be a Tensor of size C

Providing the output node is size of (100,), then I should set the parameter weight with shape of (100,).
This works like:
label vector = (
label_1_new = label_1_old * weight_1,
label_2_new = label_2_old * weight_2,
…
label_100_new = label_100_old * weight_100,
)
In fact, it just adjusts the size of the label.
Maybe I can adjust the size of the label directly, instead of using this parameter?
Is this understanding right?
But here (binary_cross_entropy) 2 said,

weight (Tensor, optional): a manual rescaling weight if provided it’s repeated to match input tensor shape

Why the focus here is turned into input, but not label?