数据处理中ToTensor紧接着Normalize
发布日期:2021-06-29 11:45:20
浏览次数:3
分类:技术文章
本文共 845 字,大约阅读时间需要 2 分钟。
transform = transforms.Compose([ transforms.ToTensor(), transforms.Normalize(mean=(0.5, 0.5, 0.5), std=(0.5, 0.5, 0.5)) ])
ToTensor的作用:另外一个作用就是将数据全部归一化到了(0,1)
Convert a ``PIL Image`` or ``numpy.ndarray`` to tensor.Converts a PIL Image or numpy.ndarray (H x W x C) in the range[0, 255] to a torch.FloatTensor of shape (C x H x W) in the range [0.0, 1.0]."""
既然上述函数已经归一化了,为什么后面一般还要接一个归一化呢?
Normalize:作用就是继续调整,使数据均值靠近0,偏差就靠近0。在上面的处理还有一个作用是将数据范围变到(-1,1)
"""Normalize a tensor image with mean and standard deviation.Given mean: ``(M1,...,Mn)`` and std: ``(S1,..,Sn)`` for ``n`` channels, this transformwill normalize each channel of the input ``torch.*Tensor`` i.e.``input[channel] = (input[channel] - mean[channel]) / std[channel]``
最重要的是:数据分布在(0,1)之间,可能实际的bias(可以理解为我们的参数b)会比较大,而我们的模型初始化b=0,那么要达到实际的bias大小就比较慢,如果经过调整使实际bias大小减少,就是说靠近原点,那么就能加快收敛。
转载地址:https://blog.csdn.net/zz2230633069/article/details/88353122 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
感谢大佬
[***.8.128.20]2024年04月09日 20时53分08秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
神奇的麦考林
2019-04-29
centos7使用rpm安装mysql遇到的error: Failed dependencies: mysql-community-common(x86-64) 5.7.9 is needed
2019-04-29
spark报错:warn util.utils::service ‘sparkUI‘ can not bind on part 4040.Attempting port 4041.4042等错误
2019-04-29
Error getting authority: Error initializing authority: Could not connect: No such file or directory
2019-04-29
编程程软件测试思维方式:如何科学制定测试计划
2019-04-29
raspberry 2b 启动信息
2019-04-29
win7下树莓派安装使用win10
2019-04-29
raspberry 树莓派 360/百度(RT2870 MT7601) WIFI驱动
2019-04-29
raspberrrypi 常用软件大全
2019-04-29
树莓派raspberry使用手机做为显示设备
2019-04-29
visual studio 2015 下载地址
2019-04-29
BLE蓝牙4.0串口调试助手
2019-04-29
PHP库收集
2019-04-29
七牛 PHP 文件管理
2019-04-29
汽车OBD产品
2019-04-29
短网址dwz.cn批量注册
2019-04-29
dcloud mui html5plus 5+sdk
2019-04-29
不要驱动,简单粗暴的用树莓派驱动USB打印机
2019-04-29