Ejemplo n.º 1
0
model = VRidGGNN(model)
# model_name = 'VRid'
# model = load_network(model, model_name)

print(model)

if opt.single_cls:
    if opt.backbone == 'ResNet50':
        ignored_params = list(map(id, model.model.fc.parameters()))
    elif opt.backbone == 'EfficientNet-B0':
        ignored_params = list(map(id, model.model._fc.parameters()))
    ignored_params += (list(map(id, model.classifier.parameters())))
    if opt.freeze_backbone:
        ignored_params += (list(map(id, model.model.parameters())))
    base_params = filter(lambda p: id(p) not in ignored_params,
                         model.parameters())
    # optimizer = optim.SGD(
    #     [{'params': base_params, 'lr': 0.1*opt.lr},
    #      {'params': model.classifier.parameters(), 'lr': opt.lr}],
    #     weight_decay=5e-4, momentum=0.9, nesterov=True)
    optimizer = optim.Adam([{
        'params': base_params,
        'lr': 0.00035
    }, {
        'params': model.classifier.parameters(),
        'lr': 0.0035
    }])
else:
    if opt.backbone == 'ResNet50':
        ignored_params = list(map(id, model.model.fc.parameters()))
    elif opt.backbone == 'EfficientNet-B0':
Ejemplo n.º 2
0
    model = PCB_Effi_GGNN(model, opt)
    # model_name = 'LSTM'
    # model = load_network(model, model_name)

print(model)

if opt.single_cls:
    if opt.backbone == 'ResNet50':
        ignored_params = list(map(id, model.model.fc.parameters()))
    elif opt.backbone == 'EfficientNet-B0':
        ignored_params = list(map(id, model.model._fc.parameters()))
    ignored_params += (list(map(id, model.classifier.parameters())))
    if opt.freeze_backbone:
        ignored_params += (list(map(id, model.model.parameters())))
    base_params = filter(
        lambda p: id(p) not in ignored_params, model.parameters()
    )
    optimizer = optim.SGD(
        [{'params': base_params, 'lr': 0.1*opt.lr},
         {'params': model.classifier.parameters(), 'lr': opt.lr}],
        weight_decay=5e-4, momentum=0.9, nesterov=True)
else:
    if opt.backbone == 'ResNet50':
        ignored_params = list(map(id, model.model.fc.parameters()))
    elif opt.backbone == 'EfficientNet-B0':
        ignored_params = list(map(id, model.model._fc.parameters()))
    ignored_params += (
        list(map(id, model.classifierA0.parameters()))
        + list(map(id, model.classifierA1.parameters()))
        + list(map(id, model.classifierA2.parameters()))
        + list(map(id, model.classifierA3.parameters()))