Пример #1
0
 def apply(self, image, location, scale):
     matrices = self.compute_crop_matrices(location, scale)
     patch = image
     for axis, matrix in enumerate(matrices):
         patch = util.batched_tensordot(patch, matrix, [[2], [1]])
     self.add_auxiliary_variable(T.constant(0.), name="mean_savings")
     return patch
Пример #2
0
 def apply(self, image, location, scale):
     matrices = self.compute_crop_matrices(location, scale)
     patch = image
     for axis, matrix in enumerate(matrices):
         patch = util.batched_tensordot(patch, matrix, [[2], [1]])
     self.add_auxiliary_variable(T.constant(0.), name="mean_savings")
     return patch
Пример #3
0
 def apply_inner(self, image, location, scale, a, b):
     slices = [theano.gradient.disconnected_grad(T.arange(a[i], b[i]))
               for i in xrange(self.n_spatial_dims)]
     hardcrop = image[
         np.index_exp[:, :] +
         tuple(slice(a[i], b[i])
               for i in range(self.n_spatial_dims))]
     matrices = self.compute_crop_matrices(location, scale, slices)
     patch = hardcrop
     for axis, matrix in enumerate(matrices):
         patch = util.batched_tensordot(patch, matrix, [[2], [1]])
     return patch
Пример #4
0
 def apply_inner(self, image, location, scale, a, b):
     slices = [theano.gradient.disconnected_grad(T.arange(a[i], b[i]))
               for i in xrange(self.n_spatial_dims)]
     hardcrop = util.subtensor(
         image,
         [(T.arange(image.shape[0]), 0),
          (T.arange(image.shape[1]), 1)]
          + [(slice, 2 + i) for i, slice in enumerate(slices)])
     matrices = self.compute_crop_matrices(location, scale, slices)
     patch = hardcrop
     for axis, matrix in enumerate(matrices):
         patch = util.batched_tensordot(patch, matrix, [[2], [1]])
     return patch
Пример #5
0
 def apply_inner(self, image, location, scale, a, b):
     slices = [
         theano.gradient.disconnected_grad(T.arange(a[i], b[i]))
         for i in xrange(self.n_spatial_dims)
     ]
     hardcrop = util.subtensor(image, [(T.arange(image.shape[0]), 0),
                                       (T.arange(image.shape[1]), 1)] +
                               [(slice, 2 + i)
                                for i, slice in enumerate(slices)])
     matrices = self.compute_crop_matrices(location, scale, slices)
     patch = hardcrop
     for axis, matrix in enumerate(matrices):
         patch = util.batched_tensordot(patch, matrix, [[2], [1]])
     return patch
Пример #6
0
 def apply(self, image, location, scale):
     matrices = self.compute_crop_matrices(location, scale)
     patch = image
     for axis, matrix in enumerate(matrices):
         patch = util.batched_tensordot(patch, matrix, [[2], [1]])
     return patch, T.constant(0)