I am guessing that the problem is that my train_set consists of 6 data and 1 target, instead of 1 data and 1 target. In your examples you have only (data, target). So even if I had fixed weights they wouldn’t be multiplied with the correct data. In comments you can see what my train_set contains. I need all 6 inputs in my model therefore I can’t change that. Is there a way around it ?
train_set = SentimentDataset(file=TRAIN_DATA, word2idx=word2idx, tword2idx=tword2idx,
                             max_length=0, max_topic_length=0, topic_bs=True)

 # train_set: message, topic, len(self.data[index]), len(self.topics[index]), self.weights, index, label

_weights = [0.8,0.8,0.3,0.4,0.8]

sampler = torch.utils.data.sampler.WeightedRandomSampler(_weights, BATCH_SIZE)