Issues using the Slicer 4.11 kernel with Pytorch

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 so far

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

data_transforms = {
    'train': transforms.Compose([
        transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
    'val': transforms.Compose([
        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),
                  for x in ['train', 'val']}
dataloaders = {x:[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")


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)
    if title is not None:
    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]) 

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:

inputs, classes = next(iter(dataloaders['train'])) 

When it gets here, this window shows up on my screen

I don’t know what I am supposed to put in here or if this is supposed to be happening as I haven’t worked with Slicer ever before. Does anyone know how I can solve it?

Can you add a link to the tutorial you are trying to follow? Is it supposed to work in Slicer?

Hello, this is the tutorial:
I it is not made for the Slicer kernel afaik, but I was trying to see if it would work for it since other models worked in it.

You should try with the slicer preview build. It has a newer python and works with pytorch.