咖啡|通过随机裁剪进行数据扩充 [英] Caffe | data augmentation by random cropping

查看:99
本文介绍了咖啡|通过随机裁剪进行数据扩充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Caffe上训练自己的网络,类似于Imagenet模型.但是我对作物层感到困惑.直到我了解Imagenet模型中的作物层这一点为止,在训练过程中,它将随机抽取227x227图像作物并训练网络.但是在测试过程中,它将对中心227x227图像进行裁剪,难道我们从256x256图像中裁剪中心227x27图像时会丢失图像中的信息吗?第二个问题,我们如何定义培训期间要收获的农作物数量?

I am trying to train my own network on Caffe, similar to Imagenet model. But I am confused with the crop layer. Till the point I understand about crop layer in Imagenet model, during training it will take random 227x227 image crops and train the network. But during testing it will take the center 227x227 image crop, does not we loose the information from image while we crop the center 227x27 image from 256x256 image? And second question, how can we define the number of crops to be taken during training?

而且,我训练了相同的网络(相同的层数,相同的卷积大小FC神经元会明显不同),首先从256x256图像中获取227x227裁剪,第二次从256x256图像中获取255x255裁剪.根据我的直觉,裁剪为255x255的模型应该能给我最好的结果.但是,我使用227x227图像获得了更高的准确性,有人可以向我解释其背后的直觉吗,或者我做错了什么?

And also, I trained the same network(same number of layers, same convolution size FC neurons will differ obviously), first taking 227x227 crop from 256x256 image, and second time taking 255x255 crop from 256x256 image. According to my intuition, the model with 255x255 crop should give me the best result. But I am getting higher accuracy with 227x227 image, can anyone explain me the intuition behind it, or am i doing something wrong?

推荐答案

您的观察结果并非特定于Caffe.

Your observations are not specific to Caffe.

在训练和测试过程中裁剪的图像的大小必须相同(在您的情况下为227x227),因为上游网络层(卷积等)需要将图像的大小相同 .在训练期间随机进行作物是因为您想要数据扩充.但是,在测试期间,您要针对标准数据集进行测试.否则,测试过程中报告的准确性还取决于移动的测试数据库.

The sizes of the cropped images during training and testing need to be the same (227x227 in your case), because the upstream network layers (convolutions, etc) need the images to be the same size. Random crops are done during training is because you want data augmentation. However, during testing, you want to test against a standard dataset. Otherwise, the accuracy reported during testing would also depend on a shifting test database.

在每次迭代中动态地制作农作物.训练批次中的所有图像均被随机裁剪.我希望这能回答您的第二个问题.

The crops are made dynamically at each iteration. All images in a training batch are randomly cropped. I hope this answers your second question.

您的直觉并不完整:使用更大的作物(227x227),您将获得更多的数据扩充.数据扩充从根本上创建了新的"训练样本.这对于防止训练过程中的过度拟合至关重要.对于较小的作物(255x255),您应该期望更好的训练精度,但测试精度会降低,因为数据更可能被过度拟合.

Your intuition is not complete: With a bigger crop (227x227), you have more data augmentation. Data augmentation essentially creates "new" training samples out of nothing. This is vital to prevent overfitting during training. With a smaller crop (255x255), you should expect a better training accuracy but lower test accuracy, since the data is more likely be overfitted.

当然,裁剪可能会过度.裁剪过多,您从图像中丢失了太多信息.对于图像分类,理想的裁切尺寸是不改变图像类别的尺寸(即,仅裁切了背景).

Of course, cropping can be overdone. Too much cropping and you lose too much information from an image. For image categorization, the ideal crop size is one that does not alter the category of an image, (ie, only background is cropped away).

这篇关于咖啡|通过随机裁剪进行数据扩充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