13bbee615c87c812ddcfff73746cd504222e3fb0,tools/extract_embeddings.py,,main,#,28

Before Change


    src_dict = checkpoint["dicts"]["src"]
    tgt_dict = checkpoint["dicts"]["tgt"]

    emb_opts = {"src_word_vec_size": model_opt.src_word_vec_size,
                "position_encoding": model_opt.position_encoding,
                "feat_merge": model_opt.feat_merge,
                "feat_vec_exponent": model_opt.feat_vec_exponent,
                "feat_vec_size": model_opt.feat_vec_size}
    cuda = (len(model_opt.gpuid) > 0)
    encoder = onmt.Models.Encoder(model_opt.encoder_type, model_opt.brnn,
                                  model_opt.rnn_type, model_opt.enc_layers,
                                  model_opt.rnn_size, model_opt.dropout,

After Change


    if opt.cuda:
        torch.cuda.set_device(opt.gpu)

    model_opt = checkpoint["opt"]
    src_dict = checkpoint["dicts"]["src"]
    tgt_dict = checkpoint["dicts"]["tgt"]

    cuda = (len(model_opt.gpuid) > 0)
    embeddings = onmt.Models.build_embeddings(
                model_opt, src_dict.stoi[onmt.IO.PAD_WORD],
                len(src_dict), for_encoder=True)
    encoder = onmt.Models.Encoder(model_opt.encoder_type, model_opt.brnn,
                                  model_opt.rnn_type, model_opt.enc_layers,
                                  model_opt.rnn_size, model_opt.dropout,
                                  cuda, embeddings)
    embeddings = onmt.Models.build_embeddings(
                model_opt, tgt_dict.stoi[onmt.IO.PAD_WORD],
                len(tgt_dict), for_encoder=False)
    decoder = onmt.Models.Decoder(model_opt, cuda, embeddings)
    encoder_embeddings = encoder.word_lut.weight.data.tolist()
    decoder_embeddings = decoder.word_lut.weight.data.tolist()
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 15

Instances


Project Name: OpenNMT/OpenNMT-py
Commit Name: 13bbee615c87c812ddcfff73746cd504222e3fb0
Time: 2017-08-30
Author: nasa4836@gmail.com
File Name: tools/extract_embeddings.py
Class Name:
Method Name: main


Project Name: OpenNMT/OpenNMT-py
Commit Name: 13bbee615c87c812ddcfff73746cd504222e3fb0
Time: 2017-08-30
Author: nasa4836@gmail.com
File Name: tools/extract_embeddings.py
Class Name:
Method Name: main


Project Name: OpenNMT/OpenNMT-py
Commit Name: 13bbee615c87c812ddcfff73746cd504222e3fb0
Time: 2017-08-30
Author: nasa4836@gmail.com
File Name: test/test_models.py
Class Name: TestModel
Method Name: encoder_forward


Project Name: OpenNMT/OpenNMT-py
Commit Name: 13bbee615c87c812ddcfff73746cd504222e3fb0
Time: 2017-08-30
Author: nasa4836@gmail.com
File Name: onmt/Models.py
Class Name:
Method Name: make_base_model