Thanks for your response. I’ve tried using WeightedRandomSampler by splitting them into sampler_train, sampler_val and sampler_test.
class_counts = [72, 36, 36, 36, 1400, 36, 140]   # 7-labels count in 36 receipts
num_samples = sum(class_counts)

class_weights = [num_samples/class_counts[i] for i in range(len(class_counts))]
weights = [class_weights[labels[i]] for i in range(int(num_samples))]

train_features, val_features, test_features = features[0:1266], features[1266:1496], features[1496:]
train_labels, val_labels, test_labels = labels[0:1266], labels[1266:1496], labels[1496:]

sampler_train = WeightedRandomSampler(torch.DoubleTensor(weights[0:1266]), int(1266))
sampler_val = WeightedRandomSampler(torch.DoubleTensor(weights[1266:1496]), int(230))
sampler_test = WeightedRandomSampler(torch.DoubleTensor(weights[1496:]), int(260))

train_data = TensorDataset(torch.from_numpy(train_features), torch.from_numpy(train_labels))
val_data = TensorDataset(torch.from_numpy(val_features), torch.from_numpy(val_labels))
test_data = TensorDataset(torch.from_numpy(test_features), torch.from_numpy(test_labels))

train_loader = DataLoader(train_data, batch_size=300, sampler=sampler_train)
val_loader = DataLoader(val_data, batch_size=115, sampler=sampler_val)
test_loader = DataLoader(test_data, batch_size=130, sampler=sampler_test)

However, I didn’t see any change in the model prediction.