Issues using the Slicer 4.11 kernel

username: thatdario
cooked: <p>Hello, I am trying to do the Transfer Learning tutorial that the Pytorch website offers using the Slicer 4.11 kernel with the TorchIO extension but I am finding a problem I don’t understand. The code looks like this</p>
<pre><code class="lang-auto">from __future__ import print_function, division

import torch
import torch.nn as nn
import torch.optim as optim
from torch.optim import lr_scheduler
import torch.backends.cudnn as cudnn
import numpy as np
import torchvision
from torchvision import datasets, models, transforms
import matplotlib.pyplot as plt
import time
import os
import copy

cudnn.benchmark = True
plt.ion()   # interactive mode

import os
os.environ['KMP_DUPLICATE_LIB_OK']='True'

data_transforms = {
    'train': transforms.Compose([
        transforms.RandomResizedCrop(299),
        transforms.RandomHorizontalFlip(),
        transforms.ToTensor(),
        transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
    ]),
    'val': transforms.Compose([
        transforms.Resize(299),
        transforms.CenterCrop(299),
        transforms.ToTensor(),
        transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
    ]),
}

data_dir = r"c:\Users\dario\Letters"
image_datasets = {x: datasets.ImageFolder(os.path.join(data_dir, x),
                                          data_transforms[x])
                  for x in ['train', 'val']}
dataloaders = {x: torch.utils.data.DataLoader(image_datasets[x], batch_size=4,
                                             shuffle=True, num_workers=4)
              for x in ['train', 'val']}
dataset_sizes = {x: len(image_datasets[x]) for x in ['train', 'val']}
class_names = image_datasets['train'].classes

device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")

print(class_names)

def imshow(inp, title=None):
    """Imshow for Tensor."""
    inp = inp.numpy().transpose((1, 2, 0))
    mean = np.array([0.485, 0.456, 0.406])
    std = np.array([0.229, 0.224, 0.225])
    inp = std * inp + mean
    inp = np.clip(inp, 0, 1)
    plt.imshow(inp)
    if title is not None:
        plt.title(title)
    plt.pause(0.001)  # pause a bit so that plots are updated

# Get a batch of training data
inputs, classes = next(iter(dataloaders['train']))
# Make a grid from batch
out = torchvision.utils.make_grid(inputs)
imshow(out, title=[class_names[x] for x in classes]) 
</code></pre>
<p>As you can see, I am using the InceptionV3 model with 5 possible classes because that’s what I am required to work with. The problem comes when it gets to the following line:</p>
<pre><code class="lang-auto">inputs, classes = next(iter(dataloaders['train'])) 
</code></pre>
<p>When it gets here, this window shows up on my screen<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/1/c/1c016ae608c437c362ebc7c94bd0f061ac91d2ac.png" data-download-href="https://discuss.pytorch.org/uploads/default/1c016ae608c437c362ebc7c94bd0f061ac91d2ac" title="slicerproblem"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/1/c/1c016ae608c437c362ebc7c94bd0f061ac91d2ac_2_690x399.png" alt="slicerproblem" data-base62-sha1="3ZKpbQvIfpOVmH5iimIapF24Dko" width="690" height="399" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/1/c/1c016ae608c437c362ebc7c94bd0f061ac91d2ac_2_690x399.png, https://discuss.pytorch.org/uploads/default/optimized/3X/1/c/1c016ae608c437c362ebc7c94bd0f061ac91d2ac_2_1035x598.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/1/c/1c016ae608c437c362ebc7c94bd0f061ac91d2ac.png 2x" data-dominant-color="1D1D1D"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">slicerproblem</span><span class="informations">1118×647 7.71 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><br>
I don’t know what I am supposed to put in here or if this is supposed to be happening. Has anyone encountered an issue like this?</p>