(self, data)
return result
Given input data as taken from the training distirbution,
        normalizes every channel to reflect quantile values,
        uniformly distributed, within [0, 1].
Given input data as taken from the training distirbution,
        normalizes every channel to reflect quantile values,
        uniformly distributed, within [0, 1].
Given input data as taken from the training distirbution normalizes every channel to reflect quantile values uniformly distributed within [ 0 1 ] .
def normalize(self, data):
        '''
        Given input data as taken from the training distirbution,
        normalizes every channel to reflect quantile values,
        uniformly distributed, within [0, 1].
        '''
        assert self.count > 0
        assert data.shape[0] == self.depth
        summary, weights = self._weighted_summary()
        cumweights = torch.cumsum(weights, dim=-1) - weights / 2
        cumweights /= torch.sum(weights, dim=-1, keepdim=True)
        result = torch.zeros_like(data).float()
        # numpy is needed for interpolation
        ndata = data.cpu().numpy().reshape((data.shape[0], -1))
        ncw = cumweights.cpu().numpy()
        nsm = summary.cpu().numpy()
        for d in range(self.depth):
            normed = torch.tensor(numpy.interp(ndata[d], nsm[d], ncw[d]),
                dtype=torch.float, device=data.device).clamp_(0.0, 1.0)
            if len(data.shape) > 1:
                normed = normed.view(*(data.shape[1:]))
            result[d] = normed
        return result
def normalize ( self , data ) : assert self . count > 0 assert data . shape [ 0 ] == self . depth summary , weights = self . _weighted_summary ( ) cumweights = torch . cumsum ( weights , dim = - 1 ) - weights / 2 cumweights /= torch . sum ( weights , dim = - 1 , keepdim = True ) result = torch . zeros_like ( data ) . float ( ) # numpy is needed for interpolation ndata = data . cpu ( ) . numpy ( ) . reshape ( ( data . shape [ 0 ] , - 1 ) ) ncw = cumweights . cpu ( ) . numpy ( ) nsm = summary . cpu ( ) . numpy ( ) for d in range ( self . depth ) : normed = torch . tensor ( numpy . interp ( ndata [ d ] , nsm [ d ] , ncw [ d ] ) , dtype = torch . float , device = data . device ) . clamp_ ( 0.0 , 1.0 ) if len ( data . shape ) > 1 : normed = normed . view ( * ( data . shape [ 1 : ] ) ) result [ d ] = normed return result