971100f9204a869a28bf57e4ec7c780376d88e9e,allennlp/models/simple_tagger.py,SimpleTagger,tag,#SimpleTagger#Any#,98

Before Change


        // TODO(Mark): Generalise how the array is transformed into a variable after settling the data API.
        // Add a batch dimension by unsqueezing, because pytorch
        // doesn"t support inputs without one.
        array_input = {"tokens": torch.autograd.Variable(torch.LongTensor(array_input["tokens"])).unsqueeze(0)}
        output_dict = self.forward(tokens=array_input)

        // Remove batch dimension, as we only had one input.

After Change


        // TODO(Mark): Make the data API always return tensors with batch dimensions at every abstraction level.
        // Add a batch dimension by unsqueezing, because pytorch doesn"t support inputs without one.
        model_input = arrays_to_variables(array_input)
        model_input["tokens"].data.unsqueeze_(0)
        output_dict = self.forward(tokens=model_input)

        // Remove batch dimension, as we only had one input.
        predictions = output_dict["class_probabilities"].data.squeeze(0)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 2

Instances


Project Name: allenai/allennlp
Commit Name: 971100f9204a869a28bf57e4ec7c780376d88e9e
Time: 2017-08-01
Author: markn@allenai.org
File Name: allennlp/models/simple_tagger.py
Class Name: SimpleTagger
Method Name: tag


Project Name: catalyst-team/catalyst
Commit Name: d3f12d1622f736e649fcec853044b05fe68e05ba
Time: 2019-07-07
Author: scitator@gmail.com
File Name: catalyst/rl/onpolicy/algorithms/ppo.py
Class Name: PPO
Method Name: train


Project Name: cornellius-gp/gpytorch
Commit Name: e503f50cb38fb1864fb6d66ba927b0852159428d
Time: 2017-09-22
Author: gpleiss@gmail.com
File Name: gpytorch/utils/toeplitz.py
Class Name:
Method Name: index_coef_to_sparse