@ptrblck,  i just wonder how to apply the weight  in BCELoss in real training scenario. That is, the dataset is splitted into training, validation and testing subset. What is more,  during model training, there are some epoches and an  epoch  is comprised of one or more batches. So   the weight can be  calculated in  dataset level, training subset level  or even batch level. How to choose? Note that, in batch level, the number of positive or negative in each class may be zero, thus, the following will be occurred: pos_weight = torch.Tensor([(negative examples / 0)]).
Another question is that Adamax and BCELoss is used but my F1 score is just 0.04,   how to tune the performance?