【deep learning学习笔记】注释yusugomori的LR代码 --- 模型测试
测试部分代码:
void test_lr()
{
srand(0); double learning_rate = 0.1;
double n_epochs = 500; int train_N = 6;
int test_N = 2;
int n_in = 6;
int n_out = 2;
// int **train_X;
// int **train_Y;
// int **test_X;
// double **test_Y; // train_X = new int*[train_N];
// train_Y = new int*[train_N];
// for(i=0; i<train_N; i++){
// train_X[i] = new int[n_in];
// train_Y[i] = new int[n_out];
// }; // test_X = new int*[test_N];
// test_Y = new double*[test_N];
// for(i=0; i<test_N; i++){
// test_X[i] = new int[n_in];
// test_Y[i] = new double[n_out];
// } // training data
int train_X[6][6] = {
{1, 1, 1, 0, 0, 0},
{1, 0, 1, 0, 0, 0},
{1, 1, 1, 0, 0, 0},
{0, 0, 1, 1, 1, 0},
{0, 0, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 0}
}; int train_Y[6][2] = {
{1, 0},
{1, 0},
{1, 0},
{0, 1},
{0, 1},
{0, 1}
}; // construct LogisticRegression
LogisticRegression classifier(train_N, n_in, n_out);
// i wonder that we should set the N value to 1 as training online
//LogisticRegression classifier(1, n_in, n_out); // train online
for(int epoch=0; epoch<n_epochs; epoch++) {
for(int i=0; i<train_N; i++) {
classifier.train(train_X[i], train_Y[i], learning_rate);
}
// learning_rate *= 0.95;
} // test data
int test_X[2][6] = {
{1, 0, 1, 0, 0, 0},
{0, 0, 1, 1, 1, 0}
}; double test_Y[2][2]; // test
for(int i=0; i<test_N; i++) {
classifier.predict(test_X[i], test_Y[i]);
for(int j=0; j<n_out; j++) {
cout << test_Y[i][j] << " ";
}
cout << endl;
} } int main()
{
test_lr();
getchar();
return 0;
}
测试数据实际上是在训练集合中的,分别是第二个和第四个训练数据,也就是说,这是“封闭测试”。测试结果如下所示:
不过总感觉这个调用
“
LogisticRegression classifier(train_N, n_in, n_out);
”
不对。在线训练,是单个样本为单位的训练,train_N的值应该设置为1。将这一句改成
“
LogisticRegression classifier(1, n_in, n_out);
”
运行结果如下:
与上面的结果差别不大。恐怕要到实际应用中检验了。
【deep learning学习笔记】注释yusugomori的LR代码 --- 模型测试的更多相关文章
- 【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的一篇文章,看得半懂. 主要内容: 是针对文本表示的一种方法.文本表示可以进一步应用在文本分类和信息检索上面.通常,一篇文章表 ...
随机推荐
- AWVS介绍(转)
使用AWVS对域名进行全局分析,深入探索: 首先,介绍一下AWVS这个工具. Acunetix Web Vulnerability Scanner(简称AWVS)是一款知名的网络漏洞扫描工具,它通过网 ...
- 转:一道笔试题-将int型数组强制转换为char*,再求strlen,涉及大小端
写出如下程序运行结果: #include<stdio.h> #include<string.h> int main() { int a[2000]; char *p = (ch ...
- windows无效字符名导致的错误及解决办法
今天用file_put_content($fileName,$data)产生错误:内容如下: Warning: file_put_contents(images/7d5636992a7395f9174 ...
- 2、Zookeeper集群搭建、命令行Client操作
zookeeper 集群最好是奇数台: 5台允许挂掉2台 4台只能允许挂掉1台 zjtest7-redis:/opt/zookeeper/bin# ./zkServer.sh status ZooKe ...
- 一步一步重写 CodeIgniter 框架 (10) —— 使用 CodeIgniter 类库(续)
上一节简单实现了 CI 的类库扩展模型,所以 _ci_load_class 和 _ci_init_class 写的不是很完备.根据上节课的分析,当 system/libraries 目录下存在 Ema ...
- Xcode4.5 本地化,多语言设置
网上已有很多关于ios本地化的博客和资料,由于部分原作者使用的Xcode版本较早,4.5以后的版本已不再支持该方法,后来也没有更新,因此在此写一点学习资料分享出来.废话不多说. ios本地化主 ...
- docker学习笔记4:利用docker hub上的mysql镜像创建mysql容器
docker hub上有官方的mysql镜像,我们可以利用它来创建mysql容器,作为一个服务容器使用. 1.下载mysql镜像 docker pull mysql 2.创建镜像 docker run ...
- Ubuntu 14.04下安装GitLab指南
摘要 GitLab 是一个用于仓库管理系统的开源项目.使用Git作为代码管理工具,并在此基础上搭建起来的web服务. 在GitLab的官方网站上面对Ubuntu的支持也是很好的,有比较详尽的安装指南. ...
- STL--G - For Fans of Statistics(两个推断条件-二分)
G - For Fans of Statistics Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & ...
- eclipse中使用maven插件的时候,运行run as maven build的时候报错
-Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable a ...