示例#1
0
def make_model():
    set_seeds()
    model = SeaNet({
        1: (mm.MorphConv2d(1, 32, kernel_size=3, padding=1), 0),
        2: (mm.MorphConv2d(32, 32, kernel_size=3, padding=1), 1),
        3: (mm.MorphBCRLayer(32, 32, kernel_size=3, padding=1), 2),
        4: (nn.MaxPool2d(2), 3),
        5: (mm.MorphFlatLinear(6272, 10), 4)
    })
    model.eval()
    return model
示例#2
0
for d in ['models', 'logs']:
    try:
        d_run = os.path.join('results', args.run_name, d)
        assert not os.path.exists(d_run), '%s already exists!' % d_run
        _ = os.makedirs(d_run)
    except:
        pass

base_model = SeaNet(
    {
        1: (mm.MorphBCRLayer(3, 64, kernel_size=3, padding=1), 0),
        2: (mm.MaxPool2d(2), 1),
        3: (mm.MorphBCRLayer(64, 128, kernel_size=3, padding=1), 2),
        4: (mm.MaxPool2d(2), 3),
        5: (mm.MorphBCRLayer(128, 128, kernel_size=3, padding=1), 4),
        6: (mm.MorphFlatLinear(2048 * 4, 10), 5),
    },
    input_shape=(3, 32, 32))

pretrain_epochs = 20
additional_epochs = 20

dataloaders = make_dataloaders(train_size=1.0)
base_model, base_performance = train(base_model,
                                     dataloaders,
                                     epochs=pretrain_epochs,
                                     verbose=True)

for p in base_performance:
    p.update({"run_id": -1, "scratch": True})
    print(json.dumps(p))