简体   繁体   English

随机裁剪数据增强卷积神经网络

[英]Random cropping data augmentation convolutional neural networks

I am training a convolutional neural network, but have a relatively small dataset. 我正在训练卷积神经网络,但有一个相对较小的数据集。 So I am implementing techniques to augment it. 所以我正在实施增强它的技术。 Now this is the first time i am working on a core computer vision problem so am relatively new to it. 现在,这是我第一次研究核心计算机视觉问题,因此对它来说相对较新。 For augmenting, i read many techniques and one of them that is mentioned a lot in the papers is random cropping. 为了进行扩充,我阅读了许多技术,其中一篇在论文中被大量提及的是随机裁剪。 Now i'm trying to implement it ,i've searched a lot about this technique but couldn't find a proper explanation. 现在我正在努力实现它,我已经搜索了很多关于这种技术,但找不到合适的解释。 So had a few queries: 有几个疑问:

How is random cropping actually helping in data augmentation? 随机裁剪如何帮助数据增加? Is there any library (eg OpenCV, PIL, scikit-image, scipy) in python implementing random cropping implicitly? 是否有任何库(例如OpenCV,PIL,scikit-image,scipy)在python中隐式实现随机裁剪? If not, how should i implement it? 如果没有,我该如何实施呢?

In my opinion the reason random cropping helps data augmentation is that while the semantics of the image are preserved (unless you pick out a really bad crop, but let's assume that you setup your random cropping so that this is very low probability) the activations values you get in your conv net are different. 在我看来,随机裁剪有助于数据增加的原因是,虽然保留了图像的语义(除非你选择了一个非常糟糕的裁剪,但我们假设您设置了随机裁剪,这样的概率非常低)激活值你进入你的转发网是不同的。 So in effect our conv net learns to associate a broader range of spatial activation statistics with a certain class label and thus data augmentation via random cropping helps improve the robustness of our feature detectors in conv nets. 因此,实际上我们的转换网络学会将更广泛的空间激活统计数据与某个类别标签相关联,因此通过随机裁剪进行数据增强有助于提高我们的特征检测器在网络中的稳健性。 Also in the same vein, the random crop produces different intermediate activation values and produces a different forwardpass so it's like a "new training point." 同样,随机作物产生不同的中间激活值并产生不同的前向通道,因此它就像一个“新的训练点”。

It's also not trivial. 这也不是微不足道的。 See the recent work on adversarial examples in neural networks (relatively shallow to AlexNet sized). 请参阅最近关于神经网络中对抗性示例的工作(相对较浅的AlexNet大小)。 Images that semantically look the same, more or less, when we pass them through a neural net with a softmax classifier on top, we can get drastically different class probabilities. 图像在语义上看起来相同,或多或少,当我们通过一个带有softmax分类器的神经网络传递它们时,我们可以得到截然不同的类概率。 So subtle changes from a semantic point of view can end up having different forward passes through a conv net. 因此,从语义的角度来看,微妙的变化最终可能会通过转发网络进行不同的前向传递。 For more details see Intriguing properties of neural networks . 有关更多详细信息,请参阅神经网络的迷人属性

To answer the last part of your question: I usually just make my own random cropping script. 要回答你问题的最后一部分:我通常只是制作我自己的随机裁剪脚本。 Say my images are (3, 256, 256) (3 RGB channels, 256x256 spatial size) you can code up a loop which takes 224x224 random crops of your image by just randomly selecting a valid corner point. 假设我的图像是(3,256,256)(3个RGB通道,256x256空间大小),您可以编写一个循环,通过随机选择一个有效的角点来获取图像的224x224个随机裁剪。 So I typically compute an array of valid corner points and if I want to take 10 random crops, I randomly select 10 different corner points from this set, say I choose (x0, y0) for my upper left hand corner point, I will select the crop X[x0:x0+224, y0:y0+224], something like this. 所以我通常会计算一个有效角点数组,如果我想要10个随机作物,我会从这个集合中随机选择10个不同的角点,比如我选择(x0,y0)作为我的左上角点,我会选择裁剪X [x0:x0 + 224,y0:y0 + 224],就像这样。 I personally like to randomly choose from a pre-computed set of valid corner points instead of randomly choosing a corner one draw at a time because this way I guarantee I do not get a duplicate crop, though in reality it's probably low probability anyway. 我个人喜欢从一组预先计算的有效角点中随机选择,而不是一次随机选择一个角落,因为这样我保证我不会得到一个重复的作物,尽管实际上它的概率可能很低。

To answer the "how to implement cropping" question, you might want to explore https://github.com/aleju/imgaug . 要回答“如何实施裁剪”问题,您可能需要浏览https://github.com/aleju/imgaug There is a Crop augmenter available that lets you do random cropping. 有一个Crop增强器可以让你做随机裁剪。 And a lot of other fun augmenters. 还有很多其他有趣的增强剂。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我的 Pytorch 卷积神经网络中的每个时期是否应用了随机变换? (数据增强) - Are the random transforms applied at each epoch in my Pytorch convolutional neural net? (data augmentation) PyTorch和卷积神经网络 - PyTorch and Convolutional Neural Networks 卷积神经网络批量大小 - Convolutional Neural Networks batch size 将 Keras (Tensorflow) 卷积神经网络转换为 PyTorch 卷积网络? - Converting Keras (Tensorflow) convolutional neural networks to PyTorch convolutional networks? 对于使用数据增强进行图像分类的卷积神经网络,如何在 keras 中获得可重现的结果? - How can I get reproducible results in keras for a convolutional neural network using data augmentation for image classification? 这些是卷积神经网络的可取的最佳实践吗? - Are these advisable best practices for convolutional neural networks? Kernel 卷积神经网络中的大小变化 - Kernel size change in convolutional neural networks Python 中卷积神经网络的检查点 function 出错 - Error in Checkpoint function of Convolutional neural networks in Python 将字符串值作为卷积神经网络的标签传递 - passing string values as labels for convolutional neural networks 用神经网络生成数据 - Generate data with neural networks
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM