【deep learning学习笔记】注释yusugomori的DA代码 --- dA.cpp -- 训练
说实话,具体的训练公式,我没有自己推导,姑且认为他写的代码是对的。总体上看,用bp的方法。特殊之处,在于输入层和输出层是完完全全的“同一层”。
void dA::get_corrupted_input (
int *x, // the original input 0-1 vector -- input
int *tilde_x, // the resulted 0-1 vector gotten noised -- output
double p // the p probability of noise, binomial test -- input
)
{
for(int i=0; i<n_visible; i++)
{
if(x[i] == 0)
{
// if the state is 0, do noghing
tilde_x[i] = 0;
}
else
{
// if the state is 1, add the noise of p probability on it
tilde_x[i] = binomial(1, p);
}
}
} // Encode
void dA::get_hidden_values (
int *x, // the input from visible nodes
double *y // the output of hidden nodes
)
{
for(int i=0; i<n_hidden; i++)
{
// calculated sum_j(vj * wij) + bi
y[i] = 0;
for(int j=0; j<n_visible; j++)
{
y[i] += W[i][j] * x[j];
}
y[i] += hbias[i];
// sigmod (y)
y[i] = sigmoid(y[i]);
}
} // Decode
void dA::get_reconstructed_input (
double *y, // the input from hidden nodes
double *z // the output reconstructed of visible nodes
)
{
for(int i=0; i<n_visible; i++)
{
// calculated sum_j(hj * wij) + ci
z[i] = 0;
for(int j=0; j<n_hidden; j++)
{
z[i] += W[j][i] * y[j];
}
z[i] += vbias[i];
// sigmod (z)
z[i] = sigmoid(z[i]);
}
} void dA::train (
int *x, // the input sample from visiable node
double lr, // the learning rate
double corruption_level // corruption_level is the probability of noise
)
{
// the auto-encoder networks:
// input(visible) layer --> hidden layer --> output(visible) layer
// the input layer is the same as the output layer, the two layers are totally same.
// we train it by the standard bp algorithm, from output layer to the hidden layer, and to the input layer
// Here is the whole process: int *tilde_x = new int[n_visible]; // the noise input
double *y = new double[n_hidden]; // the output of hidden layer
double *z = new double[n_visible]; // the output of output layer, reconstruction double *L_vbias = new double[n_visible]; // temp value for visible bias
double *L_hbias = new double[n_hidden]; // temp value for hidden bias double p = 1 - corruption_level; // make the input sample noise by the p probability
get_corrupted_input(x, tilde_x, p);
// calculate the output of hidden nodes by the noise input, encode
get_hidden_values(tilde_x, y);
// reconstruct the input sample from visible nodes, decode
get_reconstructed_input(y, z); // update the bias of visible nodes
for(int i=0; i<n_visible; i++)
{
// the difference between input sample and the PROBABILITY of reconstructed probability of visible node
// it's different from RBM that in RBM we calcualte the difference between input sample and
// the 0-1 state of the reconstructed visiable node
// here use the standard bp algorithm, from visible layer to hidden layer
L_vbias[i] = x[i] - z[i];
// update the value by the learning rate
vbias[i] += lr * L_vbias[i] / N;
} // update the bias of hidden nodes
for(int i=0; i<n_hidden; i++)
{
// propgate the bias from visible nodes
// here use the standard bp algorithm, from visible layer to hidden layer
L_hbias[i] = 0;
for(int j=0; j<n_visible; j++)
{
L_hbias[i] += W[i][j] * L_vbias[j];
}
L_hbias[i] *= y[i] * (1 - y[i]);
hbias[i] += lr * L_hbias[i] / N;
} // update the weight of networks
for(int i=0; i<n_hidden; i++)
{
for(int j=0; j<n_visible; j++)
{
W[i][j] += lr * (L_hbias[i] * tilde_x[j] + L_vbias[j] * y[i]) / N;
}
} delete[] L_hbias;
delete[] L_vbias;
delete[] z;
delete[] y;
delete[] tilde_x;
} void dA::reconstruct (
int *x, // the input sample -- input
double *z // the reconstructed value -- output
)
{
double *y = new double[n_hidden]; // calculate the output of hidden layer
get_hidden_values(x, y);
// reconstruct from hidden layer to visible layer
get_reconstructed_input(y, z); delete[] y;
}
【deep learning学习笔记】注释yusugomori的DA代码 --- dA.cpp -- 训练的更多相关文章
- 【deep learning学习笔记】注释yusugomori的DA代码 --- dA.h
DA就是“Denoising Autoencoders”的缩写.继续给yusugomori做注释,边注释边学习.看了一些DA的材料,基本上都在前面“转载”了.学习中间总有个疑问:DA和RBM到底啥区别 ...
- 【deep learning学习笔记】注释yusugomori的RBM代码 --- 头文件
百度了半天yusugomori,也不知道他是谁.不过这位老兄写了deep learning的代码,包括RBM.逻辑回归.DBN.autoencoder等,实现语言包括c.c++.java.python ...
- [置顶]
Deep Learning 学习笔记
一.文章来由 好久没写原创博客了,一直处于学习新知识的阶段.来新加坡也有一个星期,搞定签证.入学等杂事之后,今天上午与导师确定了接下来的研究任务,我平时基本也是把博客当作联机版的云笔记~~如果有写的不 ...
- Deep Learning 学习笔记(8):自编码器( Autoencoders )
之前的笔记,算不上是 Deep Learning, 只是为理解Deep Learning 而需要学习的基础知识, 从下面开始,我会把我学习UFDL的笔记写出来 #主要是给自己用的,所以其他人不一定看得 ...
- 【deep learning学习笔记】Recommending music on Spotify with deep learning
主要内容: Spotify是个类似酷我音乐的音乐站点.做个性化音乐推荐和音乐消费.作者利用deep learning结合协同过滤来做音乐推荐. 详细内容: 1. 协同过滤 基本原理:某两个用户听的歌曲 ...
- 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的一篇文章,看得半懂. 主要内容: 是针对文本表示的一种方法.文本表示可以进一步应用在文本分类和信息检索上面.通常,一篇文章表 ...
- 【deep learning学习笔记】最近读的几个ppt(四)
这几个ppt都是在微博上看到的,是百度的一个员工整理的. <Deep Belief Nets>,31页的一个ppt 1. 相关背景 还是在说deep learning好啦,如特征表示云云. ...
随机推荐
- 001.SMB简介
一 简介 samba基于NetBIOS协议开发,能和windows通信,但只能在局域网通信. 二 Samba主要应用 文件共享 打印服务器 Samba登录时身份验证 进行windows主机名解析 三 ...
- Harbor 企业级镜像仓库搭建
Habor是由VMWare公司开源的容器镜像仓库.事实上,Habor是在Docker Registry上进行了相应的 企业级扩展,从而获得了更加广泛的应用,这些新的企业级特性包括:管理用户界面,基于角 ...
- 算法初级面试题01——认识时间复杂度、对数器、 master公式计算时间复杂度、小和问题和逆序对问题
虽然以前学过,再次回顾还是有别样的收获~ 认识时间复杂度 常数时间的操作:一个操作如果和数据量没有关系,每次都是固定时间内完成的操作,叫做常数操作. 时间复杂度为一个算法流程中,常数操作数量的指标.常 ...
- Win10 主题 美化 动漫
韩梦飞沙 yue31313 韩亚飞 han_meng_fei_sha 313134555@qq.com High School D×D 塔城白音Win7主题+Win8主题+Win10主题 Win10 ...
- Windows平台开发Mapreduce程序远程调用运行在Hadoop集群—Yarn调度引擎异常
共享原因:虽然用一篇博文写问题感觉有点奢侈,但是搜索百度,相关文章太少了,苦苦探寻日志才找到解决方案. 遇到问题:在windows平台上开发的mapreduce程序,运行迟迟没有结果. Mapredu ...
- Java_Certificates does not conform to algorithm constraints
java.security.cert.CertificateException: Certificates does not conform to algorithm constraints SSL证 ...
- clientHeight ,offsetHeight,style.height,scrollHeight有区别与联系
style.height 包括 元素的滚动条,不包括边框clientHeight 不包括元素的滚动条和边框,只有在没有元素的滚动条的情况下,style.height相等于clientHeightoff ...
- [原创]SOAPUI工具介绍
[原创]SOAPUI工具介绍 一 官方网站:http://www.soapui.org/二 下载地址:http://sourceforge.net/projects/soapui/files/三 so ...
- 百度地图api---实现新建地图
调用这个函数 function refresh() { history.go(0); } 实现了地图新建
- delphi socket 编程 使用多线程
http://blog.csdn.net/lailai186/article/details/8788710?utm_source=tuicool TClientSocket和TServerSocke ...