#!/usr/local/bin/python
from Model import Model
from Executor import Executor


if __name__ == '__main__':
    model = Model()
    model.assemble_graph()

    silence_step = 0
    skip_step = 20

    exe = Executor(model, silence_step=silence_step, skip_step=skip_step)

    exe.train_and_dev()
    exe.restore_and_test()
Beispiel #2
0
if __name__ == '__main__':
    seed = 12345
    random.seed(seed)
    np.random.seed(seed)
    torch.manual_seed(seed)
    n_gpu = torch.cuda.device_count()
    torch.backends.cudnn.deterministic = True
    torch.backends.cudnn.benchmark = False

    if n_gpu > 0:
        torch.cuda.manual_seed(seed)

    silence_step = 0  # 从哪步开始可以进行evaluate
    skip_step = 20  # 每隔多少步做evaluate
    config = DicToObj(**config_model)
    formatter = '%(asctime)s %(levelname)s %(message)s'
    config = generate_name_path(config, path_parser)

    train_logger = Logger(filename=config.saved_path + '/train.log',
                          fmt=formatter).logger
    tb_logger = Tensorboard_Logger(config.saved_path)
    exe = Executor(model_name="stocknet",
                   config=config,
                   silence_step=silence_step,
                   skip_step=skip_step,
                   train_logger=train_logger,
                   tb_logger=tb_logger)
    exe.apply(xavier_init)
    exe.train_and_dev(do_continue=False)
    exe.restore_and_test()