当前位置:网站首页>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
边栏推荐
- Pixel mobile phone brick rescue tutorial
- Spark optimization
- Getprop property
- MySQL memo (for your own query)
- AQS source code reading
- The 8 diagrams let you see the execution sequence of async / await and promise step by step
- 信息学奥赛一本通 1955:【11NOIP普及组】瑞士轮 | OpenJudge 4.1 4363:瑞士轮 | 洛谷 P1309 [NOIP2011 普及组] 瑞士轮
- Excel uses the functions of replacement, sorting and filling to comprehensively sort out financial data
- Unity攝像頭跟隨鼠標旋轉
- CLion+OpenCV identify ID number - detect ID number
猜你喜欢
Sword finger offer: the median in the data stream (priority queue large top heap small top heap leetcode 295)
PHP+MySQL 制作留言板
AQS源码阅读
Spark optimization
View, modify and delete [database] table
Making message board with PHP + MySQL
深度学习笔记 —— 微调
Pixel mobile phone brick rescue tutorial
拼了!两所A级大学,六所B级大学,纷纷撤销软件工程硕士点!
Learning Android II from scratch - activity
随机推荐
C list field sorting contains numbers and characters
机器学习---线性回归
Wechat payment function
[winui3] Écrivez une copie du gestionnaire de fichiers Explorer
Arduino UNO r3+LCD1602+DHT11
Windows remote connection to redis
Excel uses the functions of replacement, sorting and filling to comprehensively sort out financial data
[2022 ICLR] Pyraformer: Low-Complexity Pyramidal Attention for Long-Range 时空序列建模和预测
[winui3] write an imitation Explorer file manager
L2-011 玩转二叉树(建树+BFS)
What are the redis data types
[database] MySQL multi table query (I)
The 8 diagrams let you see the execution sequence of async / await and promise step by step
PHP counts the number of files in the specified folder
Other problems encountered in debugging fingerprints
多线程基本概念(并发与并行、线程与进程)和入门案例
Unity攝像頭跟隨鼠標旋轉
独立站运营 | FaceBook营销神器——聊天机器人ManyChat
Leetcode 1547: minimum cost of cutting sticks
Spark case - wordcount