Alex_Ge:

import torch import torch.nn as nn import torchvision.models as models class resnet152_mech(models.resnet152(pretrained=False)): def init(): self.inplanes = 64 super(resnet152_mech, self).init() self.conv1 = nn.Conv2d(1, 64, kernel_size=7, stride=2, padding=3, bias=False)


Hi, I think you are commiting a coding error.
You are creating a inherited class from an object. I reviewed the source code and when u call
models.resnet152(pretrained=False)

You are defining a model, it means, u are creating an instance of the class ResNet. When you inherit a class from another class you have to call the class, not the instance.
Therefore:
Your fixed code is:
import torch
import torch.nn as nn
import torchvision.models as models

class resnet152_mech(models.resnet.ResNet):

    def __init__(self, block, layers, num_classes=4):
        self.inplanes = 64
        super(resnet152_mech, self).__init__()
        self.conv1 = nn.Conv2d(1, 64, kernel_size=7, stride=2, padding=3,
                               bias=False)

For later on defining your model you have to use a similar instance definition:
 model = resnet152_mech(models.resnet.Bottleneck, [3, 8, 36, 3], **kwargs)

Oh, dont forget about modifiying **kwargs xd
Something like that