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)

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: 9

Instances


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


Project Name: bearpaw/pytorch-pose
Commit Name: dc9a7266ed6693f9a835ab411f85fa56e77065a8
Time: 2017-06-14
Author: platero.yang@gmail.com
File Name: example/mpii.py
Class Name:
Method Name: train