【转帖】DeepLearnToolbox

Matlab/Octave toolbox for deep learning. Includes Deep Belief Nets, Stacked Autoencoders, Convolutional Neural Nets, Convolutional Autoencoders and vanilla Neural Nets. Each method has examples to get you started.

DeepLearnToolbox/

         rasmusbergpalm        authored on May 11

  Failed to load latest commit information.
                        CAE           merged upstream/master                        a year ago          
                        CNN           fixed a small bug for Matlab calling undefined OCTAVE_VERSION for con…                        11 months ago          
                        DBN           fix assertion                        a year ago          
                        NN           Merge pull request #93 from golden1232004/master                        7 months ago          
                        SAE           fixes #21. Thanks @skaae                        2 years ago          
                        data           Few changes to make CNNs work on Octave.                        a year ago          
                        tests           Update test_example_CNN.m                        a year ago          
                        util           fixed a small bug for Matlab calling undefined OCTAVE_VERSION for con…                        11 months ago          
                        .travis.yml           Minor changes to CI script                        a year ago          
                        CONTRIBUTING.md           merged upstream/master                        a year ago          
                        LICENSE           added license. fixes #10. thanks                        2 years ago          
                        README.md           Add a Bitdeli badge to README                        a year ago          
                        README_header.md           Update README_header.md                        a year ago          
                        REFS.md           Added links to REF.md references.                        3 years ago          
                        create_readme.sh           updated readme                        2 years ago          

README.md

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

For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.

If you use this toolbox in your research please cite Prediction as a candidate for learning deep hierarchical models of data

@MASTERSTHESIS\{IMM2012-06284,
    author       = "R. B. Palm",
    title        = "Prediction as a candidate for learning deep hierarchical models of data",
    year         = "2012",
}

Contact: rasmusbergpalm at gmail dot com

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

  1. Download.
  2. addpath(genpath(‘DeepLearnToolbox‘));

Known errors

test_cnn_gradients_are_numerically_correct fails on Octave because of a bug in Octave‘s convn implementation. See http://savannah.gnu.org/bugs/?39314

test_example_CNN fails in Octave for the same reason.

Example: Deep Belief Network

function test_example_DBN
load mnist_uint8;

train_x = double(train_x) / 255;
test_x  = double(test_x)  / 255;
train_y = double(train_y);
test_y  = double(test_y);

%%  ex1 train a 100 hidden unit RBM and visualize its weights
rand(‘state‘,0)
dbn.sizes = [100];
opts.numepochs =   1;
opts.batchsize = 100;
opts.momentum  =   0;
opts.alpha     =   1;
dbn = dbnsetup(dbn, train_x, opts);
dbn = dbntrain(dbn, train_x, opts);
figure; visualize(dbn.rbm{1}.W‘);   %  Visualize the RBM weights

%%  ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NN
rand(‘state‘,0)
%train dbn
dbn.sizes = [100 100];
opts.numepochs =   1;
opts.batchsize = 100;
opts.momentum  =   0;
opts.alpha     =   1;
dbn = dbnsetup(dbn, train_x, opts);
dbn = dbntrain(dbn, train_x, opts);

%unfold dbn to nn
nn = dbnunfoldtonn(dbn, 10);
nn.activation_function = ‘sigm‘;

%train nn
opts.numepochs =  1;
opts.batchsize = 100;
nn = nntrain(nn, train_x, train_y, opts);
[er, bad] = nntest(nn, test_x, test_y);

assert(er < 0.10, ‘Too big error‘);

Example: Stacked Auto-Encoders

function test_example_SAE
load mnist_uint8;

train_x = double(train_x)/255;
test_x  = double(test_x)/255;
train_y = double(train_y);
test_y  = double(test_y);

%%  ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN
%  Setup and train a stacked denoising autoencoder (SDAE)
rand(‘state‘,0)
sae = saesetup([784 100]);
sae.ae{1}.activation_function       = ‘sigm‘;
sae.ae{1}.learningRate              = 1;
sae.ae{1}.inputZeroMaskedFraction   = 0.5;
opts.numepochs =   1;
opts.batchsize = 100;
sae = saetrain(sae, train_x, opts);
visualize(sae.ae{1}.W{1}(:,2:end)‘)

% Use the SDAE to initialize a FFNN
nn = nnsetup([784 100 10]);
nn.activation_function              = ‘sigm‘;
nn.learningRate                     = 1;
nn.W{1} = sae.ae{1}.W{1};

% Train the FFNN
opts.numepochs =   1;
opts.batchsize = 100;
nn = nntrain(nn, train_x, train_y, opts);
[er, bad] = nntest(nn, test_x, test_y);
assert(er < 0.16, ‘Too big error‘);

Example: Convolutional Neural Nets

function test_example_CNN
load mnist_uint8;

train_x = double(reshape(train_x‘,28,28,60000))/255;
test_x = double(reshape(test_x‘,28,28,10000))/255;
train_y = double(train_y‘);
test_y = double(test_y‘);

