I can’t seem to get it to work.
I’ve tried a slightly different approach:
import torch
import torch.nn as nn
import torchvision.models as models

class resnet152_mech(models.resnet152(pretrained=False)):

    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)

However when I create such an object, I get an error:

Traceback (most recent call last):
File “resnet_test.py”, line 1, in 
import resnet_mechion as mechion
File “/home/zuperath/code/mechion_core/python/resnet_mechion.py”, line 7, in 
class resnet152_mech(models.resnet152(pretrained=False)):
File “/home/zuperath/anaconda2/lib/python2.7/site-packages/torchvision/models/resnet.py”, line 106, in init
self.layer1 = self._make_layer(block, 64, layers[0])
File “/home/zuperath/anaconda2/lib/python2.7/site-packages/torchvision/models/resnet.py”, line 123, in _make_layer
if stride != 1 or self.inplanes != planes * block.expansion:
AttributeError: ‘str’ object has no attribute ‘expansion’

I’m not sure what this is, seems to me some logic test tabout planes and blocks fails?