ValueError: Floating point image RGB values must be in the 0..1 range. while using matplotlib

前端 未结 1 703
失恋的感觉
失恋的感觉 2020-12-20 18:47

I want to visualize weights of the layer of a neural network. I\'m using pytorch.

import torch
import torchvision.models as models
from matplotlib import pyp         


        
相关标签:
1条回答
  • 2020-12-20 18:58

    It sounds as if you already know your values are not in that range. Yes, you must re-scale them to the range 0.0 - 1.0. I suggest that you want to retain visibility of negative vs positive, but that you let 0.5 be your new "neutral" point. Scale such that current 0.0 values map to 0.5, and your most extreme value (largest magnitude) scale to 0.0 (if negative) or 1.0 (if positive).


    Thanks for the vectors. It looks like your values are in the range -2.25 to +2.0. I suggest a rescaling new = (1/(2*2.25)) * old + 0.5

    0 讨论(0)
提交回复
热议问题