Cifar-10 with PyTorch

PyTorch is a convenient framwork which allows us to build deep learning network faster.

However, its tutorial does not provide example of loading datasets from raw data e.g. images. This tutorial uses cifar-10 datasets as an example to show how to load data without torchvision. SourceCode

First, we download train.7z and trainLabels.csv from kaggle. train.7z contains images from different classes and trainLabels.csv gives out the related labels. Unzip train.7z and put it into 'data' fold. Then we can use data_prepare.py to process data. Specially, function data_preprocessing normalize images to [-1, 1]. Please be aware that shape of training sample is [3,32,32] or PyTorch will report error.

Then we can use cifar-10.py to train the network. Network structure is 

3*1->1*3->RELU->BN ->3*1->1*3->RELU->maxpool->BN ->3*1->1*3->RELU->BN ->3*1->1*3->RELU->avgpool->BN->3*1->1*3->RELU ->BN->3*1->1*3->RELU->BN->3*1->1*3->RELU->avgpool->BN->fc(256,256)->fc(256,10)

With 200 epochs the best validation error is 83%.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容