研究CNTK(五):ConvNet_CIFAR10.cntk、ConvNet_CIFAR10_DataAug.cntk

从任务上来说,识别物体是最艰难的,因为物体大小开关都会发生灵活变化,传统的神经网络识别这个几乎是不可能的任务,而卷积技术则克服了这一点,不过仍然需要依赖强大的计算量。

ConvNet中的模型是:

model = Sequential (
            Normalize {featMean, featScale} :
            ConvolutionalLayer {64, (3:3), pad = true} : ReLU :
            ConvolutionalLayer {64, (3:3), pad = true} : ReLU :
            MaxPoolingLayer {(3:3), stride = (2:2)} :


            ConvolutionalLayer {64, (3:3), pad = true} : ReLU :
            ConvolutionalLayer {64, (3:3), pad = true} : ReLU :
            MaxPoolingLayer {(3:3), stride = (2:2)} :


            DenseLayer {256} : Dropout : ReLU :
            DenseLayer {128} : Dropout : ReLU :


            LinearLayer {labelDim}
        )

因为使用了Sequential ,所以可以直接用“:”进行连接,步骤可以简单描述为输入正则化,卷积两次,池化,卷积两次,池化,全连接256,全连接128,输出。

与之前的并无太大区别,运行它需要在机器上,大概要个七八分钟,运行后看结果:

Minibatch[1-100]: errs = 17.563% * 1600; top5Errs = 0.750% * 1600
Minibatch[101-200]: errs = 19.563% * 1600; top5Errs = 1.438% * 1600
Minibatch[201-300]: errs = 17.188% * 1600; top5Errs = 1.875% * 1600
Minibatch[301-400]: errs = 17.875% * 1600; top5Errs = 0.813% * 1600
Minibatch[401-500]: errs = 18.313% * 1600; top5Errs = 0.875% * 1600
Minibatch[501-600]: errs = 17.938% * 1600; top5Errs = 1.000% * 1600
Minibatch[601-625]: errs = 20.000% * 400; top5Errs = 1.250% * 400
Final Results: Minibatch[1-625]: errs = 18.150% * 10000; top5Errs = 1.130% * 10000

错误率是18%左右,正确率为82%。

使用ConvNet_CIFAR10_DataAug.cntk,进行80次迭代,虽然意外硬盘空间满了没有计算完,不过正确率也仅到了85.156%,运行时间长了很多,提升只能说还算可观。

Starting minibatch loop.
(GPU): creating curand object with seed 148
(GPU): creating curand object with seed 149
 Epoch[75 of 80]-Minibatch[   1- 100, 14.29%]: ce = 0.43693989 * 6400; errs = 14.578% * 6400; time = 2.2431s; samplesPerSecond = 2853.3
 Epoch[75 of 80]-Minibatch[ 101- 200, 28.57%]: ce = 0.44393230 * 6400; errs = 14.703% * 6400; time = 2.1941s; samplesPerSecond = 2916.9
 Epoch[75 of 80]-Minibatch[ 201- 300, 42.86%]: ce = 0.45336273 * 6400; errs = 14.797% * 6400; time = 2.2024s; samplesPerSecond = 2906.0
 Epoch[75 of 80]-Minibatch[ 301- 400, 57.14%]: ce = 0.46737686 * 6400; errs = 15.250% * 6400; time = 2.1987s; samplesPerSecond = 2910.8
 Epoch[75 of 80]-Minibatch[ 401- 500, 71.43%]: ce = 0.45469894 * 6400; errs = 15.000% * 6400; time = 2.1968s; samplesPerSecond = 2913.3
 Epoch[75 of 80]-Minibatch[ 501- 600, 85.71%]: ce = 0.46115814 * 6400; errs = 15.000% * 6400; time = 2.1925s; samplesPerSecond = 2919.0
 Epoch[75 of 80]-Minibatch[ 601- 700, 100.00%]: ce = 0.45480957 * 6400; errs = 14.734% * 6400; time = 2.1945s; samplesPerSecond = 2916.4
Finished Epoch[75 of 80]: [Training] ce = 0.45361355 * 50000; errs = 14.844% * 50000; totalSamplesSeen = 3750000; learningRatePerSample = 1.5625001e-005; epochTime=17.2243s

 

值得注意的是在ConvNet_CIFAR10_DataAug.cntk中,使用的是ImageReader,而不是将图像都转换成数据文本,读文本时用的是CNTKTextFormatReader

    reader = {
        verbosity = 0 ; randomize = true
        deserializers = ({
            type = "ImageDeserializer" ; module = "ImageReader"
            file = "$dataDir$/train_map.txt"
            input = {
                features = { transforms = (
                    { type = "Crop" ; cropType = "random" ; cropRatio = 0.8 ; jitterType = "uniRatio" } :
                    { type = "Scale" ; width = 32 ; height = 32 ; channels = 3 ; interpolations = "linear" } :
                    { type = "Mean" ; meanFile = "$dataDir$/CIFAR-10_mean.xml" } :
                    { type = "Transpose" }
                )}
                labels = { labelDim = 10 }
            }
        })
    }

发表评论

电子邮件地址不会被公开。 必填项已用*标注