File Exchange

image thumbnail

CNN classification using random erasing/cut out

version 1.0.1 (355 KB) by Kenta
This demo shows how to do random erasing/cut out augmentation in CNN classification. random erasing や cut outとよばれる方法を用いて画像にマスクをかけ、分類を行います。


Updated 24 May 2020

View License

This demo shows how to do random erasing/cut out augmentation in CNN classification as explained in [1] and [2]. A rectangle mask was created randomly on the training images to escape overfitting as shown below. In this demo, a gray color mask was made and the height and width ranged from 1 to the half of the image size. The color and size of the mask can be changed in the custom function at the end of this script.
The test accuracy with/without the random erasing/cut out was compared; the test accucacy with the technique was significantly higher because the network with it, to some extent, escape the over-fitting to the training data. This was done with cifar-10 dataset [3, 4]. You may alleviate the over-fitting using the random erasing/cut out.

このファイルでは、cut outやrandom erasingとよばれる方法 [1, 2] を用いてデータ拡張をし、さらに畳み込みニューラルネットワーク(CNN)にて分類をする例を示します。過学習を防ぐために、訓練データセットの画像にランダムに長方形のマスクをかけ、その画像をもとに学習を行います。Cifar-10とよばれるデータセット [3, 4]を用いてこのデータ拡張によって、分類精度が上昇することを確認できます。輝度値が128のグレーのマスクをかけていますが、訓練データ内の輝度値の平均を使ったり、ゴマ塩ノイズを乗せたりと工夫をすることでさらなる精度上昇の可能性も考えられます。

[Key words]
augmentation, cifar-10, classification, cnn, cut out, data augmentation, over-fitting, over-tune, random erasing
[1] Zhong, Z., L. Zheng, G. Kang, S. Li, and Y. Yang. "Random erasing data augmentation. arXiv 2017." arXiv preprint arXiv:1708.04896.
[2] DeVries, Terrance, and Graham W. Taylor. "Improved regularization of convolutional neural networks with cutout." arXiv preprint arXiv:1708.04552 (2017).
[3] Krizhevsky, A., and G. Hinton. "Learning multiple layers of features from tiny images." Master's Thesis. University of Toronto, Toronto, Canada, 2009.
[4] The CIFAR-10 dataset (

Cite As

Kenta (2020). CNN classification using random erasing/cut out (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (1)



Japanese description added

MATLAB Release Compatibility
Created with R2020a
Compatible with any release
Platform Compatibility
Windows macOS Linux