5c177f3d9a29fc7737bd4734315820d1c11c7e87,cnn_text_classification.py,CNNClassifier,predict,#CNNClassifier#,156

Before Change


    def predict(self, X):
        y_pred = []

        for text in X:
            assert isinstance(text, str)

            text = self.__pad(self.__text_field.preprocess(text), True)

            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()
        return y_pred

    def __pad(self, x, preprocessed=False):

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)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 6

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: chuyangliu/snake
Commit Name: 1226a2eee68336240a35fce9678320ca9430584f
Time: 2018-01-06
Author: chuyang.s.liu@gmail.com
File Name: snake/solver/dqn.py
Class Name: DQNSolver
Method Name: __choose_action


Project Name: pytorch/tnt
Commit Name: ba256835a4f33d9139a70b6440c3223123132bc8
Time: 2017-08-24
Author: swetha.tanamala@gmail.com
File Name: torchnet/meter/confusionmeter.py
Class Name: ConfusionMeter
Method Name: add


Project Name: scikit-learn-contrib/DESlib
Commit Name: 1002cfbcc9f8182404fb058f959d625de2eabbfc
Time: 2018-03-22
Author: rafaelmenelau@gmail.com
File Name: deslib/dcs/rank.py
Class Name: Rank
Method Name: estimate_competence