当前位置:网站首页>Deep learning notes - data expansion
Deep learning notes - data expansion
2022-04-23 04:57:00 【Whisper_ yl】



Fixed shape ? Convolutional neural network is usually a fixed input .


The effect is not certain . Many times I think it is useful because I think there will be pictures in the test set, which is similar to this effect .
So how to choose data enhancement ? You can push back and forward , Think about the changes between the pictures in the deployment and test set and the pictures in the training set , To determine what kind of data enhancement is needed .

More diversity , Make generalization better . The purpose of the expansion is to make the training set more like the test set , It would be better if they were exactly the same !:)
import torch
import torchvision
from torch import nn
from d2l import torch as d2l
import matplotlib.pyplot as plt
d2l.set_figsize()
img = d2l.Image.open('./img/cat1.jpg')
d2l.plt.imshow(img);
# aug: How to enlarge the picture
def apply(img, aug, num_rows=2, num_cols=4, scale=1.5):
Y = [aug(img) for _ in range(num_rows * num_cols)]
d2l.show_images(Y, num_rows, num_cols, scale=scale)
plt.show()
# Flip image left and right
# apply(img, torchvision.transforms.RandomHorizontalFlip())
# Flip the image up and down
# apply(img, torchvision.transforms.RandomVerticalFlip())
# Random cutting
shape_aug = torchvision.transforms.RandomResizedCrop(
(200, 200), scale=(0.1, 1), ratio=(0.5, 2))
# Randomly change the brightness of the image
'''
apply(img, torchvision.transforms.ColorJitter(
brightness=0.5, contrast=0, saturation=0, hue=0))
'''
# Randomly change the hue of the image
'''
apply(img, torchvision.transforms.ColorJitter(
brightness=0, contrast=0, saturation=0, hue=0.5))
'''
# Randomly change the brightness of the image 、 Contrast 、 Saturation and hue
color_aug = torchvision.transforms.ColorJitter(
brightness=0.5, contrast=0.5, saturation=0.5, hue=0.5)
# Combined with a variety of image enhancement methods
augs = torchvision.transforms.Compose([
torchvision.transforms.RandomHorizontalFlip(), color_aug, shape_aug])
apply(img, augs)
版权声明
本文为[Whisper_ yl]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230453143820.html
边栏推荐
- Spell it! Two A-level universities and six B-level universities have abolished master's degree programs in software engineering!
- selenium模式下切换窗口,抓取数据的实现
- Use model load_ state_ Attributeerror appears when dict(): 'STR' object has no attribute 'copy‘
- [winui3] Écrivez une copie du gestionnaire de fichiers Explorer
- Informatics Olympiad 1955: [11noip popularization group] Swiss round | openjudge 4.1 4363: Swiss round | Luogu p1309 [noip2011 popularization group] Swiss round
- QPushbutton 槽函数被多次触发
- AQS source code reading
- 信息学奥赛一本通 1955:【11NOIP普及组】瑞士轮 | OpenJudge 4.1 4363:瑞士轮 | 洛谷 P1309 [NOIP2011 普及组] 瑞士轮
- [database] MySQL multi table query (I)
- What is the meaning of load balancing
猜你喜欢
随机推荐
[winui3] Écrivez une copie du gestionnaire de fichiers Explorer
Arduino UNO r3+LCD1602+DHT11
Unity3d practical skills - theoretical knowledge base (I)
Informatics Olympiad 1955: [11noip popularization group] Swiss round | openjudge 4.1 4363: Swiss round | Luogu p1309 [noip2011 popularization group] Swiss round
Progress of innovation training (III)
简单的拖拽物体到物品栏
Learning Android V from scratch - UI
Set Chrome browser background to eye protection (eye escort / darkreader plug-in)
Com alibaba. Common methods of fastjson
Day.js 常用方法
解决ValueError: Argument must be a dense tensor: 0 - got shape [198602], but wanted [198602, 16].
Graduation project
Learning Android II from scratch - activity
Innovation training (V) mid term inspection
Getprop property
Excel uses the functions of replacement, sorting and filling to comprehensively sort out financial data
leetcode——启发式搜索
POI export message list (including pictures)
MySQL memo (for your own query)
Learning Android from scratch -- baseactivity and activitycollector









