def __init__(self): super(EmbeddingNetwork, self).__init__() self.resnet = res18_oct_or_octa() self.resnet.load_state_dict(torch.load('./res18_octa.pth')) #180 0.8116 210 0.7729 240 0.8043 270:0.837 300:0.8442 360:0.8490 390:0.8297 420:0.8418 450:0.8297 #60 0.8176 120:0.8249 810:0.8285 720:0.9034 self.cls = self.resnet.cls self.cls.load_state_dict(self.resnet.cls.state_dict()) self.conv1 = self.resnet.conv1 self.conv1.load_state_dict(self.resnet.conv1.state_dict()) self.bn1 = self.resnet.bn1 self.bn1.load_state_dict(self.resnet.bn1.state_dict()) self.relu = self.resnet.relu self.maxpool = self.resnet.maxpool self.layer1 = self.resnet.layer1 self.layer1.load_state_dict(self.resnet.layer1.state_dict()) self.layer2 = self.resnet.layer2 self.layer2.load_state_dict(self.resnet.layer2.state_dict()) self.layer3 = self.resnet.layer3 self.layer3.load_state_dict(self.resnet.layer3.state_dict()) self.layer4 = self.resnet.layer4 self.layer4.load_state_dict(self.resnet.layer4.state_dict()) self.avgpool = self.resnet.avgpool
def __init__(self): super(EmbeddingNetwork, self).__init__() self.resnet = res18_oct_or_octa() self.resnet.load_state_dict(torch.load('./res18_oct.pth')) self.cls = self.resnet.cls self.cls.load_state_dict(self.resnet.cls.state_dict()) self.conv1 = self.resnet.conv1 self.conv1.load_state_dict(self.resnet.conv1.state_dict()) self.bn1 = self.resnet.bn1 self.bn1.load_state_dict(self.resnet.bn1.state_dict()) self.relu = self.resnet.relu self.maxpool = self.resnet.maxpool self.layer1 = self.resnet.layer1 self.layer1.load_state_dict(self.resnet.layer1.state_dict()) self.layer2 = self.resnet.layer2 self.layer2.load_state_dict(self.resnet.layer2.state_dict()) self.layer3 = self.resnet.layer3 self.layer3.load_state_dict(self.resnet.layer3.state_dict()) self.layer4 = self.resnet.layer4 self.layer4.load_state_dict(self.resnet.layer4.state_dict()) self.avgpool = self.resnet.avgpool
# x=torch.cat([x1,x2],1) # x = self.conv1(x) # x = self.bn1(x) # x = self.relu(x) # x = self.maxpool(x) # layer1 = self.layer1(x) # (, 64L, 56L, 56L) # layer2 = self.layer2(layer1) # (, 128L, 28L, 28L) # layer3 = self.layer3(layer2) # (, 256L, 14L, 14L) # layer4 = self.layer4(layer3) # (,512,7,7) # x = self.avgpool(layer4) # (,512,1,1) # # # x = x.view(x.size(0), -1) # return x classificationNetwork = res18_oct_or_octa().cuda() ############################################# # Define the optimizer criterion = nn.CrossEntropyLoss() optimizer_embedding = optim.Adam([ { 'params': classificationNetwork.parameters() }, ], lr=0.001) embedding_lr_scheduler = lr_scheduler.StepLR(optimizer_embedding, step_size=10,