(self, imagedata, delta, unit=None,
            above=None, below=None)
return result_image
Visualizes the given activations, thresholded at a specified level,
        with green for high numbrers and red for low numbers.
Visualizes the given activations, thresholded at a specified level,
        with green for high numbrers and red for low numbers.
Visualizes the given activations thresholded at a specified level with green for high numbrers and red for low numbers .
def pytorch_masked_delta(self, imagedata, delta, unit=None,
            above=None, below=None):
        '''
        Visualizes the given activations, thresholded at a specified level,
        with green for high numbrers and red for low numbers.
        '''
        scaled_image = self.scaled_image(imagedata).float().cpu()
        amask, bmask, aborder, bborder = [torch.tensor(0) for _ in range(4)]
        if above is not None:
            amask = self.pytorch_mask(delta, unit, level=above).cpu()
            aborder = border_from_mask(amask)
        if below is not None:
            bmask = ~self.pytorch_mask(delta, unit, level=below).cpu()
            bborder = border_from_mask(bmask)
        inside = ((amask | bmask) & ~(aborder | bborder))
        outside = (~(amask | bmask) & ~(aborder | bborder))
        inside, outside, aborder, bborder = [d.float()
                for d in [inside, outside, aborder, bborder]]
        red, green = [torch.tensor(c, dtype=torch.float, device=aborder.device
            )[:,None,None] for c in [[255, 0, 0], [0, 255, 0]]]
        result_image = (
                scaled_image * inside +
                green * aborder +
                red * bborder +
                0.5 * scaled_image * outside).clamp(0, 255).byte()
        return result_image
def pytorch_masked_delta ( self , imagedata , delta , unit = None , above = None , below = None ) : scaled_image = self . scaled_image ( imagedata ) . float ( ) . cpu ( ) amask , bmask , aborder , bborder = [ torch . tensor ( 0 ) for _ in range ( 4 ) ] if above is not None : amask = self . pytorch_mask ( delta , unit , level = above ) . cpu ( ) aborder = border_from_mask ( amask ) if below is not None : bmask = ~ self . pytorch_mask ( delta , unit , level = below ) . cpu ( ) bborder = border_from_mask ( bmask ) inside = ( ( amask | bmask ) & ~ ( aborder | bborder ) ) outside = ( ~ ( amask | bmask ) & ~ ( aborder | bborder ) ) inside , outside , aborder , bborder = [ d . float ( ) for d in [ inside , outside , aborder , bborder ] ] red , green = [ torch . tensor ( c , dtype = torch . float , device = aborder . device ) [ : , None , None ] for c in [ [ 255 , 0 , 0 ] , [ 0 , 255 , 0 ] ] ] result_image = ( scaled_image * inside + green * aborder + red * bborder + 0.5 * scaled_image * outside ) . clamp ( 0 , 255 ) . byte ( ) return result_image