Hi!
I have defined my autoencoder in pytorch as following:
        self.encoder = nn.Sequential(
            nn.Conv2d(input_shape[0], 32, kernel_size=1, stride=1),
            nn.ReLU(),
            nn.Conv2d(32, 64, kernel_size=1, stride=1),
            nn.ReLU(),
            nn.Conv2d(64, 64, kernel_size=1, stride=1),
            nn.ReLU()
        )

        self.decoder = nn.Sequential(
            nn.Conv2d(64, 64, kernel_size=1, stride=1),
            nn.ReLU(),
            nn.Conv2d(64, 32, kernel_size=1, stride=1),
            nn.ReLU(),
            nn.Conv2d(32, input_shape[0], kernel_size=1, stride=1),
            nn.ReLU(),
            nn.Sigmoid()
        )

Everything works fine, I can train it.
But, what I need is to get a reduced dimension encoding which requires creating a new linear layer of the dimension N much lower than the image dimension so that I can extract the activations.
If anybody can help me with fitting a linear layer in the decoder part I would appreciate (i know how to Flatten() the data, but I guess I need to “unflatten” it again to interface with the Conv2d layer again)
Thank you in advance.