手把手教你用matlab做深度学习(一)- --CNN

这篇博客介绍了如何使用MATLAB进行深度学习,特别是构建卷积神经网络(CNN)进行目标检测。首先,通过指令导入CIFAR-10数据集,然后详细讲解了构建CNN模型的步骤,包括输入层、中间层、输出层的定义以及权重初始化。文章提到了训练选项,如使用sgdm优化器和训练过程的可视化。最终,展示了网络在测试集上的分类精度,并预告下篇将探讨如何提升训练精度。
摘要由CSDN通过智能技术生成

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
评论 90
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值