ufldl 深度学习入门 第5发 线性解码器

这一节其实很简单,所谓线性解码器,就是将输出层的激活函数换成了线性函数,其他的没有变。

输出层用线性函数替代sigmoid函数的目的是使输出不再受限在[0,1]范围内。

数据集采用STL-10 彩色图像,但是是8×8的patches,不是原始的64×64图像。

导入数据集:load stlSampledPatches.得到矩阵patches, 192*100000,192=8*8*3

后面在卷积和池化中会用原始的64×64的STL-10图像作为输入。


inputSize = 8×8×3 = 192; 3个通道的颜色。

隐藏层的节点数400,lambda = 3e-3,beta = 5,sparsity = 0.035,这里对输入数据进行预处理,使用ZCA白化,对应的参数epsilon = 0.1;


 STEP 1: Create and modify sparseAutoencoderLinearCost.m to use a linear decoder,

这一步借助前面的 sparseAutoencoderCost.m ,更改最后一层的激活函数。andrew ng有一个习惯很好,每一步及时验证保证正确性,这一步同样还是利用数值计算检查梯度计算是否正确,而且设置了debug时的输入层和隐藏层节点数(8,5),保证debug时候速度很快。

下面的代码与sparseAutoencoderCost.m基本一样,只是改了2行语句,我用%@@注释了。

function [cost,grad] = sparseAutoencoderLinearCost(theta, visibleSize, hiddenSize, ...
                                             lambda, sparsityParam, beta, data)
% -------------------- YOUR CODE HERE --------------------
% Instructions:
%   Copy sparseAutoencoderCost in sparseAutoencoderCost.m from your
%   earlier exercise onto this file, renaming the function to
%   sparseAutoencoderLinearCost, and changing the autoencoder to use a
%   linear decoder.
% -------------------- YOUR CODE HERE --------------------                                    



% visibleSize: the number of input units (probably 64) 
% hiddenSize: the number of hidden units (probably 25) 
% lambda: weight decay parameter
% sparsityParam: The desired average activation for the hidden units (denoted in
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值