python程序⽣成prototxt⽂件 ⼀、前⾔ 了解到上⼀篇笔记的内容,就可以尝试⾃⼰编写python程序⽣成prototxt⽂件了,当然也可以直接创建⽂件进⾏编写,不过显然,使⽤ python⽣成这个配置⽂件更为简洁。之前已说过cifar10是使⽤cifar10_quick_solver.prototxt配置⽂件来⽣成model。 cifar10_quick_solver.prototxt的内容如下: 从以上代码中可以看出,第四⾏的net参数,指定了训练时使⽤的prototxt⽂件。这个prototxt⽂件也是可以分开写的,分为train.prototxt和 test.prototxt。例如,第四⾏的配置可以改写为: ⼆、Pycaffe API⼩试 solver.prototxt⽂件如何⽣成,在后续的笔记中讲解,先学习如何使⽤python⽣成简单的train.prtotxt⽂件和test.prototxt⽂件。 1.Data Layer: # reduce the learning rate after 8 epochs (4000 iters) by a factor of 10 # The train/test net protocol buffer definition net: "examples/cifar10/cifar10_quick_train_test.prototxt" # test_iter specifies how many forward passes the test should carry out. # In the case of MNIST, we have test batch size 100 and 100 test iterations, # covering the full 10,000 testing images. test_iter: 100 # Carry out testing every 500 training iterations. test_interval: 500 # The base learning rate, momentum and the weight decay of the network. base_lr: 0.001 momentum: 0.9 weight_decay: 0.004 # The learning rate policy lr_policy: "fixed" # Display every 100 iterations display: 100 # The maximum number of iterations max_iter: 4000 # snapshot intermediate results snapshot: 4000 snapshot_format: HDF5 snapshot_prefix: "examples/cifar10/cifar10_quick" # solver mode: CPU or GPU solver_mode: GPU 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 train_net = "examples/cifar10/cifar10_quick_train.prototxt" test_net = "examples/cifar10/cifar10_quick_test.prototxt" 1 2 运⾏结果: 2.Convolution Layer: 添加卷积层: 运⾏结果: # -*- coding: UTF-8 -*- import caffe #导⼊caffe包 caffe_root = "/home/Jack-Cui/caffe-master/my-caffe-project/" #my-caffe-project⽬录 train_lmdb = caffe_root + "img_train.lmdb" #train.lmdb⽂件的位置 mean_file = caffe_root + "mean.binaryproto" #均值⽂件的位置 #⽹络规范 net = caffe.NetSpec() #第⼀层Data层 net.data, net.label = caffe.layers.Data(source = train_lmdb, backend = caffe.params.Data.LMDB, batch_size = 64, ntop=2, transform_param = dict(crop_size = 40,mean_file = mean_file,m
- 粉丝: 167
- 资源: 3万+
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- #P0015. 全排列 超级简单
- pta题库答案c语言之排序4统计工龄.zip
- pta题库答案c语言之树结构7堆中的路径.zip
- pta题库答案c语言之树结构3TreeTraversalsAgain.zip
- pta题库答案c语言之树结构2ListLeaves.zip
- pta题库答案c语言之树结构1树的同构.zip
- 基于C++实现民航飞行与地图简易管理系统可执行程序+说明+详细注释.zip
- pta题库答案c语言之复杂度1最大子列和问题.zip
- 三维装箱问题(Three-Dimensional Bin Packing Problem,3D-BPP)是一个经典的组合优化问题
- 以下是一些关于Linux线程同步的基本概念和方法.txt