Skip to content
Snippets Groups Projects
Commit aef26edf authored by Guillaume HEUSCH's avatar Guillaume HEUSCH
Browse files

[normalizer] corrected the division by zero bug, removed the loop over the...

[normalizer] corrected the division by zero bug, removed the loop over the minibatch (done in Memory.py)
parent 414e622b
No related branches found
No related tags found
1 merge request!8Gan
Pipeline #
......@@ -59,12 +59,13 @@ class MinusOneOne(object):
def __call__(self, x):
target_min = -1
target_max = 1
for j in range(x.shape[0]):
for i in range(x.shape[3]):
mini = numpy.min(x[j, :, :, i])
maxi = numpy.max(x[j, :, :, i])
x[j, :, :, i] = (x[j, :, :, i] - mini) * (target_max - target_min) / (maxi - mini) + target_min
#print "new min -> {0}".format(numpy.min(x[j, :, :, i]))
#print "new max -> {0}".format(numpy.max(x[j, :, :, i]))
#print x.shape
for i in range(x.shape[2]):
mini = numpy.min(x[:, :, i])
maxi = numpy.max(x[:, :, i])
if (maxi - mini) != 0:
x[:, :, i] = ((x[:, :, i] - mini) * ((target_max - target_min) / (maxi - mini))) + target_min
else:
x[:, :, i] = 0
return x
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment