f9b5b2395e4fb5a95e93af0c06d4918ee8410b7a,tools/extract_embeddings.py,,main,#,28

Before Change


    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, embeddings)
    encoder_embeddings = encoder.word_lut.weight.data.tolist()
    decoder_embeddings = decoder.word_lut.weight.data.tolist()

    print("Writing source embeddings")

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"]

    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,
                                  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.decoder_type, model_opt.rnn_type,
                                  model_opt.dec_layers, model_opt.rnn_size,
                                  model_opt.input_feed,
                                  model_opt.global_attention,
                                  model_opt.coverage_attn,
                                  model_opt.context_gate,
                                  model_opt.copy_attn,
                                  model_opt.dropout, 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: 12

Instances


Project Name: OpenNMT/OpenNMT-py
Commit Name: f9b5b2395e4fb5a95e93af0c06d4918ee8410b7a
Time: 2017-09-06
Author: nasa4836@gmail.com
File Name: tools/extract_embeddings.py
Class Name:
Method Name: main


Project Name: OpenNMT/OpenNMT-py
Commit Name: f9b5b2395e4fb5a95e93af0c06d4918ee8410b7a
Time: 2017-09-06
Author: nasa4836@gmail.com
File Name: onmt/Models.py
Class Name:
Method Name: make_base_model


Project Name: OpenNMT/OpenNMT-py
Commit Name: f9b5b2395e4fb5a95e93af0c06d4918ee8410b7a
Time: 2017-09-06
Author: nasa4836@gmail.com
File Name: test/test_models.py
Class Name: TestModel
Method Name: ntmmodel_forward


Project Name: OpenNMT/OpenNMT-py
Commit Name: f9b5b2395e4fb5a95e93af0c06d4918ee8410b7a
Time: 2017-09-06
Author: nasa4836@gmail.com
File Name: tools/extract_embeddings.py
Class Name:
Method Name: main