5527c532288b90c6a52c3bab08a2832984d2d96c,classification/train_classifier.py,,eval_model,#Any#Any#Any#Any#,64
Before Change
cnt = 0
total_loss = 0.0
for x, y in zip(valid_x, valid_y):
x, y = Variable(x, volatile=True), Variable(y)
output = model(x)
loss = criterion(output, y)
total_loss += loss.item()*x.size(1)
pred = output.data.max(1)[1]
After Change
return self.out(output)
def eval_model(niter, model, valid_x, valid_y):
with torch.no_grad():
model.eval()
N = len(valid_x)
criterion = nn.CrossEntropyLoss()
correct = 0.0
cnt = 0
total_loss = 0.0
for x, y in zip(valid_x, valid_y):
output = model(x)
loss = criterion(output, y)
total_loss += loss.item()*x.size(1)
pred = output.data.max(1)[1]
correct += pred.eq(y).sum().item()
cnt += y.numel()
model.train()
return 1.0-correct/cnt
def train_model(epoch, model, optimizer,
train_x, train_y, valid_x, valid_y,
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 3
Instances
Project Name: asappresearch/sru
Commit Name: 5527c532288b90c6a52c3bab08a2832984d2d96c
Time: 2019-10-22
Author: tao@asapp.com
File Name: classification/train_classifier.py
Class Name:
Method Name: eval_model
Project Name: keras-team/keras
Commit Name: 7c84229f350b83ce397b8c65e52e333e99b6d19d
Time: 2019-03-04
Author: francois.chollet@gmail.com
File Name: keras/backend/tensorflow_backend.py
Class Name:
Method Name: variable
Project Name: asappresearch/sru
Commit Name: 2c757bdbd35f07b2bb44cd21ff9124ccf008fe1e
Time: 2019-10-22
Author: tao@asapp.com
File Name: classification/train_classifier.py
Class Name:
Method Name: eval_model