DeepLearnToolbox使用总结
GitHub链接:DeepLearnToolbox
DeepLearnToolbox
A Matlab toolbox for Deep Learning.
Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data. It is inspired by the human brain's apparent deep (layered, hierarchical) architecture. A good overview of the theory of Deep Learning theory is Learning Deep Architectures for AI
Directories included in the toolbox
NN/ - A library for Feedforward Backpropagation Neural Networks
CNN/ - A library for Convolutional Neural Networks
DBN/ - A library for Deep Belief Networks
SAE/ - A library for Stacked Auto-Encoders
CAE/ - A library for Convolutional Auto-Encoders
util/ - Utility functions used by the libraries
data/ - Data used by the examples
tests/ - unit tests to verify toolbox is working
For references on each library check REFS.md
Setup
- Download.
- addpath(genpath('DeepLearnToolbox'));
Windows下把文件夹加入 path 即可
%LiFeiteng path = pwd;
files = dir(path); for i = 3:length(files) if files(i).isdir
file = files(i).name;
addpath([path '/' file])
disp(['add ' file ' to path!'])
end end
我不打算解析代码,想从代码里面学算法是stupid的;有相应的论文,readlist,talk等可以去学习。
DeepLearnToolbox单隐藏层NN的优化策略:mini-Batch SGD
function [nn, L] = nntrain(nn, train_x, train_y, opts, val_x, val_y)
%NNTRAIN trains a neural net
% [nn, L] = nnff(nn, x, y, opts) trains the neural network nn with input x and
% output y for opts.numepochs epochs, with minibatches of size
% opts.batchsize. Returns a neural network nn with updated activations,
% errors, weights and biases, (nn.a, nn.e, nn.W, nn.b) and L, the sum
% squared error for each training minibatch. assert(isfloat(train_x), 'train_x must be a float');
assert(nargin == 4 || nargin == 6,'number ofinput arguments must be 4 or 6') loss.train.e = [];
loss.train.e_frac = [];
loss.val.e = [];
loss.val.e_frac = [];
opts.validation = 0;
if nargin == 6
opts.validation = 1;
end fhandle = [];
if isfield(opts,'plot') && opts.plot == 1
fhandle = figure();
end m = size(train_x, 1); batchsize = opts.batchsize;
numepochs = opts.numepochs; numbatches = m / batchsize; assert(rem(numbatches, 1) == 0, 'numbatches must be a integer'); L = zeros(numepochs*numbatches,1);
n = 1;
for i = 1 : numepochs
tic; kk = randperm(m);
for l = 1 : numbatches
batch_x = train_x(kk((l - 1) * batchsize + 1 : l * batchsize), :); %Add noise to input (for use in denoising autoencoder)
if(nn.inputZeroMaskedFraction ~= 0)
batch_x = batch_x.*(rand(size(batch_x))>nn.inputZeroMaskedFraction);
end batch_y = train_y(kk((l - 1) * batchsize + 1 : l * batchsize), :); nn = nnff(nn, batch_x, batch_y);
nn = nnbp(nn);
nn = nnapplygrads(nn); L(n) = nn.L; n = n + 1;
end t = toc; if ishandle(fhandle)
if opts.validation == 1
loss = nneval(nn, loss, train_x, train_y, val_x, val_y);
else
loss = nneval(nn, loss, train_x, train_y);
end
nnupdatefigures(nn, fhandle, loss, opts, i);
end disp(['epoch ' num2str(i) '/' num2str(opts.numepochs) '. Took ' num2str(t) ' seconds' '. Mean squared error on training set is ' num2str(mean(L((n-numbatches):(n-1))))]);
nn.learningRate = nn.learningRate * nn.scaling_learningRate;
end
end
1.不管是在 nntrain、
nnbp还是nnapplygrads中我都没看到 对算法收敛性的判断,
而且在实测的过程中 有观察到 epoch过程中 mean-squared-error有 下降-上升-下降 的走势——微小抖动在SGD中 算是正常
多数还都是在下降(epoch我一般设为 10-40,这个值可能偏小;Hinton 06 science的文章代码记得epoch了200次,我跑了3天也没跑完)
在SAE/CNN等中 也没看到收敛性的判断。
2.CAE 没有完成
3.dropout的优化策略也可以选择
我测试了 SAE CNN等,多几次epoch(20-30),在MNIST上正确率在 97%+的样子。
其实cost-function 可以有不同的选择,如果使用 UFLDL的优化方式(固定的优化方法,传入cost-function的函数句柄),在更改cost-function上会更自由。
可以改进的地方:
1. mini-Bathch SGD算法 增加收敛性判断
2.增加 L-BFGS/CG等优化算法
3.完善CAE等
4.增加min KL-熵的 Sparse Autoencoder等
5.优化算法增加对 不同cost-function的支持
DeepLearnToolbox使用总结的更多相关文章
- 普通程序员如何转向AI方向
眼下,人工智能已经成为越来越火的一个方向.普通程序员,如何转向人工智能方向,是知乎上的一个问题.本文是我对此问题的一个回答的归档版.相比原回答有所内容增加. 一. 目的 本文的目的是给出一个简单的,平 ...
- Deep learning:五十一(CNN的反向求导及练习)
前言: CNN作为DL中最成功的模型之一,有必要对其更进一步研究它.虽然在前面的博文Stacked CNN简单介绍中有大概介绍过CNN的使用,不过那是有个前提的:CNN中的参数必须已提前学习好.而本文 ...
- 【深度学习Deep Learning】资料大全
最近在学深度学习相关的东西,在网上搜集到了一些不错的资料,现在汇总一下: Free Online Books by Yoshua Bengio, Ian Goodfellow and Aaron C ...
- DeepLearning——CNN
工具箱下载 https://github.com/rasmusbergpalm/DeepLearnToolbox CNN_demo代码解析 http://blog.csdn.net/zouxy09/a ...
- AI方向
普通程序员如何转向AI方向 眼下,人工智能已经成为越来越火的一个方向.普通程序员,如何转向人工智能方向,是知乎上的一个问题.本文是我对此问题的一个回答的归档版.相比原回答有所内容增加. 一. 目的 ...
- (转) Awesome Deep Learning
Awesome Deep Learning Table of Contents Free Online Books Courses Videos and Lectures Papers Tutori ...
- Deep learning:四十二(Denoise Autoencoder简单理解)
前言: 当采用无监督的方法分层预训练深度网络的权值时,为了学习到较鲁棒的特征,可以在网络的可视层(即数据的输入层)引入随机噪声,这种方法称为Denoise Autoencoder(简称dAE),由Be ...
- Deep learning:四十一(Dropout简单理解)
前言 训练神经网络模型时,如果训练样本较少,为了防止模型过拟合,Dropout可以作为一种trikc供选择.Dropout是hintion最近2年提出的,源于其文章Improving neural n ...
- 卷积神经网络CNN(Convolutional Neural Networks)没有原理只有实现
零.说明: 本文的所有代码均可在 DML 找到,欢迎点星星. 注.CNN的这份代码非常慢,基本上没有实际使用的可能,所以我只是发出来,代表我还是实践过而已 一.引入: CNN这个模型实在是有些年份了, ...
随机推荐
- Oracle中的over(partition by...)分析函数及开窗函数
假设有一张表student Name Score InsertTime (Name:姓名 Score:成绩 InsertTime:考试时间) 张三 20 2015-08-08 ...
- html.day02
1.链接标签 a <a href=”http://www.baidu.com”></a> <img src=”aaa”/> 一般情况下: 来源 用 src ...
- B/S系统间跨域单点登录设计思路
基于B/S系统间单点登录 此处说的单点登录的概念,即不同系统公用一个登录界面.一处系统通过登录验证,在接入的各系统均为登录状态.一般有两种情景: 1) 一级域名相同 例如:tieba.baidu.c ...
- (转)ThinkPHP find方法 查询一条数据记录
find() ThinkPHP find() 方法是和 select() 用法类似的一个方法,不同之处 find() 查询出来的始终只有一条数据,即系统自动加上了 LIMIT 1 限制. 当确认查询的 ...
- 用ASP.net判断上传文件类型的三种方法
一. 安全性比较低,把文本文件1.txt改成1.jpg照样可以上传,但其实现方法容易理解,实现也简单,所以网上很多还是采取这种方法. Boolean fileOk = false; ...
- 一个tomcat部署俩个java web项目
2.发布的时候可以发布成war包,用项目名称右键export,选择项目名称,还有发布的路径,即tomcat下的路径,参考http://zhidao.baidu.com/link?url=imOu0Uu ...
- 认识CSS样式
CSS全称为“层叠样式表 (Cascading Style Sheets)”,它主要是用于定义HTML内容在浏览器内的显示样式,如文字大小.颜色.字体加粗等. 如下列代码: p{ font-size: ...
- HDU 4632 CF 245H 区间DP(回文)
先说HDU 4632这道题,因为比较简单,题意就是给你一个字符串,然后给你一个区间,叫你输出区间内所有的回文子序列,注意是回文子序列,不是回文字串. 用dp[i][j]表示区间[i,j]内的回文子序列 ...
- Qt信号槽连接在有默认形参下的情况思考
写下这个给自己备忘,比如函数 ) 你在调用端如论是test(3)或者test(),都可以正确调用到这个函数. 但是,如果放到Qt中的信号槽的话,这个还是值得讲一讲的,不然的话,可能会引起相应的误会. ...
- 百度分享share.js插件
//百度分享window._bd_share_config = { common : { bdText : '分享标题', bdDesc : '分享描述', bdUrl : '分享链接', bdPic ...