Пример #1
0
                raise Exception
    except :
        log.exception('####################')
        trainer.save_best_model()

        return locals()



    
import sys
import pickle
if __name__ == '__main__':

    if sys.argv[1]:
        log.addFilter(CMDFilter(sys.argv[1]))

    if Config.flush:
        log.info('flushing...')
        ids = tuple((Sample._fields.index('id'),))
        dataset, vocabulary = load_squad_data('dataset/train-v1.1.json', ids)
        pickle.dump([dataset, dict(vocabulary)], open('train.squad', 'wb'))
    else:
        dataset, _vocabulary = pickle.load(open('train.squad', 'rb'))
        vocabulary = defaultdict(int)
        vocabulary.update(_vocabulary)
        
    log.info('dataset size: {}'.format(len(dataset)))
    log.info('dataset[:10]: {}'.format(pformat(dataset[0])))
    log.info('vocabulary: {}'.format(
        pformat(
Пример #2
0
    predict_parser.add_argument('--length',
                                default=10,
                                dest='prediction_length')

    predict_parser.add_argument('--show-plot',
                                action='store_true',
                                dest='show_plot')
    predict_parser.add_argument('--save-plot',
                                action='store_true',
                                dest='save_plot')
    predict_parser.add_argument('--uniqueness', default=50, dest='beam_width')

    args = parser.parse_args()
    print(args)
    if args.log_filter:
        log.addFilter(CMDFilter(args.log_filter))

    ########################################################################################
    # anikattu initialization for directory structure and so on
    ########################################################################################
    ROOT_DIR = initialize_task(args.hpconfig, args.prefix_dir)

    sys.path.append('.')
    print(sys.path)
    HPCONFIG = importlib.__import__(args.hpconfig.replace('.py', ''))
    config.HPCONFIG = HPCONFIG.CONFIG
    config.ROOT_DIR = ROOT_DIR
    config.NAME = SELF_NAME
    print('====================================')
    print(ROOT_DIR)
    print('====================================')