bbfbfce5c8c18b39d541d912ffb11182f7d06dfd,allennlp/modules/similarity_functions/linear.py,LinearSimilarity,forward,#LinearSimilarity#Any#Any#,58
Before Change
else:
view_args = [-1] + list(combined_tensors.size()[-2:])
reshaped_tensor = combined_tensors.view(*view_args)
unsqueezed_weight = self._weight_vector.unsqueeze(1).unsqueeze(0)
reshaped_weight = unsqueezed_weight.expand(reshaped_tensor.size()[0],
self._weight_vector.size()[0],
1)
reshaped_dot_product = reshaped_tensor.bmm(reshaped_weight)
view_args = combined_tensors.size()[:-1]
dot_product = reshaped_dot_product.view(*view_args)
return self._activation(dot_product + self._bias.expand_as(dot_product)).squeeze(dim=-1)
After Change
@overrides
def forward(self, tensor_1: torch.Tensor, tensor_2: torch.Tensor) -> torch.Tensor:
combined_tensors = self._combine_tensors(tensor_1, tensor_2)
dot_product = torch.matmul(combined_tensors, self._weight_vector)
return self._activation(dot_product + self._bias)
def _combine_tensors(self, tensor_1: torch.Tensor, tensor_2: torch.Tensor) -> torch.Tensor:
combined_tensor = self._get_combination(self._combinations[0], tensor_1, tensor_2)
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 3
Instances
Project Name: allenai/allennlp
Commit Name: bbfbfce5c8c18b39d541d912ffb11182f7d06dfd
Time: 2017-08-06
Author: markn@allenai.org
File Name: allennlp/modules/similarity_functions/linear.py
Class Name: LinearSimilarity
Method Name: forward
Project Name: cornellius-gp/gpytorch
Commit Name: a7a12d157766b69cf4b1ddbb5fcdacfe485dc6fa
Time: 2019-04-03
Author: gpleiss@gmail.com
File Name: test/kernels/test_linear_kernel.py
Class Name: TestLinearKernel
Method Name: test_computes_linear_function_square_batch
Project Name: cornellius-gp/gpytorch
Commit Name: 91b0d220c8e816766fd4565e1d2f5115d3afbefe
Time: 2018-10-12
Author: gpleiss@gmail.com
File Name: gpytorch/lazy/lazy_tensor.py
Class Name: LazyTensor
Method Name: evaluate