1db3e4b5d647adef9811fa74ab8c6bf3638ade62,onmt/Translator.py,Translator,__init__,#Translator#Any#,7
Before Change
self.tt = torch.cuda if opt.cuda else torch
checkpoint = torch.load(opt.model)
self.model = checkpoint["model"]
self.model.eval()
if opt.cuda:
self.model.cuda()
else:
self.model.cpu()
self.src_dict = checkpoint["dicts"]["src"]
After Change
decoder = onmt.Models.Decoder(model_opt, self.tgt_dict)
model = onmt.Models.NMTModel(encoder, decoder)
generator = nn.Sequential(
nn.Linear(model_opt.rnn_size, self.tgt_dict.size()),
nn.LogSoftmax())
model.load_state_dict(checkpoint["model"])
generator.load_state_dict(checkpoint["generator"])
if opt.cuda:
model.cuda()
generator.cuda()
else:
model.cpu()
generator.cpu()
model.generator = generator
self.model = model
self.model.eval()
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 12
Instances
Project Name: OpenNMT/OpenNMT-py
Commit Name: 1db3e4b5d647adef9811fa74ab8c6bf3638ade62
Time: 2017-03-14
Author: bryan.mccann.is@gmail.com
File Name: onmt/Translator.py
Class Name: Translator
Method Name: __init__
Project Name: pytorch/examples
Commit Name: 988ee51b15466231e9770f46dcb4d221866322a7
Time: 2017-03-14
Author: bryan.mccann.is@gmail.com
File Name: OpenNMT/onmt/Translator.py
Class Name: Translator
Method Name: __init__
Project Name: zhanghang1989/PyTorch-Encoding
Commit Name: 8f8fbb9f6543a4ccaad53923d33647e7138d95ea
Time: 2017-10-15
Author: zhang.hang@rutgers.edu
File Name: encoding/parallel.py
Class Name: ModelDataParallel
Method Name: __init__
Project Name: OpenNMT/OpenNMT-py
Commit Name: 1db3e4b5d647adef9811fa74ab8c6bf3638ade62
Time: 2017-03-14
Author: bryan.mccann.is@gmail.com
File Name: onmt/Translator.py
Class Name: Translator
Method Name: __init__