Пример #1
0
def train(train_cfg, model_cfg, common_cfg, dataflow):
    epochs = train_cfg.epochs
    assert epochs, epochs
    epoch_size = train_cfg.epoch_size
    assert epoch_size, epoch_size
    config = TrainConfig(
        model=ModelWrapSingle(train_cfg, model_cfg, common_cfg),
        dataflow=dataflow,
        #data=my_inputsource, # alternatively, use a customized InputSource
        #callbacks=[...],    # some default callbacks are automatically applied
        # some default monitors are automatically applied
        steps_per_epoch=
        epoch_size,  # default to the size of your InputSource/DataFlow
        max_epoch=epochs)
    print("Create trainer")
    trainer = SimpleTrainer()
    print("Run train")
    launch_train_with_config(config, trainer)
Пример #2
0
                                screen_dims=IMAGE_SIZE,
                                spacing=SPACING)
    NUM_ACTIONS = init_player.action_space.n
    num_validation_files = init_player.files.num_files

    if args.task != 'train':
        assert args.load is not None
        pred = OfflinePredictor(PredictConfig(
            model=Model(),
            session_init=get_model_loader(args.load),
            input_names=['state'],
            output_names=['Qvalue']))
        if args.task == 'play':
            t0 = time.time()
            play_n_episodes(get_player(directory=data_dir,
                                       files_list=test_list, viz=0.01,
                                       saveGif=args.saveGif,
                                       saveVideo=args.saveVideo),
                            pred, num_validation_files)

            t1 = time.time()
            print(t1-t0)
        elif args.task == 'eval':
            eval_model_multithread(pred, EVAL_EPISODE, get_player)
    else:
        logger.set_logger_dir(logger_dir) # todo: variable log dir
        config = get_config()
        if args.load:
            config.session_init = get_model_loader(args.load)
        launch_train_with_config(config, SimpleTrainer())
Пример #3
0
            # prevent learning in the first epoch
            # MemInitHyperParamSetter('learning_rate_mask',(0,1)),
            # controls learning rate as a function of epoch
            HyperParamSetterWithFunc('learning_rate', learning_rate_fun),
            # GraphProfiler()
            # PeakMemoryTracker()
            # GPUUtilizationTracker(),
        ],
        steps_per_epoch=steps_per_epoch,
        max_epoch=200000,
        # first time load model from checkpoint and reset GRU state
        session_init=ChainInit([TryResumeTraining()]),  #,ResetInit(model)])
        # session_config=tf.ConfigProto(log_device_placement=True) #config_gpus(1)
    )

    trainer = SimpleTrainer()
    # with tf.contrib.tfprof.ProfileContext(logger.get_logger_dir()) as pctx:
    launch_train_with_config(traincfg, trainer)

################# JUNK ###############

# config = tf.ConfigProto(gpu_options=tf.GPUOptions(allow_growth=True))
# workaround
# with tf.Session(config=config):
#     pass

# Pin = tf.placeholder(tf.float32, shape=P_py.shape)
# backp = Backproj(vlen, 10.0, 'c3')
# l = backp.score(Pin)

# class Invert(Can):