There’s basically three ways of dealing with this.

    1. Discard data from the more common class

      丢弃数据多的数据.

    2. Weight minority class loss values more heavily

    权重少的数据损失价值更重,loss.

    1. Oversample the minority class

    过采样.
    4. 数据权重处理
    torch.utils.data.WeightedRandomSampler(weights, num_samples, replacement=True, generator=None**).

    Option 1 is implemented by selecting the files you include in your Dataset.
    Option 2 is implemented with the pos_weight parameter for BCEWithLogitsLoss
    Option 3 is implemented with a custom Sampler passed to your Dataloader