Convering my 2D CNN model to 3D

class Skyrmion_or_Not(Dataset):

def __init__(self, csv_file, root_dir, transform=None):
        self.annotations = pd.read_csv(csv_file)
        self.root_dir = root_dir
        self.transform = transform

def __len__(self):
    return len(self.annotations)

def __getitem__(self, index): # return specific image and target for image
    
    # Some aspect of the code ignores the first row of the csv file and treats as the header
    
    img_path = os.path.join(self.root_dir, self.annotations.iloc[index, 0])
    # pytorch chooses index. idea sytem looks up file name in the labels file 
    # and then finds corresponding image/file in the relevant folder
    image = np.load(img_path)
    y_label = torch.tensor(int(self.annotations.iloc[index, 1])) # reading column 1 as the label

    if self.transform:
        image = self.transform(image)

    return (image, y_label) # the y_label is it being assigned 0, 1.

This is my current custom dataset for my 2D case. I now have 3D images (dimensions 30 x 30 x 30 x 3), however I am unsure what to adjust here.

Folloeing on from this, how does one visualise a pure 3D image on matplotlib. I am aware of how I can do it on plotly, however, I want to visualise batches (previously used plt.imshow, however this only has 2d inputs). Any help would be much appreciated!

Can’t think of any reason why you’d need to change anything in the Dataset/Dataloader to go from 2D to 3D.

The model, however, is another story.