Hi I’m trying to create my first simple_cnn on my dataset.
The shape of my images are: torch.Size([64, 3, 120, 340])
And my cnn is:
def conv(ni, nf, ks=3, act=True):
layers = [nn.Conv2d(ni, nf, stride=2, kernel_size=ks, padding=ks//2)]
layers.append(nn.BatchNorm2d(nf))
if act: layers.append(nn.ReLU())
return nn.Sequential(*layers)
simple_cnn= sequential(
conv(3 ,64),
conv(64 ,128),
conv(128 ,128),
conv(128 ,128),
conv(128 ,128),
Flatten(),
nn.Linear(2048,2048),
nn.Linear(2048,2048),
nn.Linear(2048,2)
)
learn= Learner(dls,simple_cnn,loss_func=CrossEntropyLossFlat(), metrics=accuracy)
learn.fine_tune(20)
But I have the following error: RuntimeError: mat1 dim 1 must match mat2 dim 0
Can someone help me?