Commit da67a1e9 authored by Holger Kohr's avatar Holger Kohr Committed by Francisco Massa
Browse files

Partially revert #519 due to performance regression & other issues (#521)

parent cf65f394
...@@ -652,7 +652,7 @@ class Tester(unittest.TestCase): ...@@ -652,7 +652,7 @@ class Tester(unittest.TestCase):
# Checking if RandomHorizontalFlip can be printed as string # Checking if RandomHorizontalFlip can be printed as string
transforms.RandomHorizontalFlip().__repr__() transforms.RandomHorizontalFlip().__repr__()
@unittest.skipIf(stats is None, 'scipt.stats is not available') @unittest.skipIf(stats is None, 'scipy.stats is not available')
def test_normalize(self): def test_normalize(self):
def samples_from_standard_normal(tensor): def samples_from_standard_normal(tensor):
p_value = stats.kstest(list(tensor.view(-1)), 'norm', args=(0, 1)).pvalue p_value = stats.kstest(list(tensor.view(-1)), 'norm', args=(0, 1)).pvalue
......
...@@ -167,9 +167,10 @@ def normalize(tensor, mean, std): ...@@ -167,9 +167,10 @@ def normalize(tensor, mean, std):
if not _is_tensor_image(tensor): if not _is_tensor_image(tensor):
raise TypeError('tensor is not a torch image.') raise TypeError('tensor is not a torch image.')
mean = torch.Tensor(mean).view((tensor.shape[0], 1, 1)) # This is faster than using broadcasting, don't change without benchmarking
std = torch.Tensor(std).view((tensor.shape[0], 1, 1)) for t, m, s in zip(tensor, mean, std):
return tensor.sub_(mean).div_(std) t.sub_(m).div_(s)
return tensor
def resize(img, size, interpolation=Image.BILINEAR): def resize(img, size, interpolation=Image.BILINEAR):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment