857e36921ab5ca51c919839ec0b6e87585160d0c,onmt/decoders/ensemble.py,,load_test_model,#Any#Any#,119

Before Change


    shared_fields = None
    shared_model_opt = None
    models = []
    for model_path in opt.models:
        fields, model, model_opt = \
            onmt.model_builder.load_test_model(opt,
                                               dummy_opt,
                                               model_path=model_path)
        if shared_fields is None:
            shared_fields = fields
        else:
            for key, field in fields.items():
                if field is not None and "vocab" in field.__dict__:
                    assert field.vocab.stoi == shared_fields[key].vocab.stoi, \
                        "Ensemble models must use the same preprocessed data"
        models.append(model)
        if shared_model_opt is None:
            shared_model_opt = model_opt
    ensemble_model = EnsembleModel(models, opt.avg_raw_probs)
    return shared_fields, ensemble_model, shared_model_opt

After Change


class EnsembleGenerator(nn.Module):
    
    Dummy Generator that delegates to individual real Generators,
    and then averages the resulting target distributions.
    
    def __init__(self, model_generators, raw_probs=False):
        super(EnsembleGenerator, self).__init__()
        self.model_generators = nn.ModuleList(model_generators)
        self._raw_probs = raw_probs

    def forward(self, hidden, attn=None, src_map=None):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: OpenNMT/OpenNMT-py
Commit Name: 857e36921ab5ca51c919839ec0b6e87585160d0c
Time: 2019-02-14
Author: dylan.flaute@gmail.com
File Name: onmt/decoders/ensemble.py
Class Name:
Method Name: load_test_model


Project Name: OpenNMT/OpenNMT-py
Commit Name: 90e5b974a7173ab0bba0990a690e32f25f5b725a
Time: 2019-01-14
Author: benzurdopeters@gmail.com
File Name: tools/embeddings_to_torch.py
Class Name:
Method Name: get_vocabs


Project Name: OpenNMT/OpenNMT-py
Commit Name: bc1351d47d9fe83bc6c7830a8563ddb874953ed4
Time: 2019-01-09
Author: benzurdopeters@gmail.com
File Name: onmt/train_single.py
Class Name:
Method Name: main