Esempio n. 1
0
def initialize_model_from_local(path,
                                hparams,
                                de_tokenize=False,
                                verbose=False):
    start = time.time()

    conn = sqlite3.connect(path)
    c = conn.cursor()
    v = Vocabulary(max_len=hparams['MAX_LEN'])
    v.load_vocab_from_local(c, hparams['VOCAB'], verbose)
    c.close()
    conn.close()

    if de_tokenize: v.de_tokenize_data()
    if verbose: print('Vocabulary created!')

    enc, dec, opt = create_model(hparams)

    print('Time to initialize model {:.2f} min | {:.2f} hrs\n'.format(
        (time.time() - start) / 60, (time.time() - start) / 3600))
    return v, enc, dec, opt