Hi! I’m trying to implement transfer learning on binary classification using ResNet model. I have tried the solution showed in this discussion but I’m stuck in this error:
RuntimeError: running_mean should contain 128 elements not 64
This is the way I define and call the pretrained model:
class ResnetPretrained(models.resnet.ResNet):
def __init__(self, block, layers, num_classes=2):
self.inplanes = 128
super(ResnetPretrained, self).__init__(block, layers)
self.conv1 = nn.Conv2d(1, 128, kernel_size=(7, 7), bias=False)
model = ResnetPretrained(models.resnet.Bottleneck, [3, 8, 36, 3]).to(device)
My input is 128x128, 1 channel and I’m normalizing the datasets with its own mean and std parameters.
This line calls the error:
for epoch in range(self.num_epochs):
i = 0
for images, labels in self.train_set_loader:
images = images.to(device)
labels = labels.to(device))
outputs = model(images) <----------- this line calls the error
loss = criterion(outputs, labels.long())
The error reference points to this batch_norm nn.functional function
I don’t understand what this error means, where should I look to solve it?
Thanks!