f31488d65a98107e03f2045f3c5e2f927dab067d,03-wordemb-pytorch/wordemb-cbow.py,,calc_sent_loss,#,71
Before Change
t = torch.tensor([padded_sent[i]]).type(type) // This is the target vector
log_prob = model(c)
loss = criterion(log_prob, t) // loss for predicting target from context vector
if not inference:
// Back prop while training only
optimizer.zero_grad()
loss.backward()
optimizer.step()
total_loss += loss.data.cpu().item()
return total_loss
After Change
t = torch.tensor([padded_sent[i]]).type(type) // This is the target vector
logits = model(c)
loss = criterion(logits, t) // loss for predicting target from context vector
losses.append(loss)
return torch.stack(losses).sum()
MAX_LEN = 100
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 3
Instances Project Name: neubig/nn4nlp-code
Commit Name: f31488d65a98107e03f2045f3c5e2f927dab067d
Time: 2019-01-18
Author: mysteryvaibhav@gmail.com
File Name: 03-wordemb-pytorch/wordemb-cbow.py
Class Name:
Method Name: calc_sent_loss
Project Name: Kaixhin/Rainbow
Commit Name: 5ec418e8146079d6797bb15b0f5e777862815df6
Time: 2018-05-07
Author: design@kaixhin.com
File Name: env.py
Class Name: Env
Method Name: reset
Project Name: neubig/nn4nlp-code
Commit Name: f31488d65a98107e03f2045f3c5e2f927dab067d
Time: 2019-01-18
Author: mysteryvaibhav@gmail.com
File Name: 03-wordemb-pytorch/wordemb-skip.py
Class Name:
Method Name: calc_sent_loss