while I a am training the Network, Getting TypeError: “‘tuple’ object is not callable” for the ‘for’ loop line of network training code. Attached the concatenated traindataset, its trainloader, and code for training network. The same code worked for non-concatenated train dataset. Not sure what is the issue. Any help would be greatly appreciated.
#Concatenate the 5 different Training set into 1 new training set
cifar_trainset_new = torch.utils.data.ConcatDataset([cifar_trainset, cifar_trainset2, cifar_trainset3, cifar_trainset4, cifar_trainset5])
cifar_trainloader_new = torch.utils.data.DataLoader(cifar_trainset_new, batch_size=4, shuffle=True)
cifar_trainset_new_size = len(cifar_trainset_new)
print(cifar_trainset_new_size)
Use the augmented training images to train the MLP with the best performance and report the new accuracy performance
MLP with best performance is MLP2 which has Accuracy of 41 %
mlp3 = MLP2().to(device)  # operate on GPU
Define a loss function and optimizer
criterion3 = nn.CrossEntropyLoss()
optimizer3 = optim.SGD(mlp2.parameters(), lr=0.001, momentum=0.9)
Training the Network
n_epoch3 = 20
for epoch3 in range(n_epoch3):  # loop over the dataset multiple times
running_loss3 = 0.0
for i, data in enumerate(cifar_trainloader_new, 0):
# TODO: write training code

# get the inputs

inputs = data

labels = data

inputs = inputs.to(device)

labels = labels.to(device)



# zero the parameter gradients

optimizer3.zero_grad()

# forward + backward + optimize

output3 = mlp2(inputs)

loss3 = criterion3(output3, labels)

loss3.backward()

optimizer3.step()



# print statistics

running_loss3 += loss3.item()

if i % 2000 == 1999:    # print every 2000 mini-batches

    print('[%d, %5d] loss2: %.3f' %(epoch3 + 1, i + 1, running_loss3 / 2000))

    running_loss3 = 0.0

print(‘Finished Training3 with new Augmented training images’)
Save the trained model
PATH = ‘./mlp2_cifar10.pth’
torch.save(mlp3.state_dict(), PATH)
#Reloading the model
mlp3 = MLP2().to(device)
mlp3.load_state_dict(torch.load(PATH))
Evaluate the classfication performance on the testing set
correct3 = 0
total3 = 0
with torch.no_grad():
for data in cifar_testloader:
# TODO: write testing code

images , labels = data

images = images.to(device)

labels = labels.to(device)

output3 = mlp3(images)

_, predicted3 = torch.max(output3.data, 1)

total3 += labels.size(0)

correct3 += (predicted3 == labels).sum().item()

print(‘Accuracy of the network on the 10000 test images: %d %%’ % (100 * correct3 / total3))
====== Error =======
TypeError                                 Traceback (most recent call last)
 in ()
14 for epoch3 in range(n_epoch3):  # loop over the dataset multiple times
15   running_loss3 = 0.0
—> 16   for i, data in enumerate(cifar_trainloader_new, 0):
17     # TODO: write training code
18     # get the inputs
7 frames
 in call(self, tensor)
26
27     def call(self, tensor):
—> 28         return tensor + torch.randn(tensor.size()) * self.std + self.mean
29
30     def repr(self):
TypeError: ‘tuple’ object is not callable