Esempio n. 1
0
                              normalization='batch',
                              id='softmax')

optimizer_settings = {
    'args': {
        'momentum': 0.9
    },
    '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)
Esempio n. 2
0
network = nin(activate)

lr = 0.1
lr_table = {100000 : lr * 0.1}
lr_scheduler = AtIterationScheduler(lr, lr_table)
optimizer_settings = {
  'args'         : {'momentum' : 0.9},
  'initial_lr'   : lr,
  'lr_scheduler' : lr_scheduler,
  'optimizer'    : 'SGD',
  'weight_decay' : 0.0001,
}

solver = MXSolver(
  batch_size = BATCH_SIZE,
  devices = (0, 1, 2, 3),
  epochs = 300,
  initializer = DReLUInitializer(0, 1),
  optimizer_settings = optimizer_settings,
  symbol = network,
  verbose = True,
)

data = load_cifar10_record(BATCH_SIZE)
info = solver.train(data)

identifier = 'residual-network-n-%d-activate-%s-times-%d' % (N, ACTIVATE, TIMES)
pickle.dump(info, open('info/%s' % identifier, 'wb'))
parameters = solver.export_parameters()
pickle.dump(parameters, open('parameters/%s' % identifier, 'wb'))
Esempio n. 3
0
        'args': {
            'momentum': 0.9
        },
        'initial_lr': args.initial_lr,
        'lr_scheduler': lr_scheduler,
        'optimizer': 'SGD',
        'weight_decay': 0.0001,
    }

    from mx_solver import MXSolver
    from mx_initializer import PReLUInitializer
    solver = MXSolver(
        batch_size=args.batch_size,
        devices=(0, 1, 2, 3),
        epochs=150,
        initializer=PReLUInitializer(),
        optimizer_settings=optimizer_settings,
        symbol=network,
        verbose=True,
    )

    from data_utilities import load_cifar10_record
    data = load_cifar10_record(args.batch_size)

    info = solver.train(data)

    postfix = '-' + args.postfix if args.postfix else ''
    identifier = 'rnn-attention-network-on-cifar-10-%d%s' % (args.n_layers,
                                                             postfix)

    import cPickle as pickle
Esempio n. 4
0
lr_scheduler = AtIterationScheduler(lr, lr_table)

optimizer_settings = {
    'args': {
        'momentum': 0.9
    },
    'initial_lr': lr,
    'lr_scheduler': lr_scheduler,
    'optimizer': 'SGD',
}

solver = MXSolver(
    batch_size=BATCH_SIZE,
    devices=GPU_availability()[:1],
    epochs=150,
    initializer=PReLUInitializer(),
    optimizer_settings=optimizer_settings,
    symbol=network,
    verbose=True,
)

data = load_cifar10(center=True, rescale=True)
# data = load_cifar10_record(BATCH_SIZE)
info = solver.train(data)

identifier = 'dropping-out-mlp-%d-%d' % (N_LAYERS, N_HIDDEN_UNITS)
pickle.dump(info, open('info/%s' % identifier, 'wb'))
parameters = solver.export_parameters()
pickle.dump(parameters, open('parameters/%s' % identifier, 'wb'))
network = layers.fully_connected(X=network, n_hidden_units=10)
network = layers.softmax_loss(prediction=network, normalization='batch', id='softmax')

BATCH_SIZE = 128
lr = 0.1
lr_table = {32000 : lr * 0.1, 48000 : lr * 0.01}
lr_scheduler = AtIterationScheduler(lr, lr_table)

optimizer_settings = {
  'args'         : {'momentum' : 0.9},
  'initial_lr'   : lr,
  'lr_scheduler' : lr_scheduler,
  'optimizer'    : 'SGD',
  'weight_decay' : 0.0001,
}

solver = MXSolver(
  batch_size = BATCH_SIZE,
  devices = (0, 1, 2, 3),
  epochs = 150,
  initializer = PReLUInitializer(),
  optimizer_settings = optimizer_settings,
  symbol = network,
  verbose = True,
)

data = load_cifar10_record(BATCH_SIZE)
info = solver.train(data)
identifier = 'cifar-residual-network-%d-%s-transition' % (N, mode)
pickle.dump(info, open('info/%s' % identifier, 'wb'))
Esempio n. 6
0
optimizer_settings = {
    'args': {
        '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
}