コード例 #1
0
    # no need after optimized num_boost_round
    del optimal_c_model.params['early_stopping_rounds']
    return optimal_c_model


if __name__ == "__main__":
    gc.enable()
    warnings.filterwarnings('ignore')

    # read config & apply option
    c = EasyDict(config)
    opt = parse_option()
    c.transformer.USE_SMALL_DATA = opt.small
    c.log.slackauth.NO_SEND_MESSAGE = opt.nomsg

    seed_everything(c.runtime.RANDOM_SEED)

    create_logger('main', **c.log)
    logger = getLogger('main')
    logger.info(
        f':thinking_face: Starting experiment {c.runtime.VERSION}_{c.runtime.DESCRIPTION}'
    )

    try:
        main(c)
        logger.info(
            f':sunglasses: Finished experiment {c.runtime.VERSION}_{c.runtime.DESCRIPTION}'
        )
    except Exception:
        logger.critical(
            f':smiling_imp: Exception occured \n {traceback.format_exc()}')
コード例 #2
0
    c = json.load(open(f'config/config_{opt.version}.json'))
    c = EasyDict(c)
    c.runtime = {}
    c.runtime.version = opt.version
    c.runtime.use_small_data = opt.small
    c.runtime.no_send_message = opt.nomsg
    c.runtime.random_seed = opt.seed
    c.runtime.dsize = '.small' if c.runtime.use_small_data is True else ''

    # dict to save results
    r = EasyDict()
    r.update(c)
    r.paths = {}
    r.paths.result = f'config/result_{c.runtime.version}{c.runtime.dsize}.json'

    seed_everything(c.runtime.random_seed)

    # check config.experiment_type
    if c.experiment_type != experiment_type:
        raise ValueError(
            f'experiment_type in config: {c.experiment_type} does not match this script'
        )

    # start logging
    r.paths.main_log_path = f'log/main_{c.runtime.version}{c.runtime.dsize}.log'
    r.paths.train_log_path = f'log/train_{c.runtime.version}{c.runtime.dsize}.tsv'
    slackauth = EasyDict(json.load(open('./slackauth.json', 'r')))
    slackauth.token_path = Path().home() / slackauth.token_file
    create_logger('main',
                  version=c.runtime.version,
                  log_path=r.paths.main_log_path,