【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的一篇文章,看得半懂. 主要内容: 是针对文本表示的一种方法.文本表示可以进一步应用在文本分类和信息检索上面.通常,一篇文章表 ...
随机推荐
- Hibernat之关系的处理一对一处理
第一步:编写两个pojo,比如一个学生表一个班级表 这里使用注解. 需要 公司表: package com.qcf.pox; import javax.persistence.CascadeType ...
- cform 开发框架介绍
CForm是从2012年开始研发的一套灵活,易用,简单,成熟的中小型应用系统开发框架.目前已成功应用在浙江大学.温州科技职业学院.广西农业局.青岛市农业局.乐清妇保院.老博会.婚尚起义结婚网等单位. ...
- 【hoj】2651 pie 二分查找
二分查找是一个非常主要的算法,针对的是有序的数列,通过中间值的大小来推断接下来查找的是左半段还是右半段,直到中间值的大小等于要找到的数时或者中间值满足一定的条件就返回,所以当有些问题要求在一定范围内找 ...
- selenium2入门 用Yaml文件进行元素管理 (五)
比如界面有一个按钮,id号是test.如果进行对象化的话,就是test.click就可以了.不用每次都要去创建test对象.如果id号变了,我们也只需要改一下test的名称就行了. 使用Yaml需要用 ...
- Windows 8 常用第三方SDK使用概览
原文:Windows 8 常用第三方SDK使用概览 应用开发过程中,我们或多或少会使用到第三方的公司平台的功能,例如:新浪微博.人人网.高德地图等. 那么在Windows 8 Store App开发中 ...
- unix域套接字UDP网络编程
unix域套接字UDP网络编程,服务器如下面: #include <stdio.h> #include <stdlib.h> #include <string.h> ...
- ASP.NET MVC项目
ASP.NET MVC项目里创建一个aspx视图 先从控制器里添加视图 视图引擎选"ASPX(C#)",使用布局或模板页不要选. 在Views\EAV目录里,生成的aspx是个单独 ...
- DHTML【3】--HTML
从这一节开始我们就开始介绍HTML的标签了,首先我们来介绍Form标签. Form标签也称Form表单,From是与服务器交互最重要的标签,此标签必须做到随手就写,写完就正常运行的地步. 那么什么是F ...
- 手机APP下单支付序列图
今天安装了Visio,学习了下如何使用,画了一下公司现在项目的下单支付序列图,话就不多说了,直接上图,处女作,欢迎指正!
- 列表类型转换(ConvertList<TSource, TResult>)
性能优化-列表类型转换(ConvertList<TSource, TResult>) 2013-12-16 16:55 by stevey, 426 阅读, 7 评论, 收藏, 编辑 之前 ...