![]() init() nv1 = nn.Conv2d(1, 64, kernel_size=7, stride=2, padding=3, bias=False) 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). I’m not sure what this is, seems to me some logic test tabout planes and blocks fails? If stride != 1 or self.inplanes != planes * block.expansion:ĪttributeError: ‘str’ object has no attribute ‘expansion’ However when I create such an object, I get an error:įile “/home/zuperath/code/mechion_core/python/resnet_mechion.py”, line 7, inįile “/home/zuperath/anaconda2/lib/python2.7/site-packages/torchvision/models/resnet.py”, line 106, in initįile “/home/zuperath/anaconda2/lib/python2.7/site-packages/torchvision/models/resnet.py”, line 123, in _make_layer I’ve tried a slightly different approach: import torchĬlass resnet152_mech(models.resnet152(pretrained=False)):ĭef _init_(self, block, layers, num_classes=4): Using a 64圆4 input will generate a much smaller output.Ĭonsidering those facts, do the best choise The output size using a 224x224 input is 8x8 (forgetting about fully connected and these stuff). You should also consider what are you using this net to. Code will run with 64 by 64 of course but all the pretraining would be not very useful. I am afraind that there is no fine tunning… you would be training from the scratch. You just have to check nv1 to nv1 = nn.Conv2d(1, 64, kernel_size=7, stride=2, padding=3, Self.fc = nn.Linear(512 * block.expansion, num_classes) Self.layer4 = self._make_layer(block, 512, layers, stride=2) Self.layer3 = self._make_layer(block, 256, layers, stride=2) Self.layer2 = self._make_layer(block, 128, layers, stride=2) Self.layer1 = self._make_layer(block, 64, layers) Self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1) This is a copy of official pytorch implementation class ResNet(nn.Module):ĭef _init_(self, block, layers, num_classes=1000): Modifiying ResNet is very easy and more powerful (than VGG).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |