Visualizing Tensor

Does anyone know why my code is visualizing feature map in grayscale when I’m using it during forward-pass? I want to visualize it in other colors

def vis_tensor(data):
    data =data[0].transpose((1, 2, 0))
    data = data - data.min()
    data = data / data.max()
    data = data * 255
    mean = np.repeat(data.mean(-1, keepdims=True),3 ,2)
    mean = mean.astype('uint8')
    max = np.repeat(data.max(-1, keepdims=True), 3, 2)
    max = max.astype('uint8')

Output now is like this:

Because you run mean and max on the channel dimension? Since only one channel is left, it considers the image as being grayscale?

An image with a single channel is a grayscale image. So this is the expected visualization from my point of view.
What were you expecting?

You could chose another colormap in matplotlib to map each grayscale value to a specific color.