1.使用深度学习做目标检测
上一篇博客已经讲解了怎么用matlab导入数据。
[trainingImages,trainingLabels,testImages,testLabels] = helperCIFAR10Data.load('cifar10Data');
使用这个指令就可以导入CIFAR-10 data的数据。
使用下面指令查看样本和图片大小:
size(trainingImages)
CIFAR-10 数据集有10类,使用指令列出:
numImageCategories = 10;
categories(trainingLabels)
1.接下来我们来建立CNN模型,这里建立输入层:
% Create the image input layer for 32x32x3 CIFAR-10 images
[height, width, numChannels, ~] = size(trainingImages);
imageSize = [height width numChannels];
inputLayer = imageInputLayer(imageSize)
2.建立网络中间层
% Convolutional layer parameters filter size
filterSize = [5 5];
numFilters = 32;
middleLayers = [
% The first convolutional layer has a bank of 32 5x5x3 filters. A
% symmetric padding of 2 pixels is added to ensure that image borders
% are included in the processing. This is important to avoid
% information at the borders being washed away too early in the
% network.
convolution2dLayer(filterSize, numFilters, 'Padding', 2) %(n+2p-f)/s+1
% Note that the third dimension of the filter can be omitted because it
% is automatically deduced based on the connec