小编yle*_*lee的帖子

(pytorch)我想将 [0 255] 整数张量标准化为 [0 1] 浮点张量

我想将 [0 255] 整数张量标准化为 [0 1] 浮点张量。

我使用 cifar10 数据集并想要处理整数图像张量。
所以当我加载数据集时,我将它们设为整数张量,我使用“transforms.ToTensor()”,因此值设置为 [0 1] float

tensor([[[0.4588, 0.4588, 0.4588,  ..., 0.4980, 0.4980, 0.5020],
         [0.4706, 0.4706, 0.4706,  ..., 0.5098, 0.5098, 0.5137],
         [0.4824, 0.4824, 0.4824,  ..., 0.5216, 0.5216, 0.5294],
         ...,
         [0.3098, 0.3020, 0.2863,  ..., 0.4549, 0.3608, 0.3137],
         [0.2902, 0.2902, 0.2902,  ..., 0.4431, 0.3333, 0.3020],
         [0.2706, 0.2941, 0.2941,  ..., 0.4157, 0.3529, 0.3059]],

        [[0.7725, 0.7725, 0.7725,  ..., 0.7569, 0.7569, 0.7608],
         [0.7765, 0.7765, 0.7765,  ..., 0.7608, 0.7608, 0.7686],
         [0.7765, 0.7765, 0.7765,  ..., 0.7608, 0.7608, 0.7725],
         ...,
         [0.6510, …
Run Code Online (Sandbox Code Playgroud)

python casting normalize pytorch tensor

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

casting ×1

normalize ×1

python ×1

pytorch ×1

tensor ×1