8a70c277c355fe734a01fe58baafdc2dc5164205,OpenNMT/train.py,,eval,#Any#Any#Any#,122

Before Change


    loss = 0

    model.eval()
    for src, tgt in data:
        outputs = model.forward(src)
        loss = criterion.forward(outputs, tgt)

    model.train()
    return math.exp(loss / data.len)


def trainModel(model, trainData, validData, dataset):
    print(model)

After Change


    total_words = 0

    model.eval()
    for i in range(len(data)):
        batch = data[i]
        outputs = model(batch)
        loss = criterion(outputs, batch[1])
        total_loss += loss.data[0]
        total_words += batch[1].data.gt(onmt.Constants.EOS).sum()

    model.train()
    return total_loss / total_words

Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: pytorch/examples
Commit Name: 8a70c277c355fe734a01fe58baafdc2dc5164205
Time: 2016-12-29
Author: alerer@fb.com
File Name: OpenNMT/train.py
Class Name:
Method Name: eval


Project Name: pytorch/tutorials
Commit Name: 3128e13109c8766eafb413f2428bba976701e929
Time: 2020-12-02
Author: 6156351+zhangguanheng66@users.noreply.github.com
File Name: beginner_source/transformer_tutorial.py
Class Name:
Method Name:


Project Name: OpenNMT/OpenNMT-py
Commit Name: 8a70c277c355fe734a01fe58baafdc2dc5164205
Time: 2016-12-29
Author: alerer@fb.com
File Name: OpenNMT/train.py
Class Name:
Method Name: eval