百度了半天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. 浙江大学PAT考试1009~1012(1010上帝是冠军。。)

    哎,pat1010即使java书面,只有java书面,还增加了两个点,,.啊,智商捉佳,主要pat有些不给明确的范围.造成遐想空间.. 还是按顺序介绍.. 题目地址:http://pat.zju.ed ...

  2. Oracle / PLSQL写语句的时候常使用的函数

    最近在学习数据库方面的知识,做个标记. 这里有英文解释,建议多看看英文文档: https://www.techonthenet.com/oracle/functions/ 下面开始记录一下,自己在Or ...

  3. 移动应用跨平台框架江湖将现终结者?速来参拜来自Facebook的React Native

    React Native使用初探 February 06 2015 Facebook让所有React Conf的参与人员都可以初尝React Native的源码---一个编写原生移动应用的方法.该方法 ...

  4. .Net IOC 之Unity

    .Net IOC 之Unity 在码农的世界里,为了应付时常变更的客户需求,增加的架构的客扩展性,减少工作量.IOC诞生了,它是一种可以实现依赖注入和控制对象生命周期的容器.最为一个有节操.有追求的码 ...

  5. 图解IntelliJ IDEA v13应用服务器的运行配置

    初步了解IntelliJ IDEA v13应用服务器以后,接下来我们将继续设置应用服务器的运行配置. Artifacts是IDE在通过运行配置时部署的一个服务.Artifacts包括名称.类型.输出目 ...

  6. .NET 开源了,Visual Studio 开始支持 Android 和 iOS 程序编写并自带 Android 模拟器

    .NET 开源了,Visual Studio 开始支持 Android 和 iOS 程序编写并自带 Android 模拟器 北京时间今天凌晨的 Connect(); 大会上,多少程序员的假想成为现实. ...

  7. extern用法汇总

    extern 在源文件A里定义的函数,在其他源文件中是看不见的(即不能訪问).为了在源文件B里能调用这个函数,应该在B的头部加上一个外部声明: extern   函数原型: 这样,在源文件B里也能够调 ...

  8. Controller 的 Action 只接受 Ajax 请求

    ASP.NET MVC 使 Controller 的 Action 只接受 Ajax 请求. 2014-08-27 14:19 by h82258652, 555 阅读, 2 评论, 收藏, 编辑 首 ...

  9. 读书笔记—CLR via C#字符串及文本

    前言 这本书这几年零零散散读过两三遍了,作为经典书籍,应该重复读反复读,既然我现在开始写博了,我也准备把以前觉得经典的好书重读细读一遍,并且将笔记整理到博客中,好记性不如烂笔头,同时也在写的过程中也可 ...

  10. rapid-framework脚手架快速搭建springMVC框架项目

    rapid-framework介绍:   一个类似ruby on rails的java web快速开发脚手架,本着不重复发明轮子的原则,框架只是将零散的struts(struts2)+spring+h ...