PyTorch ImageFolder Dataset conversion to 1d
I have a dataset with three labels.
First, I'm loading my data into a Dataset with the ImageFolder class and the CenterCrop transform.
So every picture has now three channels r, g, b with 224x224 values from 0..1. I thought my NN has 224×224×3 Input Nodes.
I get this error:
RuntimeError: mat1 and mat2 shapes cannot be multiplied (21504x224 and 150528x200)

Assuming that the first mat1 is the Image (I have no clue where the 21504 is coming from)  and the second one is the first nn.Linear(2242243, 200) Layer, I can see why they cannot be multiplied. So, I changed the nn.Linear(2242243) to nn.Linear(224). Now it works, but..
transform = transforms.Compose([transforms.Resize((300, 200)),
                                transforms.CenterCrop(224),
                                transforms.ToTensor()])

dataset = datasets.ImageFolder('/content/drive/MyDrive/Colab Notebooks/data', transform=transform)

# ... BatchSize = 32
model = nn.Sequential(
        nn.Linear(224, 200), # &lt;- The Size of one Row! 
        nn.Sigmoid(),  
        nn.Linear(200, 40),
        nn.Sigmoid(),
        nn.Dropout(p=0.2),
        nn.Linear(40, 40),
        nn.Sigmoid(), 
        nn.Linear(40, 20),
        nn.Sigmoid(),
        nn.Linear(20, 3) 
    ).to(device)
# ...
prediction = model(x)


For some Reaseon my prediction has now this from.
prediction[32][3][224]

I would expect 32 items in a list for a Batch. Every Item from the Batch contains 3 values with the probability what the label is. But why does the Height / width came up here?.
I think I have to change the Format of the dataset from 224x224x3 (3d) to 150528 1d, but operations like view() did not work, probably because of the lazy loading from ImageFolder.
The NN works fine with the MINST dataset. (28x28) In and (10) Out. So my guess is: The dataset has to be transformed, but I can't figure out how.

It can work if you apply transforms.Lambda and change transforms in the following way:
transform = transforms.Compose([transforms.Resize((300, 200)),
                                transforms.CenterCrop(224),
                                transforms.ToTensor(),
                                transforms.Lambda(lambda x: torch.flatten(x))])

As a result you will have (batch_size, 150528) shape for each batch which means that you need to specify 150528 input size for the first linear layer. Not sure that it's reasonable to classify images with linear fully-connected layers in such a case. It will work slowly and unlikely converge to some good predictions. You'd better consider using convolution layers instead.
