I am working with this code: https://github.com/AlexHex7/CapsNet_pytorch 30
here the training images come from train_loader. I want train the images from valid_loader at the same time. How can I do that?
train_loader = torch.utils.data.DataLoader(train_dataset, batch_size=cfg.batch_size, shuffle=True)
valid_loader = torch.utils.data.DataLoader(valid_dataset, batch_size=cfg.batch_size, shuffle=True)
for epoch_index in range(cfg.epoch):
for train_batch_index, (img_batch, label_batch) in enumerate(train_loader):
img_batch = variable(img_batch)
label_batch = variable(label_batch).unsqueeze(dim=1)
predict, reconstruct_img = net(img_batch, label_batch, train=True)
    acc = net.calc_acc(predict, label_batch)
    margin_loss = net.margin_loss(predict, label_batch)
    reconstruct_loss = net.reconstruction_loss(img_batch, reconstruct_img)      
    loss = margin_loss + reconstruct_loss 
    net.zero_grad()
    loss.backward()
    opt.step()