VGG Convolutional Neural Networks Practical(6)training data and labels

31 篇文章 1 订阅
17 篇文章 0 订阅

第3.1部分:培训数据和标签
第一步是加载图像data/ dots.jpg并使用提供的extractBlackBlobs函数提取图像中的所有黑点。
这里写图片描述

% Load an image
im = rgb2gray(im2single(imread('data/dots.jpg'))) ;

% Compute the location of black blobs in the image
[pos,neg] = extractBlackBlobs(im) ;

数组pos和neg现在包含像素标签,并将用作CNN的监督训练的注释。 这些注释可以可视化如下:

figure(1) ; clf ; 
subplot(1,3,1) ; imagesc(im) ; axis equal ; title('image') ;
subplot(1,3,2) ; imagesc(pos) ; axis equal ; title('positive points (blob centres)') ;
subplot(1,3,3) ; imagesc(neg) ; axis equal ; title('negative points (not a blob)') ;
colormap gray ;

任务:检查pos和neg:
pos包含对应于每个斑点中心的单个真值;
neg包含对于足够远离斑点的每个像素的真实值。
是否有pos和neg都为false的像素?

第3.2部分:图像预处理
在我们尝试训练CNN之前,对图像进行预处理以去除其平均值。 它也通过应用标准偏差3个像素的高斯核进行平滑:

% Pre-smooth the image
im = vl_imsmooth(im,3) ;

% Subtract median value
im = im - median(im(:)) ;

我们稍后将回到这个预处理步骤。

第3.3部分:使用梯度下降学习
算法的参数设置如下:

numIterations = 500 ;
rate = 5 ;
momentum = 0.9 ;
shrinkRate = 0.0001 ;
plotPeriod = 10 ;

任务:
检查文件exercise3.m中的代码。 确保代码正在实现上述算法。 特别注意前向和后向通过以及如何计算目标函数及其导数。
运行算法并观察结果。 然后回答以下问题:
学习的滤波器应该类似于众所周知的微分算子的离散化。是 哪一个呢?
与绝对值的平均值相比,过滤器值的平均值是多少?
再次运行算法,观察相对于值0和1的正像素和负像素的得分的直方图的演变。回答以下问题:
目标函数是否单调减少?
随着直方图的演变,您可以在优化中识别至少两个“阶段”?
一旦收敛,分数是否按你期望的方式分布?

% -------------------------------------------------------------------------
% Part 3: Learning a simple CNN
% -------------------------------------------------------------------------

setup ;

% -------------------------------------------------------------------------
% Part 3.1: Load an example image and generate its labels
% -------------------------------------------------------------------------

% Load an image
im = rgb2gray(im2single(imread('data/dots.jpg'))) ;

% Compute the location of black blobs in the image
[pos,neg] = extractBlackBlobs(im) ;

figure(1) ; clf ;
subplot(1,3,1) ; imagesc(im) ; axis equal ; title('image') ;
subplot(1,3,2) ; imagesc(pos) ; axis equal ; title('positive points (blob centres)') ;
subplot(1,3,3) ; imagesc(neg) ; axis equal ; title('negative points (not a blob)') ;
colormap gray ;

% -------------------------------------------------------------------------
% Part 3.2: Image preprocessing
% -------------------------------------------------------------------------

% Pre-smooth the image
im = vl_imsmooth(im,3) ;

% Subtract median value
im = im - median(im(:)) ;

% -------------------------------------------------------------------------
% Part 3.3: Learning with stochastic gradient descent
% -------------------------------------------------------------------------

% SGD parameters:

我这里因为
这里写图片描述
出了一点问题,觉得问题是vlfeat没有编译好的问题,附上链接:
Windows 10 下 VS2013 和 matlab2015b 编译 vlfeat-0.9.20 图文详细版 - 博客频道 - CSDN.NET
等这个问题解决了再来写后续···现在看起来好麻烦,我想先往后看···

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值