【deep learning学习笔记】注释yusugomori的DA代码 --- dA.cpp -- 模型测试
来源:互联网 发布:win10默认网卡mac地址 编辑:程序博客网 时间:2024/05/22 17:41
测试代码。能看到,训练的时候是单个样本、单个样本的训练的,在NN中是属于“stochastic gradient descent”,否则,一批样本在一起的,就是“standard gradient descent”。
void test_dA() {srand(0); double learning_rate = 0.1;double corruption_level = 0.3;int training_epochs = 100;int train_N = 10;int test_N = 2;int n_visible = 20;int n_hidden = 5;// training dataint train_X[10][20] = {{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},{1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},{1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},{1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},{0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1},{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1},{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1},{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0}};// construct dAdA da(train_N, n_visible, n_hidden, NULL, NULL, NULL);// trainfor(int epoch=0; epoch<training_epochs; epoch++) {// train it sample by samplefor(int i=0; i<train_N; i++) {da.train(train_X[i], learning_rate, corruption_level);}}// test dataint test_X[2][20] = {{1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0} };double reconstructed_X[2][20];// testfor(int i=0; i<test_N; i++) {da.reconstruct(test_X[i], reconstructed_X[i]);for(int j=0; j<n_visible; j++) {printf("%.5f ", reconstructed_X[i][j]);}cout << endl;} cout << endl;}int main() {test_dA();getchar();return 0;}程序运行结果:
- 【deep learning学习笔记】注释yusugomori的DA代码 --- dA.cpp -- 模型测试
- 【deep learning学习笔记】注释yusugomori的DA代码 --- dA.cpp --模型准备
- 【deep learning学习笔记】注释yusugomori的DA代码 --- dA.cpp -- 训练
- 【deep learning学习笔记】注释yusugomori的DA代码 --- dA.h
- 【deep learning学习笔记】注释yusugomori的RBM代码 --- cpp文件 -- 模型测试
- 【deep learning学习笔记】注释yusugomori的SDA代码 -- Sda.cpp -- 模型测试
- 【deep learning学习笔记】注释yusugomori的RBM代码 --- cpp文件 -- 模型训练
- 【deep learning学习笔记】注释yusugomori的SDA代码 -- Sda.cpp -- 模型准备
- 【deep learning学习笔记】注释yusugomori的SDA代码 -- Sda.cpp -- 模型训练与预测
- 【deep learning学习笔记】注释yusugomori的LR代码 --- 模型测试
- 【deep learning学习笔记】注释yusugomori的RBM代码 --- cpp文件 -- 准备工作
- 【deep learning学习笔记】注释yusugomori的LR代码 --- LogisticRegression.cpp
- 【deep learning学习笔记】注释yusugomori的SDA代码 -- 准备工作
- 【deep learning学习笔记】注释yusugomori的RBM代码 --- 头文件
- 【deep learning学习笔记】注释yusugomori的LR代码 --- LogisticRegression.h
- 【deep learning学习笔记】注释yusugomori的RBM代码 --- 头文件
- 【deep learning学习笔记】注释yusugomori的SDA代码 -- Sda.h
- Theano-Deep Learning Tutorials 笔记:Denoising Autoencoders (dA)
- CoreText --- 行 CTLineRef
- VC6.0常用控件的操作
- 五险一金,终于懂了!
- 解题报告1
- worldwind 从简单开始 CardLayoutUsage
- 【deep learning学习笔记】注释yusugomori的DA代码 --- dA.cpp -- 模型测试
- android level-list ImageView中显示不同的图片
- 确定比赛名次 (拓扑排序)
- Codeforces Round #192 (Div. 2) 。。很水的只过了两题- -
- 黑马程序员--04.多线程--02.【run()和start()】【线程的运行状态】【获取想成对象及其名称】
- hdu 2821 dfs
- Tiny210(S5PV210) U-BOOT(二)----配置时钟频率基本原理
- UVA216 Getting in Line
- AtomicInteger在实际项目中的应用