资源简介
MATLAB代码,里面包括代码运行的相关变量以及提供了下载数据的链接,可以通过代码直接下载数据,方便阅读。
代码片段和文件信息
%% Deep learning for classification on the MNIST dataset
% Copyright 2018 The MathWorks Inc.
%% Prepare the dataset
%准备数据集
% The MNIST dataset is a set of handwritten digits categorized 0-9 and is
% available at http://yann.lecun.com/exdb/mnist/.
%MNIST数据集是一组手写数字,分类为0-9,可以在http://yann.lecun.com/exdb/mnist/上找到。
% The following line will download (if necessary) and prepare the dataset
% to use in MATLAB.
%如有必要,下面的代码行将下载并准备好在MATLAB中使用的数据集。
[imgDataTrain labelsTrain imgDataTest labelsTest] = prepareData;
%% Let‘s look at a few of the images
%让我们看一些图片
% Randomize the images for display
%随机显示图像
warning off images:imshow:magnificationMustBeFitForDockedFigure
perm = randperm(numel(labelsTrain) 25);
subset = imgDataTrain(::1perm);
montage(subset)
%% How do we classify a digit?
%我们如何对数字进行分类?
% First we need a model - let‘s load one
load MNISTModel
% Predict the class of an image
%预测图像的类别
randIndx = randi(numel(labelsTest));
img = imgDataTest(::1randIndx);
actualLabel = labelsTest(randIndx);
predictedLabel = net.classify(img);
imshow(img);
title([‘Predicted: ‘ char(predictedLabel) ‘ Actual: ‘ char(actualLabel)])
%% Need a starting point? Check the documentation!
%需要一个起点?检查文档!
% search “deep learning“
%搜索“深度学习”
web(fullfile(docroot ‘nnet/deep-learning-training-from-scratch.html‘))
%% Prepare the CNN
% One of the simplest possible convnets it contains one convolutional
% layer one ReLU one pooling layer and one fully connected layer
%一个最简单的卷积网络,它包含一个卷积层,一个ReLU,一个池化层,和一个完全连接的层
layers = [ imageInputlayer([28 28 1])
convolution2dlayer(520)
relulayer
maxPooling2dlayer(2 ‘Stride‘ 2)
fullyConnectedlayer(10)
softmaxlayer
classificationlayer() ]
%% Attempt 1: Set training options and train the network
%%尝试1:设置训练选项并训练网络
miniBatchSize = 8192;
options = trainingOptions( ‘sgdm‘...
‘MiniBatchSize‘ miniBatchSize...
‘Plots‘ ‘training-progress‘);
net = trainNetwork(imgDataTrain labelsTrain layers options);
%% Attempt 2: Change the learning rate
%尝试2:改变学习速度
options = trainingOptions( ‘sgdm‘...
‘MiniBatchSize‘ miniBatchSize...
‘Plots‘ ‘training-progress‘...
‘InitialLearnRate‘ 0.0001);
net = trainNetwork(imgDataTrain labelsTrain layers options);
%% Attempt 3: Change the network architecture
%尝试3:更改网络架构
layers = [
imageInputlayer([28 28 1])
convolution2dlayer(316‘Padding‘1)
batchNormalizationlayer
relulayer
maxPooling2dlayer(2‘Stride‘2)
convolution2dlayer(332‘Padding‘1)
batchNormalizationlayer
relulayer
maxPooling2dlayer(2‘Stride‘2)
convolution2dlayer(364‘Padding‘1)
batchNormalizationlayer
relulayer
fullyConnectedlayer(10)
softmaxlayer
classificationlayer];
options = trainingOptions( ‘sgdm‘
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 505 2018-05-02 10:43 Demo1_MNIST\letterW.png
文件 211842 2018-05-02 10:43 Demo1_MNIST\MNISTModel.mat
文件 3727 2019-04-24 11:25 Demo1_MNIST\MNIST_Classification_Demo.m
文件 828512 2018-05-02 10:43 Demo1_MNIST\MNIST_Classification_Demo_Live.html
文件 503833 2018-05-02 10:43 Demo1_MNIST\MNIST_Classification_Demo_Live.mlx
文件 3508 2019-04-24 10:20 Demo1_MNIST\prepareData.m
目录 0 2019-04-25 11:14 Demo1_MNIST
----------- --------- ---------- ----- ----
1551927 7
- 上一篇:心电信号处理方法
- 下一篇:hsv空间双边滤波去雾MATLAB代码
相关资源
- MATLABDeepLearning.rar
- 《2017_MATLAB_DeepLearning》完整版-Phil K
- matlab深度学习工具箱254438
- matlab深度学习算法合集
- DeepLearnToolbox-master.zip
- 2017Matlab_DeepLearning配套代码
- DeepLearnToolbox 工具箱
- 深度学习的matlab的工具包(DeepLearnT
- Phil Kim-2017Matlab_DeepLearning电子书
- Matlab实现循环神经网络RNN
- 深度学习汽车目标检测matlab2017
- 深度学习matlab工具箱(DeepLearnToolbox
- 深度学习的常用工具箱(DeepLearnTool
- DeepLearnToolbox_matlab matlab实现的深度学
- DeepLearnToolbox-master2735393
- DeepLearnToolbox-master2734431
- Exercise1-Sparse-Autoencoder 网址:http://d
- DeepLearnToolbox-master
- DeepLearnToolbox-master 关于深度学习的一
- DeepLearnToolbox 深度学习工具包
- DeepLearnToolbox-master 深度学习工具箱的
- deeplearning_facerecognition 人脸识别
- DeepLearnToolbox-master 深度学习matlab工具
- DeepLearnToolbox-master 基于matlab的深度学
- Abalone Dataset
评论
共有 条评论