pytorch 图像归一化

这是python numpy的归一化:

   mean = np.array([0.485, 0.456, 0.406], dtype=np.float32)
   std = np.array([0.229, 0.224, 0.225], dtype=np.float32)
   img = img.astype(np.float32)
   img = (img/255.0 - mean) / std
   img = img.transpose([2, 0, 1])
   img = torch.Tensor(np.asarray([img]))

 

pytorch的归一化参考:

https://blog.csdn.net/jacke121/article/details/92798188

你可能感兴趣的:(python)