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

来源:互联网 发布:thinkphp js跳转页面 编辑:程序博客网 时间:2024/05/22 16:40

DA就是“Denoising Autoencoders”的缩写。继续给yusugomori做注释,边注释边学习。看了一些DA的材料,基本上都在前面“转载”了。学习中间总有个疑问:DA和RBM到底啥区别?(别笑,我不是“学院派”的看Deep Learning理论,如果“顺次”看下来,可能不会有这个问题),现在了解的差不多了,详情见:【deep learning学习笔记】Autoencoder。之后,又有个疑问,DA具体的权重更新公式是怎么推导出来的?我知道是BP算法,不过具体公示的推导、偏导数的求解,没有看到哪个材料有具体的公式,所以姑且认为yusugomori的代码写的是正确的。


注释后的头文件:

// The Class of denoising auto-encoderclass dA {public:int N;// the number of training samplesint n_visible;// the number of visible nodesint n_hidden;// the number of hidden nodesdouble **W;// the weight connecting visible node and hidden nodedouble *hbias;// the bias of hidden nodesdouble *vbias;// the bias of visible nodespublic:// initialize the parametersdA ( int,// N int,// n_visible int ,// n_hidden double**,// W double*,// hbias double*// vbias );~dA();// make the input noisedvoid get_corrupted_input (int*,// the original input 0-1 vector-- inputint*,// the resulted 0-1 vector gotten noised-- outputdouble// the p probability of noise, binomial test -- input);// encode process: calculate the probability output from hidden node// p(hi|v) = sigmod ( sum_j(vj * wij) + bi), it's same with RBM// but different from RBM, it dose not generate 0-1 state from Bernoulli distributionvoid get_hidden_values (int*,// the input from visible nodesdouble*// the output of hidden nodes);// decode process: calculate the probability output from visiable node// p(vi|h) = sigmod ( sum_j(hj * wij) + ci), it's same with RBM// but different from RBM, it dose not generate 0-1 state from Bernoulli distribution void get_reconstructed_input (double*,// the input from hidden nodesdouble*// the output reconstructed of visible nodes);// train the model by a single samplevoid train (int*,// the input sample from visiable nodedouble,// the learning ratedouble// corruption_level is the probability of noise);// reconstruct the input samplevoid reconstruct (int*,// the input sample-- inputdouble*// the reconstructed value -- output);};


原创粉丝点击