
Caffe研究实践 二 ------准备数据 训练 测试
修改
发布日期:2021-05-06 19:00:15
浏览次数:30
分类:精选文章
本文共 4230 字,大约阅读时间需要 14 分钟。
一、准备样本数据
获取minist的数据包。这个版本是四个数据包。
learning@learning-virtual-machine:~/caffe/data/mnist$ ./get_mnist.sh
下载过程如下:
Downloading...--2016-05-11 17:35:10-- http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gzResolving yann.lecun.com (yann.lecun.com)... 128.122.47.89Connecting to yann.lecun.com (yann.lecun.com)|128.122.47.89|:80... connected.HTTP request sent, awaiting response... 200 OKLength: 9912422 (9.5M) [application/x-gzip]Saving to: ‘train-images-idx3-ubyte.gz’train-images-idx 100%[===========>] 9.45M 225KB/s in 73s 2016-05-11 17:36:24 (133 KB/s) - ‘train-images-idx3-ubyte.gz’ saved [9912422/9912422]
--2016-05-11 17:36:38-- http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gzResolving yann.lecun.com (yann.lecun.com)... 128.122.47.89Connecting to yann.lecun.com (yann.lecun.com)|128.122.47.89|:80... connected.HTTP request sent, awaiting response... 200 OKLength: 28881 (28K) [application/x-gzip]Saving to: ‘train-labels-idx1-ubyte.gz’train-labels-idx 100%[===========>] 28.20K 1.41KB/s in 7.5s 2016-05-11 17:36:49 (3.75 KB/s) - ‘train-labels-idx1-ubyte.gz’ saved [28881/28881]
--2016-05-11 17:36:49-- http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gzResolving yann.lecun.com (yann.lecun.com)... 128.122.47.89Connecting to yann.lecun.com (yann.lecun.com)|128.122.47.89|:80... connected.HTTP request sent, awaiting response... 200 OKLength: 1648877 (1.6M) [application/x-gzip]Saving to: ‘t10k-images-idx3-ubyte.gz’t10k-images-idx3 100%[===========>] 1.57M 71.9KB/s in 19s 2016-05-11 17:37:08 (85.5 KB/s) - ‘t10k-images-idx3-ubyte.gz’ saved [1648877/1648877]
--2016-05-11 17:37:09-- http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gzResolving yann.lecun.com (yann.lecun.com)... 128.122.47.89Connecting to yann.lecun.com (yann.lecun.com)|128.122.47.89|:80... connected.HTTP request sent, awaiting response... 200 OKLength: 4542 (4.4K) [application/x-gzip]Saving to: ‘t10k-labels-idx1-ubyte.gz’t10k-labels-idx1 100%[===========>] 4.44K --.-KB/s in 0s 2016-05-11 17:37:09 (31.5 MB/s) - ‘t10k-labels-idx1-ubyte.gz’ saved [4542/4542]
get_mnist.sh 代码
#!/usr/bin/env sh# This scripts downloads the mnist data and unzips it.DIR="$( cd "$(dirname "$0")" ; pwd -P)"cd $DIRecho "Downloading..."for fname in train-images-idx3-ubyte train-labels-idx1-ubyte t10k-images-idx3-ubyte t10k-labels-idx1-ubytedo if [ ! -e $fname ]; then wget --no-check-certificate http://yann.lecun.com/exdb/mnist/${fname}.gz gunzip ${fname}.gz fidone
二、训练
learning@learning-virtual-machine:~/caffe$ ./examples/mnist/train_lenet.sh
出现问题:
I0511 17:52:25.115056 63914 caffe.cpp:185] Using GPUs 0F0511 17:52:25.116345 63914 common.cpp:66] Cannot use GPU in CPU-only Caffe: check mode.
解决方案:
lenet_solver.prototxt
文件learning@learning-virtual-machine:~/caffe/examples/mnist$ sudo gedit lenet_solver.prototxt
在文件中添加以下内容:
# 检查是否有GPU可用device: GPU
- 运行训练脚本
- CUDA 驱动是否正确安装
- CUDA 库文件是否存在
- 重新启动系统
learning@learning-virtual-machine:~/caffe/examples/mnist$ ./train_lenet.sh
如果问题依然存在,请检查以下内容:
三、测试
learning@learning-virtual-machine:~/caffe$ ./build/tools/caffe.bin test -model=examples/mnist/lenet_train_test.prototxt -weights=examples/mnist/lenet_iter_10000.caffemodel
I0512 09:18:41.455747 3503 caffe.cpp:275] Batch 44, loss = 0.0137619I0512 09:18:41.671058 3503 caffe.cpp:275] Batch 45, accuracy = 0.99I0512 09:18:41.671362 3503 caffe.cpp:275] Batch 45, loss = 0.0446652I0512 09:18:41.910468 3503 caffe.cpp:275] Batch 46, accuracy = 1I0512 09:18:41.910781 3503 caffe.cpp:275] Batch 46, loss = 0.00462838I0512 09:18:42:082020 3503 caffe.cpp:275] Batch 47, accuracy = 0.99I0512 09:18:42:082260 3503 caffe.cpp:275] Batch 47, loss = 0.0215265I0512 09:18:42:297307 3503 caffe.cpp:275] Batch 48, accuracy = 0.96I0512 09:18:42:301200 3503 caffe.cpp:275] Batch 48, loss = 0.0964929I0512 09:18:42:576354 3503 caffe.cpp:275] Batch 49, accuracy = 1I0512 09:18:42:576627 3503 caffe.cpp:275] Batch 49, loss = 0.00345927I0512 09:18:42:576843 3503 caffe.cpp:280] Loss: 0.0427004I0512 09:18:42:576843 3503 caffe.cpp:292] accuracy = 0.9872I0512 09:18:42:576954 3503 caffe.cpp:292] loss = 0.0427004 (* 1 = 0.0427004 loss)
参考资料
发表评论
最新留言
表示我来过!
[***.240.166.169]2025年04月15日 23时35分56秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
Spring Cloud第九篇 | 分布式服务跟踪Sleuth
2019-03-06
CODING 敏捷实战系列课第三讲:可视化业务分析
2019-03-06
工作动态尽在掌握 - 使用 CODING 度量团队效能
2019-03-06
CODING DevOps 深度解析系列第二课报名倒计时!
2019-03-06
数据结构第八节(图(下))
2019-03-06
基于Mustache实现sql拼接
2019-03-06
POJ 2260 Error Correction 模拟 贪心 简单题
2019-03-06
gRPC在 ASP.NET Core 中应用学习(一)
2019-03-06
@SuppressWarnings 用法
2019-03-06
看完你就明白的锁系列之锁的状态
2019-03-06
看完这篇操作系统,和面试官扯皮就没问题了
2019-03-06
我的价值观
2019-03-06
一文详解 Java 并发模型
2019-03-06
值类型与引用类型(中)
2019-03-06
MSSQL 2005 数据库变成可疑状态
2019-03-06
QBlog V2.5 源码开放下载(ASP.NET 番外系列之开端)
2019-03-06
秋色园引发CPU百分百命案的事件分析与总结
2019-03-06
安装jdk并配置环境变量
2019-03-06
稀疏数组
2019-03-06
js的严格模式
2019-03-06