您的位置:首页 > Web前端

caffe 回调函数分析

2015-08-24 15:33 316 查看
20150824 caffe 中增加回调函数, 在上一篇介绍回调函数的基础上, 这里重点分析caffe中的回调函数

主要涉及 程序为, solver.hpp 定义和解释回调函数

caffe.cpp caffe入口函数, 设置信号类型, 三种不同类型, 所有会产生三种回调函数

定义信号句柄, 其实就是对象的指针

solver.cpp  回调函数 具体使用

作用: 当运行程序过程中 ,出现中断时, 能够保存当前的模型。

下面这段是官方解释

Add signal handler and early exit/snapshot to Solver.

Add signal handler and early exit/snapshot to Solver.

Add signal handler and early exit/snapshot to Solver.

Also check for exit and snapshot when testing.

Skip running test after early exit.

Fix more lint.

Rebase on master.

Finish rebase on master.

Fixups per review comments.

Redress review comments.

Lint.

Correct error message wording.、

Correct error message wording.、

这一次入口函数变化比较大,Add signal handler and early exit/snapshot to Solver. 使用了函数句柄的形式,这个方式 和win32

句柄有点像。可以学习这种用法。

caffe 入口函数初发生了变化,

增加

/**

* @brief Enumeration of actions that a client of the Solver may request by

* implementing the Solver's action request function, which a

* a client may optionally provide in order to request early termination

* or saving a snapshot without exiting. In the executable caffe, this

* mechanism is used to allow the snapshot to be saved when stopping

* execution with a SIGINT (Ctrl-C).

*/

namespace SolverAction {

enum Enum {

NONE = 0, // Take no special action.

STOP = 1, // Stop training. snapshot_after_train controls whether a

// snapshot is created.

SNAPSHOT = 2 // Take a snapshot, and keep training.

};

}

/**

* @brief Type of a function that returns a Solver Action enumeration.

*/

typedef boost::function<SolverAction::Enum()> ActionCallback;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: