5c177f3d9a29fc7737bd4734315820d1c11c7e87,cnn_text_classification.py,CNNClassifier,predict,#CNNClassifier#Any#,156
Before Change
self.__model.eval()
text = [[self.__text_field.vocab.stoi[x] for x in text]]
x = Variable(torch.tensor(text))
x = x.cuda() if self.cuda and torch.cuda.is_available() else x
_, predicted = torch.max(self.__model(x), 1)
y_pred.append(self.__label_field.vocab.itos[predicted.data[0] + 1])
torch.cuda.empty_cache()
After Change
return y_output
def predict(self, X):
y_pred = [torch.argmax(yi, 1) for yi in self.__predict(X)]
return [self.__label_field.vocab.itos[yi.data[0] + 1] for yi in y_pred]
def predict_proba(self, X):
softmax = nn.Softmax(dim=1)
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 5
Instances Project Name: Shawn1993/cnn-text-classification-pytorch
Commit Name: 5c177f3d9a29fc7737bd4734315820d1c11c7e87
Time: 2019-07-17
Author: rriva002@ucr.edu
File Name: cnn_text_classification.py
Class Name: CNNClassifier
Method Name: predict
Project Name: IndicoDataSolutions/Enso
Commit Name: 7f46b2274cb8958441b1236e8fd7ac39d546a732
Time: 2017-12-13
Author: maritza@mylestone.com
File Name: enso/sample/__init__.py
Class Name: KCenter
Method Name: sample
Project Name: biocore/scikit-bio
Commit Name: 25ba1b21813a346b303adf045b88803d70ed90fe
Time: 2015-11-30
Author: mcdonadt@colorado.edu
File Name: skbio/tree/_tree.py
Class Name: TreeNode
Method Name: _set_max_distance