Training Neural Networks with Very Little Data -- A Draft径向变换
来源:互联网 发布:sql count 用法 编辑:程序博客网 时间:2024/06/05 18:24
最近有一篇针对数据增强的文章比较有意思:这里只讲一下核心的代码实现以及实现细节,原文可以自行查阅:
Training Neural Networks with Very Little Data – A Draft
文章的大概意思就是通过某种变换,将笛卡尔坐标系的图像通过坐标变换,变换成极坐标系下的图像,该变换直接通过下面的公式给出:
变换比较简单,公式也写的很清楚,根据公式实现的代码:
github:
https://github.com/zhly0/radial-transform
from skimage import datafrom skimage import ioimport numpy as npimport mathimport matplotlib.pyplot as pltdef to_gray(img): w, h,_ = img.shape ret = np.empty((w, h), dtype=np.uint8) retf = np.empty((w, h), dtype=np.float) imgf = img.astype(float) retf[:, :] = ((imgf[:, :, 1] + imgf[:, :, 2] + imgf[:, :, 0])/3) ret = retf.astype(np.uint8) return retdef radia_transform(img,w,h): shape = im.shape new_im = np.zeros(shape) print(shape) print(len(shape)) print('w',w) print('h',h) width = shape[1] height = shape[0] lens = len(shape) for i in range(0,width): xita = 2*3.14159*i/width for a in range(0,height): x = (int)(math.floor(a * math.cos(xita))) y = (int)(math.floor(a * math.sin(xita))) new_y = (int)(h+x) new_x = (int)(w+y) #print(h.dtype) if new_x>=0 and new_x<width: if new_y>=0 and new_y<height: if lens==3: new_im[a,i,0] = (im[new_y,new_x,0]-127.5)/128 new_im[a,i,1] = (im[new_y,new_x,1]-127.5)/128 new_im[a,i,2] = (im[new_y,new_x,2]-127.5)/128 else: new_im[a,i] = (im[new_y,new_x]-127.5)/128 new_im[a,i] = (im[new_y,new_x]-127.5)/128 new_im[a,i] = (im[new_y,new_x]-127.5)/128 return new_imim = io.imread('E:/1.jpg')im = to_gray(im)h = im.shape[0]w = im.shape[1]new_im1 = radia_transform(im,(int)(w/2),(int)(h/2))new_im2 = radia_transform(im,(int)(w/4),(int)(h/4))new_im3 = radia_transform(im,(int)(w*0.5),(int)(h*0.75))plt.figure(num='astronaut',figsize=(8,8)) plt.subplot(2,2,1) plt.title('origin image') plt.imshow(im,plt.cm.gray) plt.subplot(2,2,2) plt.title('0.5') plt.imshow(new_im1,plt.cm.gray) plt.axis('off') plt.subplot(2,2,3) plt.title('0.25') plt.imshow(new_im2,plt.cm.gray) plt.axis('off') plt.subplot(2,2,4) plt.title('0.75') plt.imshow(new_im3,plt.cm.gray) plt.axis('off') plt.show()
以及对应的变换:
阅读全文
1 0
- Training Neural Networks with Very Little Data -- A Draft径向变换
- Training Very Deep Networks
- DeepID3:Face Recognition with Very Deep Neural Networks
- neural networks deep learning Planar data classification with a hidden layer参考答案
- BinaryConnect: Training Deep Neural Networks with binary weights during propagations
- BinaryConnect: Training Deep Neural Networks with binary weights during propagations
- Efficient Training of Very Deep Neural Networks for Supervised Hashing
- Training Very Deep Networks--Highway Networks
- 深度学习:Hinton_Science_Reducing the dimensionality of data with neural networks
- Hinton Science06 Reducing the dimensionality of data with neural networks
- 深度学习:Hinton_Science_Reducing the dimensionality of data with neural networks
- Reducing the Dimensionality of Data with Neural Networks
- Reducing the Dimensionality of Data with Neural Networks
- Reducing the Dimensionality of Data with Neural Networks
- Labelling Unsegmented Sequence Data with Recurrent Neural Networks(笔记)
- 深度学习:Hinton_Science_Reducing the dimensionality of data with neural networks
- Descriptor Matching with Convolutional Neural Networks: a Comparison to SIFT
- Training Very Deep Networks公式推导
- 批量生产删除ASM物理文件的脚本
- 第三周——项目一—顺序表的基本运算(3)
- CXTPRibbonBar添加系统菜单时候,会出现白条
- License Key Formatting 问题及解法
- Leetcode 242 Valid Anagram
- Training Neural Networks with Very Little Data -- A Draft径向变换
- Leetcode 400 Nth Digit
- USB充电,标准充电器,非标准充电器的区别
- Leetcode 441 Arranging Coins
- 如何将拷贝过来的代码实现高亮
- Leetcode 561 Array Partition I
- 前端技术介绍,跟我学响应式布局
- 关于pod导入protocolBuffers使用问题
- Leetcode 605 Can Place Flowers