I have to use both MNIST and SVHN dataset.
but length of MNIST train loader is 600 and SVHN train loader is 733. It’s different…
and I think I should reset the ‘data_iter’ on each dataset but I don’t know this usage is right.
# MNIST
dataset = dsets.MNIST(root='./data',
                      train=True,
                      transform=transforms.ToTensor(),
                      download=True)

mnist_data_loader = torch.utils.data.DataLoader(dataset=dataset,
                                          batch_size=100,
                                          shuffle=True)

# SVHN
svhn_transform = transforms.Compose([transforms.Grayscale(), transforms.Resize(28), transforms.ToTensor()])
dataset = dsets.SVHN(root='./data/',
                     split='train',
                     transform=svhn_transform,
                     download=True)
svhn_data_loader = torch.utils.data.DataLoader(dataset=dataset,
                                          batch_size=100,
                                          shuffle=True)

mnist_iter_per_epoch = len(mnist_train_loader) # length of this loader : 600
svhn_iter_per_epoch = len(svhn_train_loader) # length of this loader : 733

for epoch in range(100):
   # Reset the data_iter
   if (epoch+1) % mnist_iter_per_epoch ==0:
         mnist_iter = iter(mnist_train_loader)
   if (epoch+1) % svhn_iter_per_epoch ==0:
         svhn_iter = iter(svhn_train_loader)
    ...