%% ex1 Train a 6c-2s-12c-2s Convolutional neural network
%will run 1 epoch in about 200 second and get around 11% error.
%With 100 epochs you‘ll get around 1.2% error
rand(‘state‘,0)
cnn.layers = {
    struct(‘type‘, ‘i‘) %input layer
    struct(‘type‘, ‘c‘, ‘outputmaps‘, 6, ‘kernelsize‘, 5) %convolution layer
    struct(‘type‘, ‘s‘, ‘scale‘, 2) %sub sampling layer
    struct(‘type‘, ‘c‘, ‘outputmaps‘, 12, ‘kernelsize‘, 5) %convolution layer
    struct(‘type‘, ‘s‘, ‘scale‘, 2) %subsampling layer
};
cnn = cnnsetup(cnn, train_x, train_y);

opts.alpha = 1;
opts.batchsize = 50;
opts.numepochs = 1;

cnn = cnntrain(cnn, train_x, train_y, opts);

[er, bad] = cnntest(cnn, test_x, test_y);

%plot mean squared error
figure; plot(cnn.rL);

assert(er<0.12, ‘Too big error‘);

Example: Neural Networks

function test_example_NN
load mnist_uint8;

train_x = double(train_x) / 255;
test_x  = double(test_x)  / 255;
train_y = double(train_y);
test_y  = double(test_y);

% normalize
[train_x, mu, sigma] = zscore(train_x);
test_x = normalize(test_x, mu, sigma);

%% ex1 vanilla neural net
rand(‘state‘,0)
nn = nnsetup([784 100 10]);
opts.numepochs =  1;   %  Number of full sweeps through data
opts.batchsize = 100;  %  Take a mean gradient step over this many samples
[nn, L] = nntrain(nn, train_x, train_y, opts);

[er, bad] = nntest(nn, test_x, test_y);

assert(er < 0.08, ‘Too big error‘);

%% ex2 neural net with L2 weight decay
rand(‘state‘,0)
nn = nnsetup([784 100 10]);

nn.weightPenaltyL2 = 1e-4;  %  L2 weight decay
opts.numepochs =  1;        %  Number of full sweeps through data
opts.batchsize = 100;       %  Take a mean gradient step over this many samples

nn = nntrain(nn, train_x, train_y, opts);

[er, bad] = nntest(nn, test_x, test_y);
assert(er < 0.1, ‘Too big error‘);

%% ex3 neural net with dropout
rand(‘state‘,0)
nn = nnsetup([784 100 10]);

nn.dropoutFraction = 0.5;   %  Dropout fraction
opts.numepochs =  1;        %  Number of full sweeps through data
opts.batchsize = 100;       %  Take a mean gradient step over this many samples

nn = nntrain(nn, train_x, train_y, opts);

[er, bad] = nntest(nn, test_x, test_y);
assert(er < 0.1, ‘Too big error‘);

%% ex4 neural net with sigmoid activation function
rand(‘state‘,0)
nn = nnsetup([784 100 10]);

nn.activation_function = ‘sigm‘;    %  Sigmoid activation function
nn.learningRate = 1;                %  Sigm require a lower learning rate
opts.numepochs =  1;                %  Number of full sweeps through data
opts.batchsize = 100;               %  Take a mean gradient step over this many samples

nn = nntrain(nn, train_x, train_y, opts);

[er, bad] = nntest(nn, test_x, test_y);
assert(er < 0.1, ‘Too big error‘);

%% ex5 plotting functionality
rand(‘state‘,0)
nn = nnsetup([784 20 10]);
opts.numepochs         = 5;            %  Number of full sweeps through data
nn.output              = ‘softmax‘;    %  use softmax output
opts.batchsize         = 1000;         %  Take a mean gradient step over this many samples
opts.plot              = 1;            %  enable plotting

nn = nntrain(nn, train_x, train_y, opts);

[er, bad] = nntest(nn, test_x, test_y);
assert(er < 0.1, ‘Too big error‘);

%% ex6 neural net with sigmoid activation and plotting of validation and training error
% split training data into training and validation data
vx   = train_x(1:10000,:);
tx = train_x(10001:end,:);
vy   = train_y(1:10000,:);
ty = train_y(10001:end,:);

rand(‘state‘,0)
nn                      = nnsetup([784 20 10]);
nn.output               = ‘softmax‘;                   %  use softmax output
opts.numepochs          = 5;                           %  Number of full sweeps through data
opts.batchsize          = 1000;                        %  Take a mean gradient step over this many samples
opts.plot               = 1;                           %  enable plotting
nn = nntrain(nn, tx, ty, opts, vx, vy);                %  nntrain takes validation set as last two arguments (optionally)

[er, bad] = nntest(nn, test_x, test_y);
assert(er < 0.1, ‘Too big error‘);
时间: 2024-07-30 20:05:43

【转帖】DeepLearnToolbox的相关文章

jdk和jre是什么?都有什么用?(转帖)

