Solved by Mona_Jalal in post #2 
              
              
                I decided to use an alternative method shown below: 
###im_paths = torch.Tensor()
im_paths = []
with torch.no_grad():
    for i, (inputs, classes, im_path) in enumerate(dataloaders['test']):
       
        ###im_paths = torch.cat((im_paths, im_path), )
        im_paths.append(im_path)

flattened_im…