百度了半天yusugomori,也不知道他是谁。不过这位老兄写了deep learning的代码,包括RBM、逻辑回归、DBN、autoencoder等,实现语言包括c、c++、java、python等。是学习的好材料。代码下载地址:https://github.com/yusugomori/DeepLearning。不过这位老兄不喜欢写注释,而且这些模型的原理、公式什么的,不了解的话就看不懂代码。我从给他写注释开始,边看资料、边理解它的代码、边给他写上注释。

工具包中RBM的实现包含了两个文件,RBM.h和RBM.cpp。RBM.h添加注释后,如下:

class RBM
{
public:
// the number of training sample
int N;
// the number of visiable node
int n_visible;
// the number of hidden node
int n_hidden;
// the weight connecting the visiable node and the hidden node
double **W;
// the bias of hidden node
double *hbias;
// the bias of visiable node
double *vbias; public:
// construct the RBM by input parameters
RBM (int, // N
int, // n_visible
int, // n_hidden
double**, // W
double*, // hbias
double* // vbias
);
// destructor, release all the memory of parameters
~RBM ();
// CD-k algorithm to train RBM
void contrastive_divergence (int*, // one input sample
double, // the learning rate
int // the k of CD-k, it is usually 1
); // these the functions of Gibbs sample // sample the hidden node given the visiable node, 'sample' means calculating
// 1. the output probability of the hidden node given the input of visiable node
// and the weight of current RBM; 2. the 0-1 state of hidden node by a binomial
// distribution given the calculated output probability of this hidden node
void sample_h_given_v (int*, // one input sample from visiable nodes -- input
double*, // the output probability of hidden nodes -- output
int* // the calculated 0-1 state of hidden node -- output
);
// sample the visiable node given the hidden node, 'sample' means calculating
// 1. the output probability of the visiable node given the input of hidden node
// and the weight of current RBM; 2. the 0-1 state of visiable node by a binomial
// distribution given the calculated output probability of this visiable node
void sample_v_given_h (int*, // one input sample from hidden nodes -- input
double*, // the output probability of visiable nodes -- output
int* // the calculated 0-1 state of visiable node -- output
);
// 'propup' -- probability up. It's called by the 'sample_x_given_x' function and the reconstruct funciton
// To calculate the probability in 'upper' node given the input from 'lower' node in RBM
// note: what is the 'up' and 'down'? the visiable node is below (down) the hidden node.
// 'probability up' means calculating the probability of hidden node given the visiable node
// return value: the output probability of the hidden node given the input of visiable node
// and the weight of current RBM
// the probability is : p (hi|v) = sigmod ( sum_j(vj * wij) + bi)
double propup (int*, // one input sample from visiable node -- input
double*, // the weight W connecting one hidden node to all visible node -- input
double // the bias for this hidden node -- input
);
// 'propdown' -- probability down. It's called by the 'sample_x_given_x' function and the reconstruct funciton
// To calculate the probability in 'lower' node given the input from 'upper' node in RBM
// note: what is the 'up' and 'down'? the visiable node is below (down) the hidden node.
// 'probability down' means calculating the probability of visiable node given the hidden node
// return value: the output probability of the visiable node given the input of hidden node
// and the weight of current RBM
// the probability is : p (vi|h) = sigmod ( sum_j(hj * wij) + ci)
double propdown (int*, // one input sample from hidden node -- input
int, // the index of visiable node in the W matrix -- input
double // the bias for this visible node -- input
);
// 'gibbs_hvh' -- gibbs sample firstly from hidden node to visible node, then sample
// from visiable node to hidden node. It is called by contrastive_divergence.
void gibbs_hvh (int*, // one input sample from hidden node, h0 -- input
double*, // the output probability of visiable nodes -- output
int*, // the calculated 0-1 state of visiable node -- output
double*, // the output probability of reconstructed hidden node h1 -- output
int* // the calculated 0-1 state of reconstructed hidden node h1 -- output
);
// reconstruct the input visiable node by the trained RBM (so as to varify the RBM model)
void reconstruct (int*, // one input sample from visiable node
double* // the reconstructed output by RBM model
);
};

主要添加了函数说明、参数说明、计算说明、调用关系等。

