I am extremely new to PyTorch and would need a little guidance/clarification.
The tutorial I am inspiring myself from to build my CNN is: Training a Classifier — PyTorch Tutorials 1.10.0+cu102 documentation
I am trying to build my own CNN using a local dataset. The dataset consists of roughly 10,000 images of 56x56.
I have loaded the data using pickle as follows:
with open("./images_l.pkl", 'rb') as f: imgs = pickle.load(f) with open("./labels_l.pkl", 'rb') as f: labels = pickle.load(f)
From the tutorial, it seems as though we want to wrap the dataset in a data loader. So I convert the NumPy array into a dataset and then wrap it in a dataloader as follows:
trainset = torch.utils.data.TensorDataset(torch.tensor(imgs), torch.tensor(labels)) trainloader = torch.utils.data.DataLoader(trainset, batch_size=4)
After doing what’s above, defining + instantiating the CNN and setting the appropriate loss function/optimizer, I attempt to train the network, but there seems to be a mismatch with the dimensions which, I assume, is because the transformation is not applied.
Expected 4-dimensional input for 4-dimensional weight [6, 1, 5, 5], but got 3-dimensional input of size [4, 56, 56] instead
Any guidance would be greatly appreciated.