I just want fine tuning ResNet18 on cifar10 datasets. so I just want to change the last linear layer from 1000 to 10.
I tried use children function to get the previous layers
ResModel = resnet18(weights=ResNet18_Weights)
model = nn.Sequential(
*list(ResModel.children())[:-1],
nn.Linear(512,10)
)
so it raised error
RuntimeError: mat1 and mat2 shapes cannot be multiplied (32768x1 and 512x10)
and then I tried this way ResModel.fc=nn.Linear(512,10) it works fine.
so why?