当前位置:网站首页>Paddle implementation, multidimensional time series data enhancement, mixup (using beta distribution to make continuous random numbers)
Paddle implementation, multidimensional time series data enhancement, mixup (using beta distribution to make continuous random numbers)
2022-07-23 19:37:00 【Lee Meier】
# Data to enhance
def data_augment(X, y, p=0.8, alpha=0.5, beta=0.5):
"""Regression SMOTE
1. Put the data x It is divided into fix_X and X
2. Yes X To remodel
For random uniform distribution less than 0.8 The index of idx_to_change Reshape the data part .
X2 It's after disordering the order X
beta The value is np.random.beta(alpha, beta, batch_size) / 2 + 0.5 ####beta value >0.5 Make sure that most of the reshaped data is the original value
X[idx_to_change] = beta value *X[idx_to_change] +(1-beta value )*X2[idx_to_change]
3. Merge fix_X and X New data x
4. For input y In the same way
"""
fix_X, X = X[:, :, :, :2], X[:, :, :, 2:]#[32, 134, 144, 2] [32, 134, 144, 10]
fix_y, y = y[:, :, :, :2], y[:, :, :, 2:]#[32, 134, 288, 2] [32, 134, 288, 10]
# print('fix_X, X:',fix_X.shape, X.shape)
batch_size = X.shape[0]#32
random_values = paddle.rand([batch_size]) # Returns uniformly distributed , The scope is [0, 1) Of Tensor shape:[32]
idx_to_change = random_values < p #32 A value of , Less than 0.8 For the False, Others are True
# ensure that first element to switch has probability > 0.5
np_betas = np.random.beta(alpha, beta, batch_size) / 2 + 0.5
random_betas = paddle.to_tensor(
np_betas, dtype="float32").reshape([-1, 1, 1, 1]) # [32, 1, 1, 1]
index_permute = paddle.randperm(batch_size)# returns a 1-D Tensor filled with random permutation values from 0 to n-1# Used to disrupt data numbers
X[idx_to_change] = random_betas[idx_to_change] * X[idx_to_change]
X[idx_to_change] += (
1 - random_betas[idx_to_change]) * X[index_permute][idx_to_change]
y[idx_to_change] = random_betas[idx_to_change] * y[idx_to_change]
y[idx_to_change] += (
1 - random_betas[idx_to_change]) * y[index_permute][idx_to_change]
return paddle.concat([fix_X, X], -1), paddle.concat([fix_y, y], -1)
边栏推荐
- 关于:在企业局域网中启用 Delivery Optimization
- 当代励志“女”录
- 为啥一问 JVM 就 懵B ?
- 【C语言】程序环境和预处理
- Talk about the parental delegation mechanism in detail (often asked in interviews) [easy to understand]
- Educational Codeforces Round 132 (Rated for Div. 2)【比赛记录】
- Alibaba最新神作!耗时187天肝出来1015页分布式全栈手册太香了
- 虹科干货 | 教您如何解析MODBUS中的浮点型数据
- Read data from txt and convert it to Yolo format data
- 吃透Chisel语言.21.Chisel时序电路(一)——Chisel寄存器(Register)详解
猜你喜欢

Data link layer -------- Ethernet and ARP

使用 frp 实现内网穿透

PowerCLi 管理VMware vCenter 一键批量部署OVA

UPC 2022 summer personal training game 12 (number of combinations b)

Canvas draw text and clear draw

Weights & Biases (一)

Calculation of structure size (structure memory alignment)

Lendingclub loan status business details current, charge off, issued, full paid, grace period

selenium中元素定位正确但是操作失败,6种解决办法全稿定

Mee | Zhejiang University Chenglei group develops a new method for designing and constructing synthetic flora
随机推荐
Still using xshell? You are out. I recommend a more modern terminal connection tool
A preliminary study of the relationship between combinatorial mathematics and DP, and the derivation of resettable combinatorial formulas
R语言使用dwilcox函数生成Wilcoxon秩和统计分布密度函数数据、使用plot函数可视化Wilcoxon秩和统计分布密度函数数据
Using FRP to achieve intranet penetration
(干货)结合Scikit-learn介绍几种常用的特征选择方法
Codeforces Round #809 (Div. 2)【VP记录】
当代励志“女”录
MySQL读写分离的三种实现方案
Element positioning in selenium is correct, but the operation fails. Six solutions are all finalized
吃透Chisel语言.21.Chisel时序电路(一)——Chisel寄存器(Register)详解
Fragment
R语言data.table包进行数据分组聚合统计变换(Aggregating transforms)、计算dataframe数据的分组最小值(min)
[C language] program environment and preprocessing
How can mysqldump export content without comments?
USB3.0:VL817Q7-C0的LAYOUT指南
Four principles of interface design
三维点云课程(六)——三维目标检测
Data link layer -------- Ethernet and ARP
R语言ggplot2可视化:使用ggplot2可视化散点图、使用ggpubr包的theme_classic2函数设置可视化图像为经典主题(classic theme with axis lines)
公链之Sui(前脸书/Meta员工成立的新公链项目)