示例#1
0
    },
    'initial_lr': 0.1,
    'optimizer': 'SGD'
}

solver = MXSolver(
    batch_size=64,
    devices=(args.gpu_index, ),
    epochs=30,
    initializer=PReLUInitializer(),
    optimizer_settings=optimizer_settings,
    symbol=network,
    verbose=True,
)

from data_utilities import load_mnist
data = load_mnist(path='stretched_canvas_mnist', scale=1,
                  shape=(1, 56, 56))[:2]
data += load_mnist(path='stretched_mnist', scale=1, shape=(1, 56, 56))[2:]

info = solver.train(data)

postfix = '-' + args.postfix if args.postfix else ''
identifier = 'residual-network-on-stretched-mnist-%d%s' % (
    args.n_residual_layers, postfix)

import cPickle as pickle
pickle.dump(info, open('info/%s' % identifier, 'wb'))
parameters = solver.export_parameters()
pickle.dump(parameters, open('parameters/%s' % identifier, 'wb'))
示例#2
0
        'momentum': 0.9
    },
    'initial_lr': lr,
    'lr_scheduler': AtIterationScheduler(lr, lr_table),
    'optimizer': 'SGD',
    'weight_decay': 0.0001,
}

solver = MXSolver(
    batch_size=BATCH_SIZE,
    devices=(0, 1, 2, 3),
    epochs=int(sys.argv[1]),
    initializer=PReLUInitializer(),
    optimizer_settings=optimizer_settings,
    symbol=network,
    verbose=True,
)

info = solver.train(data)

identifier = 'triple-state-transitory-residual-network'
pickle.dump(info, open('info/%s' % identifier, 'wb'))

parameters, states = solver.export_parameters()
parameters = {
    key: value
    for key, value in parameters.items() if 'transition' in key
}
states = {key: value for key, value in states.items() if 'transition' in key}
pickle.dump((parameters, states), open('parameters/%s' % identifier, 'wb'))