Hello. I have a model with the following layers:
Sequential(
(0): Linear(in_features=256, out_features=256, bias=True)
(1): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1))
(2): ReLU()
(3): ReflectionPad2d((1, 1, 1, 1))
(4): Conv2d(256, 128, kernel_size=(3, 3), stride=(1, 1))
(5): ReLU()
(6): Upsample(scale_factor=2.0, mode=nearest)
(7): ReflectionPad2d((1, 1, 1, 1))
(8): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1))
(9): ReLU()
(10): ReflectionPad2d((1, 1, 1, 1))
(11): Conv2d(128, 64, kernel_size=(3, 3), stride=(1, 1))
(12): ReLU()
(13): Upsample(scale_factor=2.0, mode=nearest)
(14): ReflectionPad2d((1, 1, 1, 1))
(15): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1))
(16): ReLU()
(17): ReflectionPad2d((1, 1, 1, 1))
(18): Conv2d(64, 3, kernel_size=(3, 3), stride=(1, 1))
)
I have a tensor of size [1, 256, 130, 130]
that I give as input to this network. Please note that only the first layer, that is, Linear(in_features=256, out_features=256, bias=True)
is trainable and the rest have fixed weights. Now when I give the tensor as input I am getting the following error: “RuntimeError: mat1 and mat2 shapes cannot be multiplied (33280x130 and 256x256)”
I tried to flatten the tensor for the Linear layer using z_flattened = z.view(z.size(0), -1)
which again gives the following error: “RuntimeError: Expected 4-dimensional input for 4-dimensional weight [256, 256, 3, 3], but got 2-dimensional input of size [1, 256] instead”
Can someone please tell me what am I doing wrong here?