当前位置:网站首页>Data enhancement
Data enhancement
2022-06-11 16:00:00 【zhao_ crystal】
Catalog
1. Implementation method of data enhancement
2. Data enhancement in tf In the implementation of
2.1 adopt ImageDataGenerator Enhance the data
1. Implementation method of data enhancement
(1) normalization
Normalize the data to a certain range , Make the network easier to learn .
(2) Image transformation
Flip , The tensile , tailoring , deformation ( Rich data )
(3) Color change
Contrast , brightness
(4) Multiscale clipping 
2. Data enhancement in tf In the implementation of
adopt keras.preprocessing.image.ImageDataGenerator Interface to implement data enhancement
rescale = 1./255, # Zoom all pixels to 0——1, Because the values of all pixels are 0——255 Between .
rotation_range = 40, # A way of image enhancement , such as ratation_range = 40, Indicates that the random rotation angle of the image is -40——40 Between degrees .
width_shift_range = 0.2, # Displacement in the horizontal direction , Less than 1, It is the ratio of displacement ; Greater than 1, Is the value of the moving pixel .width_shift_range = 0.2, Indicates random translation of the image 0——20%
height_shift_range = 0.2, # Displacement in the vertical direction
shear_range = 0.2, # Shear strength
zoom_range = 0.2, # Scaling strength
horizontal_flip = True, # Whether to do random inversion in the horizontal direction
fill_mode = 'nearest') # When processing pictures , Use when pixels need to be filled . such as , Enlarge the image , Some pixels need to be filled .
2.1 adopt ImageDataGenerator Enhance the data
# Training data
train_datagen= keras.preprocessing.image.ImageDataGenerator(
rescale = 1./255, # Zoom all pixels to 0——1, Because the values of all pixels are 0——255 Between .
rotation_range = 40, # A way of image enhancement , such as ratation_range = 40, Indicates that the random rotation angle of the image is -40——40 Between degrees .
width_shift_range = 0.2, # Displacement in the horizontal direction , Less than 1, It is the ratio of displacement ; Greater than 1, Is the value of the moving pixel .width_shift_range = 0.2, Indicates random translation of the image 0——20%
height_shift_range = 0.2, # Displacement in the vertical direction
shear_range = 0.2, # Shear strength
zoom_range = 0.2, # Scaling strength
horizontal_flip = True, # Whether to do random inversion in the horizontal direction
fill_mode = 'nearest') # When processing pictures , Use when pixels need to be filled . such as , Enlarge the image , Some pixels need to be filled .
train_generator = train_datagen.flow_from_directory(
train_dir,
target_size = (height, width),
batch_size = batch_size,
seed = 7,
shuffle = True,
class_mode = "categorical")
# Validation data
valid_datagen= keras.preprocessing.image.ImageDataGenerator(
rescale = 1./255 # Zoom all pixels to 0——1, Because the values of all pixels are 0——255 Between .
)
valid_generator = train_datagen.flow_from_directory(
valid_dir,
target_size = (height, width),
batch_size = batch_size,
seed = 7,
shuffle = False,
class_mode = "categorical")For more codes, see : This code is based on convolutional neural network .
边栏推荐
- 【愚公系列】2022年06月 .NET架构班 077-分布式中间件 ScheduleMaster加载程序集定时任务
- Opengauss version 3.0.0 was officially released, and immediately experience the first lightweight version in the community
- 使用gsql连接数据库
- postgresql启动过程
- openGauss AI能力升级,打造全新的AI-Native数据库
- Basic SQL statement - delete / update
- How AGC security rules simplify user authorization and authentication requests
- Import data to the database? Try the copy from stdin statement
- [Yugong series] June 2022 Net architecture class 079 cluster principle of distributed middleware schedulemaster
- 带你深度了解AGC云数据库
猜你喜欢

DHCP协议实例化分析

openGauss并行解码浅谈

Analysis of the execution process of opengauss simple query SQL

Elk enterprise log analysis system

The third generation Pentium B70 won the C-NCAP five-star safety performance again

Go language slice

openGauss数据库性能调优概述及实例分析

Open the door of the hybrid cloud market, Lenovo xcloud's way to break the situation

GO语言-Slice切片

It's really not human to let the express delivery arrive before the refund
随机推荐
WGet command use
鼻孔插灯,智商上升,风靡硅谷,3万就成
openGauss企业版安装
What is the future of software testing in 2022? Do you need to understand the code?
Learn automatic testing of postman interface from 0 to 1
openGauss AI能力升级,打造全新的AI-Native数据库
Nat Common | le Modèle linguistique peut apprendre des distributions moléculaires complexes
Nat Commun|语言模型可以学习复杂的分子分布
轻松上手使用gs_dump和gs_dumpall命令导出数据
使用Cloud DB构建APP 快速入门-快游戏篇
Database resource load management (Part 2)
Cloud data management will break the island of storage and the island of team
使用Cloud DB构建APP 快速入门-Server篇
rf中安装的第四步:安装 robotframework-selenium2library报错
With an average annual salary of 20W, automated test engineers are so popular?
Analysis of breadcrumb usage scenarios on websites
使用Cloud DB构建APP 快速入门-快应用篇
How does the taskbar under the computer display open programs
Import data to the database? Try the copy from stdin statement
postgresql创建表