Thanks for the response! The type of Dataset is provided via argparse in my scenario generally.
The problem isn’t quite finding the max, but more so incrementing all of the labels by an offset. Most of the datasets I’m using are already in http://pytorch.org/docs/master/torchvision/datasets.html 1 , however as far as I can tell there is no consistent member variable for the labels, eg:

MNIST: uses self.train_labels here: https://github.com/pytorch/vision/blob/master/torchvision/datasets/mnist.py#L53 2

SVHN : uses self.labels here: https://github.com/pytorch/vision/blob/master/torchvision/datasets/svhn.py#L76


So I can’t simply just do something as follows:
# receive list of datasets from argparse
# example we use two below.
mnist = MNIST('./mnist')
svhn = SVHN('./svhn')
# some other datasets here
datasets = [mnist, svhn, ... ]

# find max and cumsum
dataset_label_max = [torch.max(dataset.train_labels) for dataset in datasets]
for i, _ in range(1, len(dataset_label_max)):
    dataset_label_max[i] += dataset_label_max[ i - 1 ]

# for j in range(1, len(dataset_label_max)):
    datasets[j].train_labels += dataset_label_max[ j - 1 ]