Example #1
0
    def apply(self, X):
        X_conv = nnfuns.relu(self.apply_lin(X))  #full convolution

        #for each pixel remove mean of (filter_size[0]xfilter_size[1]) neighbourhood
        mid = int(np.floor(self.filter_size[0] / 2.))  #middle value
        X_centered = X - X_conv[:, :, mid:-mid, mid:-mid]  #same shape as X

        X_sq = nnfuns.relu(self.apply_lin(X_centered**2))

        denom = T.sqrt(X_sq[:, :, mid:-mid, mid:-mid])
        per_img_mean = denom.mean(axis=[2, 3])
        divisor = T.largest(per_img_mean.dimshuffle(0, 1, 'x', 'x'), denom)
        new_X = X_centered / T.maximum(1., divisor)  #same format as input
        return new_X
Example #2
0
    def apply(self, X):
        X_conv = nnfuns.relu(self.apply_lin(X))             #full convolution

        #for each pixel remove mean of (filter_size[0]xfilter_size[1]) neighbourhood
        mid = int(np.floor(self.filter_size[0]/2.))         #middle value
        X_centered = X - X_conv[:,:,mid:-mid, mid:-mid]     #same shape as X

        X_sq = nnfuns.relu(self.apply_lin(X_centered ** 2))

        denom = T.sqrt(X_sq[:,:,mid:-mid, mid:-mid])
        per_img_mean = denom.mean(axis = [2,3])
        divisor = T.largest(per_img_mean.dimshuffle(0,1, 'x', 'x'), denom)
        new_X = X_centered / T.maximum(1., divisor)         #same format as input
        return new_X
Example #3
0
 def apply(self, X):
     return nnfuns.relu(self.apply_lin(X))
Example #4
0
 def apply(self, X):
     return nnfuns.relu(self.apply_lin(X));