Esempio n. 1
0
 def restore(self, **solver_args):
     """
     Restore from a previous restore point fixed via set_restore_point
     
     If set_restore_point was not previously called, restores the
     state of the solver from when it was initialised.
     
     Optionally, one or more keyword arguments may be supplied, which
     then override the arguments used to restore the solver, when
     recreating the solver via solver.create .
     """
     restore_args = dict(self.restore_args)
     restore_args.update(solver_args)
    
     self._last_p_0 = restore_args['p_0']
     self.solver = solver.create(
         self.model,
         self.sink,
         **restore_args
     )
def create_jobs():
    Net.Params = {
        'model_name': job_name,
        'train_lmdb': train_lmdb,
        'test_lmdb': test_lmdb,
        'mean_file': mean_file,
        'batch_size_per_device': 128,
        'test_batch_size': 50,
        'num_classes': 2,
        'num_test_image': 1000,
    }

    # train/test/deploy.prototxt
    for phase in ['train', 'test', 'deploy']:
        proto_file = os.path.join(job_dir, '{}.prototxt'.format(phase))
        with open(proto_file, 'w') as f:
            print(Net.create_net(phase), file=f)

    # solver.prototxt
    Solver.Params['train_net'] = os.path.join(job_dir, 'train.prototxt')
    Solver.Params['test_net'] = [os.path.join(job_dir, 'test.prototxt')]
    Solver.Params['snapshot_prefix'] = os.path.join(job_dir, job_name)
    Solver.Params['base_lr'] = 0.01
    Solver.Params['test_iter'] = [Net.get_testiter()]
    Solver.Params['test_interval'] = 2500
    Solver.Params['stepsize'] = 30000
    Solver.Params['weight_decay'] = 0.008
    Solver.Params['momentum'] = 0.9
    Solver.Params['max_iter'] = 400000
    Solver.Params['snapshot'] = 50000
    Solver.Params['display'] = 500
    Solver.Params['lr_policy'] = 'step'

    solver_file = os.path.join(job_dir, 'solver.prototxt')
    with open(solver_file, 'w') as f:
        print(Solver.create(), file=f)