【deep learning学习笔记】注释yusugomori的RBM代码 --- 头文件的更多相关文章

  1. 【deep learning学习笔记】注释yusugomori的DA代码 --- dA.h

    DA就是“Denoising Autoencoders”的缩写.继续给yusugomori做注释,边注释边学习.看了一些DA的材料,基本上都在前面“转载”了.学习中间总有个疑问:DA和RBM到底啥区别 ...

  2. [置顶] Deep Learning 学习笔记

    一.文章来由 好久没写原创博客了,一直处于学习新知识的阶段.来新加坡也有一个星期,搞定签证.入学等杂事之后,今天上午与导师确定了接下来的研究任务,我平时基本也是把博客当作联机版的云笔记~~如果有写的不 ...

  3. Deep Learning 学习笔记(8):自编码器( Autoencoders )

    之前的笔记,算不上是 Deep Learning, 只是为理解Deep Learning 而需要学习的基础知识, 从下面开始,我会把我学习UFDL的笔记写出来 #主要是给自己用的,所以其他人不一定看得 ...

  4. 【deep learning学习笔记】Recommending music on Spotify with deep learning

    主要内容: Spotify是个类似酷我音乐的音乐站点.做个性化音乐推荐和音乐消费.作者利用deep learning结合协同过滤来做音乐推荐. 详细内容: 1. 协同过滤 基本原理:某两个用户听的歌曲 ...

  5. 【deep learning学习笔记】最近读的几个ppt(四)

    这几个ppt都是在微博上看到的,是百度的一个员工整理的. <Deep Belief Nets>,31页的一个ppt 1. 相关背景 还是在说deep learning好啦,如特征表示云云. ...

  6. Neural Networks and Deep Learning学习笔记ch1 - 神经网络

    近期開始看一些深度学习的资料.想学习一下深度学习的基础知识.找到了一个比較好的tutorial,Neural Networks and Deep Learning,认真看完了之后觉得收获还是非常多的. ...

  7. paper 149:Deep Learning 学习笔记(一)

     1. 直接上手篇 台湾李宏毅教授写的,<1天搞懂深度学习> slideshare的链接: http://www.slideshare.net/tw_dsconf/ss-62245351? ...

  8. Deep Learning 学习笔记——第9章

    总览: 本章所讲的知识点包括>>>> 1.描述卷积操作 2.解释使用卷积的原因 3.描述pooling操作 4.卷积在实践应用中的变化形式 5.卷积如何适应输入数据 6.CNN ...

  9. 【Deep Learning学习笔记】Dynamic Auto-Encoders for Semantic Indexing_Mirowski_NIPS2010

    发表于NIPS2010 workshop on deep learning的一篇文章,看得半懂. 主要内容: 是针对文本表示的一种方法.文本表示可以进一步应用在文本分类和信息检索上面.通常,一篇文章表 ...

随机推荐

  1. Python学习笔记:概要

    1.print不同的互动解释语句输出和输出 在以下示例,我们分配字符串值到可变myString.先用print 要显示一个变量的内容, 其次是变量名,以显示. >>> myStrin ...

  2. InstallShield集成安装MSDE2000最小版本(二) fishout特许授权发布

    原文:InstallShield集成安装MSDE2000最小版本(二) fishout特许授权发布 原帖地址:http://blog.csdn.net/fishout/archive/2009/10/ ...

  3. win7 wifi 无Internet訪问权限或者有限的訪问权限

    自己家的无线路由器,手机和笔记本都使用正常,可是一台新笔记本连上之后总是提示"有限的訪问权限",无法连公网. 网上的非常多办法都无论用,什么设置静态IP或者重新启动路由,基本都是瞎 ...

  4. SQL点滴33—SQL中的字符串操作

    原文:SQL点滴33-SQL中的字符串操作 计算字符串长度len()用来计算字符串的长度 select sname ,len(sname) from student 字符串转换为大.小写lower() ...

  5. Android单元测试Junit (一)

    1.在eclips中建立一个Android工程,具体信息如下: 2.配置单元测试环境,打开AndroidManifest.xml,具体代码如下所示: <?xml version="1. ...

  6. C语言内存对齐(2)

    前两天参加了360测试实习生的笔试,碰到了一个有关c语言内存对齐的题目,回来后实现了一下,下面是代码: #include <stdio.h> #include <stdlib.h&g ...

  7. Lua 5.2 Reference Manual

    Lua 5.2 Reference Manual.pdf

  8. ventBroker简单实现

    C#编程实践—EventBroker简单实现 前言 话说EventBroker这玩意已经不是什么新鲜货了,记得第一次接触这玩意是在进第二家公司的时候,公司产品基础架构层中集成了分布式消息中间件,在.n ...

  9. linux下搭建SVN服务器完全手册-很强大!!!!!

    系统环境        RHEL5.4最小化安装(关iptables,关selinux) + ssh + yum 一,安装必须的软件包.        yum install subversion ( ...

  10. 在 InstantRails 环境下,安装使用 redMine

    在 InstantRails 环境下,安装使用 redMine 分类: Redmine2009-06-01 10:35 732人阅读 评论(0) 收藏 举报 characterrailsencodin ...