The original code is:
train_loader = torch.utils.data.DataLoader(train_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()
The original code take data from one source. My intension is to take data from two sources and during training I will add a custom loss in between two sources.
For this reason, I need train data from two sources. For an example on is from train folder another one is from valid folder.