cf7ed441052a1514bc7747661011944043d95206,inferno/io/transform/generic.py,AsTorchBatch,tensor_function,#AsTorchBatch#Any#,153
Before Change
def tensor_function(self, tensor):
assert isinstance(tensor, np.ndarray)
if self.dimensionality == 3:
// We"re dealing with a volume. tensor can either be 3D or 4D
assert tensor.ndim in [3, 4]
if tensor.ndim == 3 and self.add_channel_axis_if_necessary:
// Add channel axis
return torch.from_numpy(tensor[None, ...])
else:
// Channel axis is in already
return torch.from_numpy(tensor)
elif self.dimensionality == 2:
// We"re dealing with an image. tensor can either be 2D or 3D
assert tensor.ndim in [2, 3]
if tensor.ndim == 2 and self.add_channel_axis_if_necessary:
// Add channel axis
return torch.from_numpy(tensor[None, ...])
else:
// Channel axis is in already
return torch.from_numpy(tensor)
elif self.dimensionality == 1:
// We"re dealing with a vector - it has to be 1D
assert tensor.ndim == 1
return torch.from_numpy(tensor)
else:
raise NotImplementedError
After Change
raise NotImplementedError
def tensor_function(self, tensor):
assert isinstance(tensor, (list, np.ndarray)), "Expected numpy array or list, got %s" % type(tensor)
if isinstance(tensor, np.ndarray):
return self._to_batch(tensor)
else:
return [self._to_batch(elem) for elem in tensor]
In pattern: SUPERPATTERN
Frequency: 4
Non-data size: 8
Instances
Project Name: inferno-pytorch/inferno
Commit Name: cf7ed441052a1514bc7747661011944043d95206
Time: 2018-08-14
Author: constantin.pape@iwr.uni-heidelberg.de
File Name: inferno/io/transform/generic.py
Class Name: AsTorchBatch
Method Name: tensor_function
Project Name: pgmpy/pgmpy
Commit Name: 88e39c57186f9ed2ff4b562ecd9ffe468bc46320
Time: 2016-02-19
Author: mail@chrisittner.de
File Name: pgmpy/independencies/Independencies.py
Class Name: IndependenceAssertion
Method Name: __eq__
Project Name: pantsbuild/pants
Commit Name: dac3c9a5f4743bd0b38fd37e887d257f2ae73d41
Time: 2016-04-13
Author: stuhood@gmail.com
File Name: src/python/pants/engine/exp/nodes.py
Class Name: FilesystemNode
Method Name: step
Project Name: GoogleCloudPlatform/PerfKitBenchmarker
Commit Name: d6ef26173d1f2e65ec65570683e8ca43d054c8d4
Time: 2016-09-20
Author: nlavine@google.com
File Name: perfkitbenchmarker/providers/azure/azure_disk.py
Class Name: AzureDisk
Method Name: _Exists