jdk和jre是什么?都有什么用?(转帖) 文章分类:Java编程 大家肯定在安装JDK的时候会有选择是否安装单独的jre,一般都会一起安装,我也建议大家这样做.由于这样更能帮助大家弄清楚它们的差别: Jre   是java   runtime   environment,   是java程序的执行环境.既然是执行,当然要包括jvm,也就是大家熟悉的虚拟机啦,   还有全部java类库的class文件,都在lib文件夹下打包成了jar.大家能够自己验证.至于在windows上的虚拟机是哪个文件呢

Synplify9.6.2破解(转帖)

Synplify9.6.2破解(转帖)   转载自:http://www.cnblogs.com/mark-sun/archive/2012/02/26/2368773.html Abstract本文介紹如何破解Synplify Pro 9.6.2. IntroductionStep 1:安裝Synplify Pro Step 2:選擇Floating (License is on a license server) Step 3:稍後會設定SYNPLCTYD_LICENSE_FILE系統變數,

转帖-[教程] Win7精简教程(简易中度)2016年8月-0day

[教程] Win7精简教程(简易中度)2016年8月 0day 发表于 2016-8-19 16:08:41  https://www.itsk.com/thread-370260-1-1.html 本帖最后由 0day 于 2016-8-23 20:15 编辑 1.资源准备1.1 Win7 SP1 专业版原版(版本不限)1.2 Win7 SP1 便捷更新包2016年4月 本帖隐藏的内容 KB3020369 32位:https://download.microsoft.com/download/

FastReport中的frxRichView如何设置二种不同的字体 [问题点数:100分,结帖人LIULIVERYOK]

FastReport中的frxRichView如何设置二种不同的字体 [问题点数:100分,结帖人LIULIVERYOK] 在frxRichView中有几段文字,如何给第一段文字设置不同的字体? 感激大虾们能给下答案!!! 来源:http://bbs.csdn.net/topics/390952125?page=1 解答: frxReport1->LoadFromFile(L"D:\\ccrun\\123.fr3"); TfrxRichView *f = (TfrxRichVie

实用科普帖!无线路由器1/2/3根天线有啥区别?

“天线越多覆盖越广,天线越多信号越强,总之天线越多的无线路由器就越好.” ——觉得很“常识”的朋友可以继续往下看正文了,觉得这种话题弱爆了.小编是那个什么的估计也不会点进来.还是那句话,我们的干货帖大多数是为了扫盲,欢迎各位大神补充.指正…… 首先,大家也应该注意到了,老一代无线路由器的天线肯定不会超过一根.这里的“老一代”指的是802.11n协议以前的802.11a/b/g路由,老的54M产品就只有一根天线. 这样的话,802.11n显然成了一条分水岭,也是从那时开始天线不再只有孤零零的一根(

转帖: 代理模式在游戏里的应用

原帖地址及作者的github: http://alloyteam.github.com/StreetFighter/ 代理模式的定义是把对一个对象的访问, 交给另一个代理对象来操作. 举一个例子, 我在追一个MM想给她送一束花,但是我因为我性格比较腼腆,所以我托付了MM的一个好朋友来送. 这个例子不是非常好, 至少我们没看出代理模式有什么大的用处,因为追MM更好的方式是送一台宝马. 再举个例子,假如我每天都得写工作日报( 其实没有这么惨 ). 我的日报最后会让总监审阅. 如果我们都直接把日报发给

关于spring framework最新发布压缩包的下载问题 【非常非常新手帖】

关于spring framework最新发布压缩包的下载问题 [非常非常新手帖] - Java之道 - 博客频道 - CSDN.NET 最近,spirng官方改版,spring framework最新release的zip包已经在官网上找不着相应链接了,都改成maven构建下载的方式了,让初学者无从下载. 这里给大家提供springframework最新release的zip包的下载地址: ?1. 在浏览器中打开这个地址 http://maven.springframework.org/rele

(原)IOS之Metro实现,拥有windows磁帖效果(一)

IOS之Metro实现,拥有windows磁帖效果(一)  无废话-上渣图 所有转出“博客园”的朋友请您注明出处:http://www.cnblogs.com/xiaobajiu/p/4084717.html 扁平化来袭,微软的metro风格看起来很有科技感.于是想写个IOS的metro控件.搞了一段时间,有了模样.我的想法是metro和wp8的差不多,展示信息通过旋转来展示,触摸metro它会撬动或者吸弹.点击metro会执行事件,长按磁帖又可以执行其他事件. 结构:metro最外层是骨架层,

hadoop快速扫盲帖,从零了解hadoop

1.MapReduce理论简介 1.1 MapReduce编程模型 MapReduce采用"分而治之"的思想,把对大规模数据集的操作,分发给一个主节点管理下的各个分节点共同完成,然后通过整合各个节点的中间结果,得到最终结果.简单地说,MapReduce就是"任务的分解与结果的汇总". 在Hadoop中,用于执行MapReduce任务的机器角色有两个:一个是JobTracker:另一个是TaskTracker,JobTracker是用于调度工作的,TaskTracke