当前位置:网站首页>21.数据增强
21.数据增强
2022-08-02 00:14:00 【派大星的最爱海绵宝宝】
目录
big data
防止过度拟合的关键
网络参数量越来越大,网络的表达能力越来越强,如果要train一个很好的性能,我们需要大的数据集,big data。
limited data
对有限的数据进行优化:
small network capacity
减小网络的参数量,网络不容易过度拟合。网络结构固定,可以使网络的一部分权值为0,达到减小参数量的目的。
regularization
data argumentation
对原来的数据进行多样化处理,例如拍摄稀有动物的照片,对拍摄到的少量的图片进行旋转、调色、加噪声等操作,可得到更大的数据集。
常用的数据增强手段
都在torchvision中,对图片的处理都在视觉领域。compose功能类似于nn.Sequential,把一系列功能打包在一起使用。
flip翻转
train_loader = torch.utils.data.DataLoader(
datasets.MNIST('mnist_data', train=True, download=True,
transform=torchvision.transforms.Compose([
transform.RandomHorizontalFlip(),
transform.RamdomVerticalFlip(),
transforms.ToTensor(),
])),
batch_size=batch_size, shuffle=True)
图片按照transform里的顺序进行
RandomHorizonFlip水平角度翻转,random指的是这一步不一定进行,增加了随机性。
RandomVerticalFlip是竖直角度翻转。
rotate旋转
更加通用
train_loader = torch.utils.data.DataLoader(
datasets.MNIST('mnist_data', train=True, download=True,
transform=torchvision.transforms.Compose([
transform.RandomHorizontalFlip(),
transform.RamdomVerticalFlip(),
transform.RandomRotation(15),
transform.RandomRotation([90,180,270]),
transforms.ToTensor(),
])),
batch_size=batch_size, shuffle=True)
第一种,旋转某个角度,参数x即翻转-x到x内进行翻转操作。
第二种,固定角度翻转,[90,180,270]随机的在这三个数中挑一个数进行旋转。
scale缩放
在中心店往外进行缩放
train_loader = torch.utils.data.DataLoader(
datasets.MNIST('mnist_data', train=True, download=True,
transform=torchvision.transforms.Compose([
transform.RandomHorizontalFlip(),
transform.RamdomVerticalFlip(),
transform.RandomRotation(15),
transform.RandomRotation([90,180,270]),
transform.Resize([32,32])
transforms.ToTensor(),
])),
batch_size=batch_size, shuffle=True)
把原图片缩放到32×32。
crop part裁剪部分
随机裁剪一部分,剩下部分填充空白。
transform.RandomCrop([28,28])
noise
增加一些噪声,pytorch中并没有直接借口,需要人为的在numpy中添加。也可以使用torch中提供的高斯分布等叠加到上面。
GAN
可生成更多的样本
特点
无穷多的照片和原来的照片的分布非常接近,variance非常的小,所以即使得到无穷多的照片进行train时,performance只会比原来的数据好一点,不会好很多。
边栏推荐
- Unknown CMake command “add_action_files“
- go笔记之——goroutine
- Angr(十二)——官方文档(Part3)
- What does the errorPage attribute of the JSP page directive do?
- 146. LRU cache
- 实现删除-一个字符串中的指定字母,如:字符串“abcd”,删除其中的”a”字母,剩余”bcd”,也可以传递多个需要删除的字符,传递”ab”也可以做到删除”ab”,剩余”cd”。
- Stapler:1 靶机渗透测试-Vulnhub(STAPLER: 1)
- 辨析内存函数memset、memcmp、memmove以及memcpy
- String splitting function strtok exercise
- 字符串分割函数strtok练习
猜你喜欢
Microsoft PC Manager V2.1 beta version officially released
MLX90640 红外热成像仪测温模块开发笔记(完整版)
[HCIP] BGP Small Experiment (Federation, Optimization)
nodeJs--mime模块
Quick solution for infix to suffix and prefix expressions
bgp 聚合 反射器 联邦实验
辨析内存函数memset、memcmp、memmove以及memcpy
渗透测试与攻防对抗——渗透测试基础
Automatic conversion of Oracle-style implicit joins to ANSI JOINs using jOOQ
实现删除-一个字符串中的指定字母,如:字符串“abcd”,删除其中的”a”字母,剩余”bcd”,也可以传递多个需要删除的字符,传递”ab”也可以做到删除”ab”,剩余”cd”。
随机推荐
什么是低代码(Low-Code)?低代码适用于哪些场景?
DFS详解
ROS dynamic parameters
具有通信时延的多自主体系统时变参考输入的平均一致性跟踪
2022/08/01 学习笔记 (day21) 泛型和枚举
字符串分割函数strtok练习
【CodeTON Round 2 (Div. 1 + Div. 2, Rated, Prizes!)(A~D)】
业务测试如何避免漏测 ?
Redis-消息发布订阅
A simple file transfer tools
冒泡排序函数封装
07-SDRAM: FIFO control module
[Solution] Emqx startup under win10 reports Unable to load emulator DLL, node.db_role = EMQX_NODE__DB_ROLE = core
[HCIP] BGP Small Experiment (Federation, Optimization)
回顾历史5次经济衰退时期:这一次可能会有何不同?
期货开户交返是行内公开的秘密
JS中localStorage和sessionStorage
信息物理系统状态估计与传感器攻击检测
js中内存泄漏的几种情况
JSP how to obtain the path information in the request object?