【deep learning学习笔记】注释yusugomori的RBM代码 --- 头文件
百度了半天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代码 --- 头文件的更多相关文章
- 【deep learning学习笔记】注释yusugomori的DA代码 --- dA.h
DA就是“Denoising Autoencoders”的缩写.继续给yusugomori做注释,边注释边学习.看了一些DA的材料,基本上都在前面“转载”了.学习中间总有个疑问:DA和RBM到底啥区别 ...
- [置顶]
Deep Learning 学习笔记
一.文章来由 好久没写原创博客了,一直处于学习新知识的阶段.来新加坡也有一个星期,搞定签证.入学等杂事之后,今天上午与导师确定了接下来的研究任务,我平时基本也是把博客当作联机版的云笔记~~如果有写的不 ...
- Deep Learning 学习笔记(8):自编码器( Autoencoders )
之前的笔记,算不上是 Deep Learning, 只是为理解Deep Learning 而需要学习的基础知识, 从下面开始,我会把我学习UFDL的笔记写出来 #主要是给自己用的,所以其他人不一定看得 ...
- 【deep learning学习笔记】Recommending music on Spotify with deep learning
主要内容: Spotify是个类似酷我音乐的音乐站点.做个性化音乐推荐和音乐消费.作者利用deep learning结合协同过滤来做音乐推荐. 详细内容: 1. 协同过滤 基本原理:某两个用户听的歌曲 ...
- 【deep learning学习笔记】最近读的几个ppt(四)
这几个ppt都是在微博上看到的,是百度的一个员工整理的. <Deep Belief Nets>,31页的一个ppt 1. 相关背景 还是在说deep learning好啦,如特征表示云云. ...
- Neural Networks and Deep Learning学习笔记ch1 - 神经网络
近期開始看一些深度学习的资料.想学习一下深度学习的基础知识.找到了一个比較好的tutorial,Neural Networks and Deep Learning,认真看完了之后觉得收获还是非常多的. ...
- paper 149:Deep Learning 学习笔记(一)
1. 直接上手篇 台湾李宏毅教授写的,<1天搞懂深度学习> slideshare的链接: http://www.slideshare.net/tw_dsconf/ss-62245351? ...
- Deep Learning 学习笔记——第9章
总览: 本章所讲的知识点包括>>>> 1.描述卷积操作 2.解释使用卷积的原因 3.描述pooling操作 4.卷积在实践应用中的变化形式 5.卷积如何适应输入数据 6.CNN ...
- 【Deep Learning学习笔记】Dynamic Auto-Encoders for Semantic Indexing_Mirowski_NIPS2010
发表于NIPS2010 workshop on deep learning的一篇文章,看得半懂. 主要内容: 是针对文本表示的一种方法.文本表示可以进一步应用在文本分类和信息检索上面.通常,一篇文章表 ...
随机推荐
- 使用SqlBulkCopy导入数据至MS SQL Server
原文:使用SqlBulkCopy导入数据至MS SQL Server Insus.NET一直使用表类型来数据入MS SQL Server.参考<存储过程参数为DataTable>http: ...
- CSS3制作
目标是制作如下面DEMO显示的一个日历效果: HTML Markup 先来看看其结构: <div class="calendar"> <span class=&q ...
- Oracle并行查询出错
1.错误描写叙述 ORA-12801: 并行查询服务器P007中发出错误信号 ORA-01722:无效数字 12801.00000 -"error signaled in parallel ...
- UC编程:输入输出重定向(系统调用)
在Unix下,系统重定向是使用dup和dup2函数完成的 在学习使用这两个函数之前,必须要搞懂一个概念就是文件描述符 摘自:<文件描述符和文件指针的区别> 文件描述符就是open文件时产生 ...
- UC编程:环境变量的查询与修改
每个程序中都维护一个指向环境变量的指针char **environ; 子进程会从父进程继承环境变量.子进程环境变量的修改不一定会影响父进程 无关的多个进程之间修改环境变量不会互相影响 打印环境变量 [ ...
- Web前端框架与类库
Web前端框架与类库的思考 说起前端框架,我也是醉了.现在去面试或者和同行聊天,动不动就这个框架碉堡了,那个框架好犀利. 当然不是贬低框架,只是有一种杀鸡焉用牛刀的感觉.网站技术是为业务而存在的,除此 ...
- IE6浏览器不支持固定定位(position:fixed)解决方案
代码如下: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w ...
- vue.js源码精析
MVVM大比拼之vue.js源码精析 VUE 源码分析 简介 Vue 是 MVVM 框架中的新贵,如果我没记错的话作者应该毕业不久,现在在google.vue 如作者自己所说,在api设计上受到了很多 ...
- JAVA学习:内部类
一.内部类的访问规则: 1.内部类可以直接访问外部类中的成员,包括私有.格式为外部类名.this 2.外部类要访问内部类,必须建立内部类对象. 代码: class Outer { private in ...
- 关于readonly
当某个字段是引用类型,且该字段是readonly类型时,那么不可改变的是引用,而非引用的对象.如以下代码: public sealed class AType { public static read ...