My understanding is that:


In fact, when it’s the default value (None), the parameter weight is a vector which is full of (1,). I mean, weight = (1, 1, …, 1). The size of vector equals the number of batch-size.


Assume the size of batch is 4, and I set the weight = (w1, w2, w3, w4).
Then the value of loss function:
Loss = (loss_sample_1 * w1 +  loss_sample_2 * w2 + loss_sample_3 * w3 + loss_sample_4 * w4) / (w_1 + w_2 + w_3 + w_4)
Here, each loss sample is also a vector, with size of number of output nodes.


Actually, it adjusts the size of the learning rate for each sample.


So the larger the value of weight parameter, the greater the impact to the Loss.


It is generally used when the size of various data sets is not balanced.


Is this the right understanding?
I tried to see the source code, but I could not find it.