引言
要看caffe源码,我认为首先应该看的就是caffe.proto。
它位于…\src\caffe\proto目录下,在这个文件夹下还有一个.pb.cc和一个.pb.h文件,这两个文件都是由caffe.proto编译而来的。
在caffe.proto中定义了很多结构化数据,包括:
- BlobProto
- Datum
- FillerParameter
- NetParameter
- SolverParameter
- SolverState
- LayerParameter
- ConcatParameter
- ConvolutionParameter
- DataParameter
- DropoutParameter
- HDF5DataParameter
- HDF5OutputParameter
- ImageDataParameter
- InfogainLossParameter
- InnerProductParameter
- LRNParameter
- MemoryDataParameter
- PoolingParameter
- PowerParameter
- WindowDataParameter
- V0LayerParameter
正文
一、什么是protocol buffer
以下内容摘自:Google Protocol Buffer 的使用和原理
强烈推荐另外一篇极好的博文是:Protocol Buffer技术详解(C++实例)
简介
什么是 Google Protocol Buffer? 假如您在网上搜索,应该会得到类似这样的文字介绍:
Google Protocol Buffer( 简称 Protobuf) 是 Google 公司内部的混合语言数据标准,目前已经正在使用的有超过 48,162 种报文格式定义和超过 12,183 个 .proto 文件。他们用于 RPC 系统和持续数据存储系统。
Protocol Buffers 是一种轻便高效的结构化数据存储格式,可以用于结构化数据串行化,或者说序列化。它很适合做数据存储或 RPC 数据交换格式。可用于通讯协议、数据存储等领域的语言无关、平台无关、可扩展的序列化结构数据格式。目前提供了 C++、Java、Python 三种语言的 API。
或许您和我一样,在第一次看完这些介绍后还是不明白 Protobuf 究竟是什么,那么我想一个简单的例子应该比较有助于理解它。
一个简单的例子
安装 Google Protocol Buffer
在网站 http://code.google.com/p/protobuf/downloads/list上可以下载 Protobuf 的源代码。然后解压编译安装便可以使用它了。
安装步骤如下所示:
<code class="hljs go has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"> tar -xzf protobuf<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">-2.1</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.0</span>.tar.gz cd protobuf<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">-2.1</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.0</span> ./configure --prefix=$INSTALL_DIR <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">make</span> <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">make</span> check <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">make</span> install</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li></ul>
关于简单例子的描述
我打算使用 Protobuf 和 C++ 开发一个十分简单的例子程序。
该程序由两部分组成。第一部分被称为 Writer,第二部分叫做 Reader。
Writer 负责将一些结构化的数据写入一个磁盘文件,Reader 则负责从该磁盘文件中读取结构化数据并打印到屏幕上。
准备用于演示的结构化数据是 HelloWorld,它包含两个基本数据:
- ID,为一个整数类型的数据
- Str,这是一个字符串
书写 .proto 文件
首先我们需要编写一个 proto 文件,定义我们程序中需要处理的结构化数据,在 protobuf 的术语中,结构化数据被称为 Message。proto 文件非常类似 java 或者 C 语言的数据定义。代码清单 1 显示了例子应用中的 proto 文件内容。
清单 1. proto 文件
<code class="hljs go has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">package</span> lm; message helloworld { required <span class="hljs-typename" style="color: rgb(102, 0, 102); box-sizing: border-box;">int32</span> id =<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;"> 1</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// ID </span> required <span class="hljs-typename" style="color: rgb(102, 0, 102); box-sizing: border-box;">string</span> str =<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;"> 2</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// str </span> optional <span class="hljs-typename" style="color: rgb(102, 0, 102); box-sizing: border-box;">int32</span> opt =<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;"> 3</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//optional field </span> }</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li></ul>
一个比较好的习惯是认真对待 proto 文件的文件名。比如将命名规则定于
packageName.MessageName.proto
在上例中,package 名字叫做 lm,定义了一个消息 helloworld,该消息有三个成员,类型为 int32 的 id,另一个为类型为 string 的成员 str。opt 是一个可选的成员,即消息中可以不包含该成员。
编译 .proto 文件
写好 proto 文件之后就可以用 Protobuf 编译器将该文件编译成目标语言了。本例中我们将使用 C++。
假设您的 proto 文件存放在 $SRC_DIR 下面,您也想把生成的文件放在同一个目录下,则可以使用如下命令:
<code class="hljs lasso has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">protoc <span class="hljs-attribute" style="box-sizing: border-box;">-I</span><span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=</span><span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$SRC_DIR</span> <span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">--</span>cpp_out<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=</span><span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$DST_DIR</span> <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$SRC_DIR</span>/addressbook<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>proto</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>
命令将生成两个文件:
lm.helloworld.pb.h , 定义了 C++ 类的头文件
lm.helloworld.pb.cc , C++ 类的实现文件
在生成的头文件中,定义了一个 C++ 类 helloworld,后面的 Writer 和 Reader 将使用这个类来对消息进行操作。诸如对消息的成员进行赋值,将消息序列化等等都有相应的方法。
编写 writer 和 Reader
如前所述,Writer将把一个结构化数据写入磁盘,以便其他人来读取。假如我们不使用 Protobuf,其实也有许多的选择。一个可能的方法是将数据转换为字符串,然后将字符串写入磁盘。转换为字符串的方法可以使用sprintf(),这非常简单。数字123可以变成字符串“123”。
这样做似乎没有什么不妥,但是仔细考虑一下就会发现,这样的做法对写 Reader 的那个人的要求比较高,Reader 的作者必须了 Writer 的细节。比如”123”可以是单个数字 123,但也可以是三个数字 1,2 和 3,等等。这么说来,我们还必须让 Writer 定义一种分隔符一样的字符,以便 Reader 可以正确读取。但分隔符也许还会引起其他的什么问题。最后我们发现一个简单的 Helloworld 也需要写许多处理消息格式的代码。
如果使用 Protobuf,那么这些细节就可以不需要应用程序来考虑了。
使用 Protobuf,Writer 的工作很简单,需要处理的结构化数据由 .proto 文件描述,经过上一节中的编译过程后,该数据化结构对应了一个 C++ 的类,并定义在 lm.helloworld.pb.h 中。对于本例,类名为 lm::helloworld。
Writer 需要 include 该头文件,然后便可以使用这个类了。
现在,在 Writer 代码中,将要存入磁盘的结构化数据由一个 lm::helloworld 类的对象表示,它提供了一系列的 get/set 函数用来修改和读取结构化数据中的数据成员,或者叫 field。
当我们需要将该结构化数据保存到磁盘上时,类 lm::helloworld 已经提供相应的方法来把一个复杂的数据变成一个字节序列,我们可以将这个字节序列写入磁盘。
对于想要读取这个数据的程序来说,也只需要使用类 lm::helloworld 的相应反序列化方法来将这个字节序列重新转换会结构化数据。这同我们开始时那个“123”的想法类似,不过 Protobuf 想的远远比我们那个粗糙的字符串转换要全面,因此,我们不如放心将这类事情交给 Protobuf 吧。
程序清单 2 演示了 Writer 的主要代码,您一定会觉得很简单吧?
清单 2. Writer 的主要代码
<code class="hljs lasso has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"> <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">#include</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"lm.helloworld.pb.h"</span> … int main(<span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">void</span>) { lm<span class="hljs-tag" style="color: rgb(0, 102, 102); box-sizing: border-box;">::helloworld</span> msg1; msg1<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>set_id(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">101</span>); msg1<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>set_str(“hello”); <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Write the new address book back to disk. </span> fstream output(<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"./log"</span>, ios<span class="hljs-tag" style="color: rgb(0, 102, 102); box-sizing: border-box;">::out</span> <span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">|</span> ios<span class="hljs-tag" style="color: rgb(0, 102, 102); box-sizing: border-box;">::trunc</span> <span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">|</span> ios<span class="hljs-tag" style="color: rgb(0, 102, 102); box-sizing: border-box;">::binary</span>); <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">if</span> (<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">!</span>msg1<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>SerializeToOstream(<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">&</span>output)) { cerr <span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;"><<</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"Failed to write msg."</span> <span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;"><<</span> endl; <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">return</span> <span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">-</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>; } <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">return</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>; }</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li><li style="box-sizing: border-box; padding: 0px 5px;">11</li><li style="box-sizing: border-box; padding: 0px 5px;">12</li><li style="box-sizing: border-box; padding: 0px 5px;">13</li><li style="box-sizing: border-box; padding: 0px 5px;">14</li><li style="box-sizing: border-box; padding: 0px 5px;">15</li><li style="box-sizing: border-box; padding: 0px 5px;">16</li><li style="box-sizing: border-box; padding: 0px 5px;">17</li><li style="box-sizing: border-box; padding: 0px 5px;">18</li><li style="box-sizing: border-box; padding: 0px 5px;">19</li></ul>
Msg1 是一个 helloworld 类的对象,set_id() 用来设置 id 的值。SerializeToOstream 将对象序列化后写入一个 fstream 流。
代码清单 3 列出了 reader 的主要代码。
清单 3. Reader
<code class="hljs cpp has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"> <span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">#include "lm.helloworld.pb.h" </span> … <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">void</span> ListMsg(<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">const</span> lm::helloworld & msg) { <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">cout</span> << msg.id() << endl; <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">cout</span> << msg.str() << endl; } <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int</span> main(<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int</span> argc, <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">char</span>* argv[]) { lm::helloworld msg1; { fstream input(<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"./log"</span>, ios::in | ios::binary); <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">if</span> (!msg1.ParseFromIstream(&input)) { <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">cerr</span> << <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"Failed to parse address book."</span> << endl; <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">return</span> -<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>; } } ListMsg(msg1); … }</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li><li style="box-sizing: border-box; padding: 0px 5px;">11</li><li style="box-sizing: border-box; padding: 0px 5px;">12</li><li style="box-sizing: border-box; padding: 0px 5px;">13</li><li style="box-sizing: border-box; padding: 0px 5px;">14</li><li style="box-sizing: border-box; padding: 0px 5px;">15</li><li style="box-sizing: border-box; padding: 0px 5px;">16</li><li style="box-sizing: border-box; padding: 0px 5px;">17</li><li style="box-sizing: border-box; padding: 0px 5px;">18</li><li style="box-sizing: border-box; padding: 0px 5px;">19</li><li style="box-sizing: border-box; padding: 0px 5px;">20</li><li style="box-sizing: border-box; padding: 0px 5px;">21</li><li style="box-sizing: border-box; padding: 0px 5px;">22</li></ul>
同样,Reader 声明类 helloworld 的对象 msg1,然后利用 ParseFromIstream 从一个 fstream 流中读取信息并反序列化。此后,ListMsg 中采用 get 方法读取消息的内部信息,并进行打印输出操作。
运行结果
运行 Writer 和 Reader 的结果如下:
<code class="hljs tex has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-command" style="box-sizing: border-box; color: rgb(0, 0, 136);">\></span>writer <span class="hljs-command" style="box-sizing: border-box; color: rgb(0, 0, 136);">\></span>reader 101 Hello</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li></ul>
Reader 读取文件 log 中的序列化信息并打印到屏幕上。本文中所有的例子代码都可以在附件中下载。您可以亲身体验一下。
这个例子本身并无意义,但只要您稍加修改就可以将它变成更加有用的程序。比如将磁盘替换为网络 socket,那么就可以实现基于网络的数据交换任务。而存储和交换正是 Protobuf 最有效的应用领域。
二、caffe.proto中的几个重要数据类型
看完了上面关于protocol buffer的介绍,大家应该可以知道其实caffe.pb.cc里面的东西都是从caffe.proto编译而来的,无非就是一些关于这些数据结构(类)的标准化操作,比如
<code class="hljs cs has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">void</span> CopyFrom(); <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">void</span> MergeFrom(); <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">void</span> CopyFrom(); <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">void</span> MergeFrom; <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">void</span> Clear(); <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">bool</span> IsInitialized() <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">const</span>; <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int</span> ByteSize() <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">const</span>; <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">bool</span> MergePartialFromCodedStream(); <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">void</span> SerializeWithCachedSizes() <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">const</span>; SerializeWithCachedSizesToArray() <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">const</span>; <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int</span> GetCachedSize() <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">void</span> SharedCtor(); <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">void</span> SharedDtor(); <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">void</span> SetCachedSize() <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">const</span>;</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li><li style="box-sizing: border-box; padding: 0px 5px;">11</li><li style="box-sizing: border-box; padding: 0px 5px;">12</li><li style="box-sizing: border-box; padding: 0px 5px;">13</li><li style="box-sizing: border-box; padding: 0px 5px;">14</li></ul>
<0> BlobProto
<code class="hljs vala has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">message BlobProto {<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//blob的属性以及blob中的数据(data\diff)</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> num = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> channels = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> height = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> width = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; repeated <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> data = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">5</span> [packed = <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">true</span>]; repeated <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> diff = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">6</span> [packed = <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">true</span>]; }</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li></ul>
<1> Datum
<code class="hljs vala has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"> message Datum { optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> channels = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>; optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> height = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>; optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> width = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3</span>; optional bytes data = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4</span>;<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//真实的图像数据,以字节存储(bytes)</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> label = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">5</span>; repeated <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> float_data = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">6</span>;<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//datum也能存float类型的数据(float)</span> }</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li></ul>
<2> LayerParameter
<code class="hljs cs has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">message LayerParameter { repeated <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> bottom = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//输入的blob的名字(string)</span> repeated <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> top = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//输出的blob的名字(string)</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> name = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//层的名字</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">enum</span> LayerType { <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//层的枚举(enum,和c++中的enum一样)</span> NONE = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>; ACCURACY = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>; BNLL = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>; CONCAT = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3</span>; CONVOLUTION = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4</span>; DATA = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">5</span>; DROPOUT = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">6</span>; EUCLIDEAN_LOSS = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7</span>; ELTWISE_PRODUCT = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">25</span>; FLATTEN = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">8</span>; HDF5_DATA = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">9</span>; HDF5_OUTPUT = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">10</span>; HINGE_LOSS = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">28</span>; IM2COL = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">11</span>; IMAGE_DATA = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">12</span>; INFOGAIN_LOSS = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">13</span>; INNER_PRODUCT = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">14</span>; LRN = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">15</span>; MEMORY_DATA = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">29</span>; MULTINOMIAL_LOGISTIC_LOSS = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">16</span>; POOLING = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">17</span>; POWER = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">26</span>; RELU = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">18</span>; SIGMOID = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">19</span>; SIGMOID_CROSS_ENTROPY_LOSS = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">27</span>; SOFTMAX = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">20</span>; SOFTMAX_LOSS = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">21</span>; SPLIT = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">22</span>; TANH = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">23</span>; WINDOW_DATA = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">24</span>; } optional LayerType type = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">5</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// 层的类型</span> repeated BlobProto blobs = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">6</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//blobs的数值参数</span> repeated <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> blobs_lr = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//学习速率(repeated),如果你想那个设置一个blob的学习速率,你需要设置所有blob的学习速率。</span> repeated <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> weight_decay = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">8</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//权值衰减(repeated)</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// 相对于某一特定层的参数(optional)</span> optional ConcatParameter concat_param = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">9</span>; optional ConvolutionParameter convolution_param = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">10</span>; optional DataParameter data_param = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">11</span>; optional DropoutParameter dropout_param = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">12</span>; optional HDF5DataParameter hdf5_data_param = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">13</span>; optional HDF5OutputParameter hdf5_output_param = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">14</span>; optional ImageDataParameter image_data_param = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">15</span>; optional InfogainLossParameter infogain_loss_param = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">16</span>; optional InnerProductParameter inner_product_param = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">17</span>; optional LRNParameter lrn_param = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">18</span>; optional MemoryDataParameter memory_data_param = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">22</span>; optional PoolingParameter pooling_param = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">19</span>; optional PowerParameter power_param = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">21</span>; optional WindowDataParameter window_data_param = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">20</span>; optional V0LayerParameter layer = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>; }</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li><li style="box-sizing: border-box; padding: 0px 5px;">11</li><li style="box-sizing: border-box; padding: 0px 5px;">12</li><li style="box-sizing: border-box; padding: 0px 5px;">13</li><li style="box-sizing: border-box; padding: 0px 5px;">14</li><li style="box-sizing: border-box; padding: 0px 5px;">15</li><li style="box-sizing: border-box; padding: 0px 5px;">16</li><li style="box-sizing: border-box; padding: 0px 5px;">17</li><li style="box-sizing: border-box; padding: 0px 5px;">18</li><li style="box-sizing: border-box; padding: 0px 5px;">19</li><li style="box-sizing: border-box; padding: 0px 5px;">20</li><li style="box-sizing: border-box; padding: 0px 5px;">21</li><li style="box-sizing: border-box; padding: 0px 5px;">22</li><li style="box-sizing: border-box; padding: 0px 5px;">23</li><li style="box-sizing: border-box; padding: 0px 5px;">24</li><li style="box-sizing: border-box; padding: 0px 5px;">25</li><li style="box-sizing: border-box; padding: 0px 5px;">26</li><li style="box-sizing: border-box; padding: 0px 5px;">27</li><li style="box-sizing: border-box; padding: 0px 5px;">28</li><li style="box-sizing: border-box; padding: 0px 5px;">29</li><li style="box-sizing: border-box; padding: 0px 5px;">30</li><li style="box-sizing: border-box; padding: 0px 5px;">31</li><li style="box-sizing: border-box; padding: 0px 5px;">32</li><li style="box-sizing: border-box; padding: 0px 5px;">33</li><li style="box-sizing: border-box; padding: 0px 5px;">34</li><li style="box-sizing: border-box; padding: 0px 5px;">35</li><li style="box-sizing: border-box; padding: 0px 5px;">36</li><li style="box-sizing: border-box; padding: 0px 5px;">37</li><li style="box-sizing: border-box; padding: 0px 5px;">38</li><li style="box-sizing: border-box; padding: 0px 5px;">39</li><li style="box-sizing: border-box; padding: 0px 5px;">40</li><li style="box-sizing: border-box; padding: 0px 5px;">41</li><li style="box-sizing: border-box; padding: 0px 5px;">42</li><li style="box-sizing: border-box; padding: 0px 5px;">43</li><li style="box-sizing: border-box; padding: 0px 5px;">44</li><li style="box-sizing: border-box; padding: 0px 5px;">45</li><li style="box-sizing: border-box; padding: 0px 5px;">46</li><li style="box-sizing: border-box; padding: 0px 5px;">47</li><li style="box-sizing: border-box; padding: 0px 5px;">48</li><li style="box-sizing: border-box; padding: 0px 5px;">49</li><li style="box-sizing: border-box; padding: 0px 5px;">50</li><li style="box-sizing: border-box; padding: 0px 5px;">51</li><li style="box-sizing: border-box; padding: 0px 5px;">52</li><li style="box-sizing: border-box; padding: 0px 5px;">53</li><li style="box-sizing: border-box; padding: 0px 5px;">54</li><li style="box-sizing: border-box; padding: 0px 5px;">55</li><li style="box-sizing: border-box; padding: 0px 5px;">56</li><li style="box-sizing: border-box; padding: 0px 5px;">57</li><li style="box-sizing: border-box; padding: 0px 5px;">58</li></ul>
<3> NetParameter
<code class="hljs vala has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">message NetParameter { optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> name = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>;<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//网络的名字</span> repeated LayerParameter layers = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//repeated类似于数组</span> repeated <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> input = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3</span>;<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//输入层blob的名字</span> repeated <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> input_dim = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4</span>;<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//输入层blob的维度,应该等于(4*#input)</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">bool</span> force_backward = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">5</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">false</span>];<span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//网络是否进行反向传播。如果设置为否,则由网络的结构和学习速率来决定是否进行反向传播。</span> }</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li></ul>
<4> SolverParameter
<code class="hljs vala has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">message SolverParameter { optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> train_net = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// 训练网络的proto file</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> test_net = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// 测试网络的proto file</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> test_iter = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// 每次测试时的迭代次数</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> test_interval = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// 两次测试的间隔迭代次数</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">bool</span> test_compute_loss = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">19</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">false</span>]; optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> base_lr = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">5</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// 基本学习率</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> display = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">6</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// 两次显示的间隔迭代次数</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> max_iter = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// 最大迭代次数</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> lr_policy = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">8</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// 学习速率衰减方式</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> gamma = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">9</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// 关于梯度下降的一个参数</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> power = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">10</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// 计算学习率的一个参数</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> momentum = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">11</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// 动量</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> weight_decay = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">12</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// 权值衰减</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> stepsize = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">13</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// 学习速率的衰减步长</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> snapshot = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">14</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// snapshot的间隔</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> snapshot_prefix = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">15</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// snapshot的前缀</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">bool</span> snapshot_diff = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">16</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">false</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// 是否对于 diff 进行 snapshot</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">enum</span> SolverMode { <span class="hljs-constant" style="box-sizing: border-box;"> CPU </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>; <span class="hljs-constant" style="box-sizing: border-box;"> GPU </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>; } optional SolverMode solver_mode = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">17</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = GPU]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// solver的模式,默认为GPU</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> device_id = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">18</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// GPU的ID</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int64</span> random_seed = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">20</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = -<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// 随机数种子</span> }</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li><li style="box-sizing: border-box; padding: 0px 5px;">10</li><li style="box-sizing: border-box; padding: 0px 5px;">11</li><li style="box-sizing: border-box; padding: 0px 5px;">12</li><li style="box-sizing: border-box; padding: 0px 5px;">13</li><li style="box-sizing: border-box; padding: 0px 5px;">14</li><li style="box-sizing: border-box; padding: 0px 5px;">15</li><li style="box-sizing: border-box; padding: 0px 5px;">16</li><li style="box-sizing: border-box; padding: 0px 5px;">17</li><li style="box-sizing: border-box; padding: 0px 5px;">18</li><li style="box-sizing: border-box; padding: 0px 5px;">19</li><li style="box-sizing: border-box; padding: 0px 5px;">20</li><li style="box-sizing: border-box; padding: 0px 5px;">21</li><li style="box-sizing: border-box; padding: 0px 5px;">22</li><li style="box-sizing: border-box; padding: 0px 5px;">23</li><li style="box-sizing: border-box; padding: 0px 5px;">24</li><li style="box-sizing: border-box; padding: 0px 5px;">25</li><li style="box-sizing: border-box; padding: 0px 5px;">26</li></ul>
三、caffe.proto源码
<code class="language-c++ hljs vala has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Copyright 2014 BVLC and contributors.</span> package caffe; message BlobProto { optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> num = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> channels = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> height = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> width = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; repeated <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> data = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">5</span> [packed = <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">true</span>]; repeated <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> diff = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">6</span> [packed = <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">true</span>]; } <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The BlobProtoVector is simply a way to pass multiple blobproto instances</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// around.</span> message BlobProtoVector { repeated BlobProto blobs = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>; } message Datum { optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> channels = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>; optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> height = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>; optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> width = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// the actual image data, in bytes</span> optional bytes data = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4</span>; optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> label = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">5</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Optionally, the datum could also hold float data.</span> repeated <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> float_data = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">6</span>; } message FillerParameter { <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The filler type.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> type = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">'constant'</span>]; optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> value = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// the value in constant filler</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> min = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// the min value in uniform filler</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> max = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// the max value in uniform filler</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> mean = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">5</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// the mean value in Gaussian filler</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> std = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">6</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// the std value in Gaussian filler</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The expected number of non-zero input weights for a given output in</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Gaussian filler -- the default -1 means don't perform sparsification.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> sparse = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = -<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>]; } message NetParameter { optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> name = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// consider giving the network a name</span> repeated LayerParameter layers = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// a bunch of layers.</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The input blobs to the network.</span> repeated <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> input = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The dim of the input blobs. For each input blob there should be four</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// values specifying the num, channels, height and width of the input blob.</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Thus, there should be a total of (4 * #input) numbers.</span> repeated <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> input_dim = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Whether the network will force every layer to carry out backward operation.</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// If set False, then whether to carry out backward is determined</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// automatically according to the net structure and learning rates.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">bool</span> force_backward = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">5</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">false</span>]; } message SolverParameter { optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> train_net = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The proto file for the training net.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> test_net = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The proto file for the testing net.</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The number of iterations for each testing phase.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> test_iter = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The number of iterations between two testing phases.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> test_interval = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">bool</span> test_compute_loss = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">19</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">false</span>]; optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> base_lr = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">5</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The base learning rate</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// the number of iterations between displaying info. If display = 0, no info</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// will be displayed.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> display = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">6</span>; optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> max_iter = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// the maximum number of iterations</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> lr_policy = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">8</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The learning rate decay policy.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> gamma = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">9</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The parameter to compute the learning rate.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> power = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">10</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The parameter to compute the learning rate.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> momentum = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">11</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The momentum value.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> weight_decay = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">12</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The weight decay.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> stepsize = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">13</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// the stepsize for learning rate policy "step"</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> snapshot = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">14</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The snapshot interval</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> snapshot_prefix = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">15</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The prefix for the snapshot.</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// whether to snapshot diff in the results or not. Snapshotting diff will help</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// debugging but the final protocol buffer size will be much larger.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">bool</span> snapshot_diff = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">16</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">false</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// the mode solver will use: 0 for CPU and 1 for GPU. Use GPU in default.</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">enum</span> SolverMode { <span class="hljs-constant" style="box-sizing: border-box;"> CPU </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>; <span class="hljs-constant" style="box-sizing: border-box;"> GPU </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>; } optional SolverMode solver_mode = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">17</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = GPU]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// the device_id will that be used in GPU mode. Use device_id = 0 in default.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> device_id = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">18</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// If non-negative, the seed with which the Solver will initialize the Caffe</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// random number generator -- useful for reproducible results. Otherwise,</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// (and by default) initialize using a seed derived from the system clock.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int64</span> random_seed = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">20</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = -<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>]; } <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// A message that stores the solver snapshots</span> message SolverState { optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> iter = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The current iteration</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> learned_net = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The file that stores the learned net.</span> repeated BlobProto history = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The history for sgd solvers</span> } <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Update the next available ID when you add a new LayerParameter field.</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// LayerParameter next available ID: 23 (last added: memory_data_param)</span> message LayerParameter { repeated <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> bottom = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// the name of the bottom blobs</span> repeated <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> top = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// the name of the top blobs</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> name = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// the layer name</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Add new LayerTypes to the enum below in lexicographical order (other than</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// starting with NONE), starting with the next available ID in the comment</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// line above the enum. Update the next available ID when you add a new</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// LayerType.</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// LayerType next available ID: 30 (last added: MEMORY_DATA)</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">enum</span> LayerType { <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// "NONE" layer type is 0th enum element so that we don't cause confusion</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// by defaulting to an existent LayerType (instead, should usually error if</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// the type is unspecified).</span> <span class="hljs-constant" style="box-sizing: border-box;"> NONE </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>; <span class="hljs-constant" style="box-sizing: border-box;"> ACCURACY </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>; <span class="hljs-constant" style="box-sizing: border-box;"> BNLL </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>; <span class="hljs-constant" style="box-sizing: border-box;"> CONCAT </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3</span>; <span class="hljs-constant" style="box-sizing: border-box;"> CONVOLUTION </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4</span>; <span class="hljs-constant" style="box-sizing: border-box;"> DATA </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">5</span>; <span class="hljs-constant" style="box-sizing: border-box;"> DROPOUT </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">6</span>; <span class="hljs-constant" style="box-sizing: border-box;"> EUCLIDEAN_LOSS </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7</span>; <span class="hljs-constant" style="box-sizing: border-box;"> ELTWISE_PRODUCT </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">25</span>; <span class="hljs-constant" style="box-sizing: border-box;"> FLATTEN </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">8</span>; HDF5_DATA = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">9</span>; HDF5_OUTPUT = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">10</span>; <span class="hljs-constant" style="box-sizing: border-box;"> HINGE_LOSS </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">28</span>; IM2COL = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">11</span>; <span class="hljs-constant" style="box-sizing: border-box;"> IMAGE_DATA </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">12</span>; <span class="hljs-constant" style="box-sizing: border-box;"> INFOGAIN_LOSS </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">13</span>; <span class="hljs-constant" style="box-sizing: border-box;"> INNER_PRODUCT </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">14</span>; <span class="hljs-constant" style="box-sizing: border-box;"> LRN </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">15</span>; <span class="hljs-constant" style="box-sizing: border-box;"> MEMORY_DATA </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">29</span>; <span class="hljs-constant" style="box-sizing: border-box;"> MULTINOMIAL_LOGISTIC_LOSS </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">16</span>; <span class="hljs-constant" style="box-sizing: border-box;"> POOLING </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">17</span>; <span class="hljs-constant" style="box-sizing: border-box;"> POWER </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">26</span>; <span class="hljs-constant" style="box-sizing: border-box;"> RELU </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">18</span>; <span class="hljs-constant" style="box-sizing: border-box;"> SIGMOID </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">19</span>; <span class="hljs-constant" style="box-sizing: border-box;"> SIGMOID_CROSS_ENTROPY_LOSS </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">27</span>; <span class="hljs-constant" style="box-sizing: border-box;"> SOFTMAX </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">20</span>; <span class="hljs-constant" style="box-sizing: border-box;"> SOFTMAX_LOSS </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">21</span>; <span class="hljs-constant" style="box-sizing: border-box;"> SPLIT </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">22</span>; <span class="hljs-constant" style="box-sizing: border-box;"> TANH </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">23</span>; <span class="hljs-constant" style="box-sizing: border-box;"> WINDOW_DATA </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">24</span>; } optional LayerType type = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">5</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// the layer type from the enum above</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The blobs containing the numeric parameters of the layer</span> repeated BlobProto blobs = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">6</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The ratio that is multiplied on the global learning rate. If you want to</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// set the learning ratio for one blob, you need to set it for all blobs.</span> repeated <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> blobs_lr = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The weight decay that is multiplied on the global weight decay.</span> repeated <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> weight_decay = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">8</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Parameters for particular layer types.</span> optional ConcatParameter concat_param = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">9</span>; optional ConvolutionParameter convolution_param = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">10</span>; optional DataParameter data_param = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">11</span>; optional DropoutParameter dropout_param = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">12</span>; optional HDF5DataParameter hdf5_data_param = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">13</span>; optional HDF5OutputParameter hdf5_output_param = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">14</span>; optional ImageDataParameter image_data_param = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">15</span>; optional InfogainLossParameter infogain_loss_param = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">16</span>; optional InnerProductParameter inner_product_param = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">17</span>; optional LRNParameter lrn_param = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">18</span>; optional MemoryDataParameter memory_data_param = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">22</span>; optional PoolingParameter pooling_param = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">19</span>; optional PowerParameter power_param = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">21</span>; optional WindowDataParameter window_data_param = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">20</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// DEPRECATED: The layer parameters specified as a V0LayerParameter.</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// This should never be used by any code except to upgrade to the new</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// LayerParameter specification.</span> optional V0LayerParameter layer = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>; } <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Message that stores parameters used by ConcatLayer</span> message ConcatParameter { <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Concat Layer needs to specify the dimension along the concat will happen,</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// the other dimensions must be the same for all the bottom blobs</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// By default it will concatenate blobs along channels dimension</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> concat_dim = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>]; } <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Message that stores parameters used by ConvolutionLayer</span> message ConvolutionParameter { optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> num_output = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The number of outputs for the layer</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">bool</span> bias_term = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">true</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// whether to have bias terms</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> pad = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The padding size</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> kernel_size = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The kernel size</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> group = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">5</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The group size for group conv</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> stride = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">6</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The stride</span> optional FillerParameter weight_filler = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The filler for the weight</span> optional FillerParameter bias_filler = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">8</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The filler for the bias</span> } <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Message that stores parameters used by DataLayer</span> message DataParameter { <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Specify the data source.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> source = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// For data pre-processing, we can do simple scaling and subtracting the</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// data mean, if provided. Note that the mean subtraction is always carried</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// out before scaling.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> scale = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>]; optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> mean_file = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Specify the batch size.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> batch_size = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Specify if we would like to randomly crop an image.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> crop_size = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">5</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Specify if we want to randomly mirror data.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">bool</span> mirror = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">6</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">false</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The rand_skip variable is for the data layer to skip a few data points</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// to avoid all asynchronous sgd clients to start at the same point. The skip</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// point would be set as rand_skip * rand(0,1). Note that rand_skip should not</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// be larger than the number of keys in the leveldb.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> rand_skip = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; } <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Message that stores parameters used by DropoutLayer</span> message DropoutParameter { optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> dropout_ratio = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// dropout ratio</span> } <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Message that stores parameters used by HDF5DataLayer</span> message HDF5DataParameter { <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Specify the data source.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> source = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Specify the batch size.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> batch_size = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>; } <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Message that stores parameters used by HDF5OutputLayer</span> message HDF5OutputParameter { optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> file_name = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>; } <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Message that stores parameters used by ImageDataLayer</span> message ImageDataParameter { <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Specify the data source.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> source = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// For data pre-processing, we can do simple scaling and subtracting the</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// data mean, if provided. Note that the mean subtraction is always carried</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// out before scaling.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> scale = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>]; optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> mean_file = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Specify the batch size.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> batch_size = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Specify if we would like to randomly crop an image.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> crop_size = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">5</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Specify if we want to randomly mirror data.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">bool</span> mirror = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">6</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">false</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The rand_skip variable is for the data layer to skip a few data points</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// to avoid all asynchronous sgd clients to start at the same point. The skip</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// point would be set as rand_skip * rand(0,1). Note that rand_skip should not</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// be larger than the number of keys in the leveldb.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> rand_skip = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Whether or not ImageLayer should shuffle the list of files at every epoch.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">bool</span> shuffle = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">8</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">false</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// It will also resize images if new_height or new_width are not zero.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> new_height = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">9</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> new_width = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">10</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; } <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Message that stores parameters InfogainLossLayer</span> message InfogainLossParameter { <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Specify the infogain matrix source.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> source = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>; } <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Message that stores parameters used by InnerProductLayer</span> message InnerProductParameter { optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> num_output = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The number of outputs for the layer</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">bool</span> bias_term = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">true</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// whether to have bias terms</span> optional FillerParameter weight_filler = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The filler for the weight</span> optional FillerParameter bias_filler = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The filler for the bias</span> } <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Message that stores parameters used by LRNLayer</span> message LRNParameter { optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> local_size = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">5</span>]; optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> alpha = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1.</span>]; optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> beta = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.75</span>]; <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">enum</span> NormRegion { <span class="hljs-constant" style="box-sizing: border-box;"> ACROSS_CHANNELS </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>; <span class="hljs-constant" style="box-sizing: border-box;"> WITHIN_CHANNEL </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>; } optional NormRegion norm_region = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = ACROSS_CHANNELS]; } <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Message that stores parameters used by MemoryDataLayer</span> message MemoryDataParameter { optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> batch_size = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>; optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> channels = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>; optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> height = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3</span>; optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> width = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4</span>; } <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Message that stores parameters used by PoolingLayer</span> message PoolingParameter { <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">enum</span> PoolMethod { <span class="hljs-constant" style="box-sizing: border-box;"> MAX </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>; <span class="hljs-constant" style="box-sizing: border-box;"> AVE </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>; <span class="hljs-constant" style="box-sizing: border-box;"> STOCHASTIC </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>; } optional PoolMethod pool = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = MAX]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The pooling method</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> kernel_size = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The kernel size</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> stride = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The stride</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The padding size -- currently implemented only for average pooling.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> pad = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; } <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Message that stores parameters used by PowerLayer</span> message PowerParameter { <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// PowerLayer computes outputs y = (shift + scale * x) ^ power.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> power = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1.0</span>]; optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> scale = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1.0</span>]; optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> shift = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.0</span>]; } <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Message that stores parameters used by WindowDataLayer</span> message WindowDataParameter { <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Specify the data source.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> source = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// For data pre-processing, we can do simple scaling and subtracting the</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// data mean, if provided. Note that the mean subtraction is always carried</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// out before scaling.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> scale = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>]; optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> mean_file = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Specify the batch size.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> batch_size = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Specify if we would like to randomly crop an image.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> crop_size = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">5</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Specify if we want to randomly mirror data.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">bool</span> mirror = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">6</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">false</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Foreground (object) overlap threshold</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> fg_threshold = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Background (non-object) overlap threshold</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> bg_threshold = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">8</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Fraction of batch that should be foreground objects</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> fg_fraction = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">9</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.25</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Amount of contextual padding to add around a window</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// (used only by the window_data_layer)</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> context_pad = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">10</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Mode for cropping out a detection window</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// warp: cropped window is warped to a fixed size and aspect ratio</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// square: the tightest square around the window is cropped</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> crop_mode = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">11</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"warp"</span>]; } <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// DEPRECATED: V0LayerParameter is the old way of specifying layer parameters</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// in Caffe. We keep this message type around for legacy support.</span> message V0LayerParameter { optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> name = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// the layer name</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> type = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// the string to specify the layer type</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Parameters to specify layers with inner products.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> num_output = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The number of outputs for the layer</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">bool</span> biasterm = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">true</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// whether to have bias terms</span> optional FillerParameter weight_filler = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">5</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The filler for the weight</span> optional FillerParameter bias_filler = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">6</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The filler for the bias</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> pad = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The padding size</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> kernelsize = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">8</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The kernel size</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> group = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">9</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The group size for group conv</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> stride = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">10</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The stride</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">enum</span> PoolMethod { <span class="hljs-constant" style="box-sizing: border-box;"> MAX </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>; <span class="hljs-constant" style="box-sizing: border-box;"> AVE </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>; <span class="hljs-constant" style="box-sizing: border-box;"> STOCHASTIC </span>= <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>; } optional PoolMethod pool = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">11</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = MAX]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The pooling method</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> dropout_ratio = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">12</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// dropout ratio</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> local_size = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">13</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">5</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// for local response norm</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> alpha = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">14</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1.</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// for local response norm</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> beta = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">15</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.75</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// for local response norm</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// For data layers, specify the data source</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> source = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">16</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// For data pre-processing, we can do simple scaling and subtracting the</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// data mean, if provided. Note that the mean subtraction is always carried</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// out before scaling.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> scale = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">17</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>]; optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> meanfile = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">18</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// For data layers, specify the batch size.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> batchsize = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">19</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// For data layers, specify if we would like to randomly crop an image.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> cropsize = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">20</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// For data layers, specify if we want to randomly mirror data.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">bool</span> mirror = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">21</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">false</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The blobs containing the numeric parameters of the layer</span> repeated BlobProto blobs = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">50</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The ratio that is multiplied on the global learning rate. If you want to</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// set the learning ratio for one blob, you need to set it for all blobs.</span> repeated <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> blobs_lr = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">51</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The weight decay that is multiplied on the global weight decay.</span> repeated <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> weight_decay = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">52</span>; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// The rand_skip variable is for the data layer to skip a few data points</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// to avoid all asynchronous sgd clients to start at the same point. The skip</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// point would be set as rand_skip * rand(0,1). Note that rand_skip should not</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// be larger than the number of keys in the leveldb.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> rand_skip = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">53</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Fields related to detection (det_*)</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// foreground (object) overlap threshold</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> det_fg_threshold = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">54</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// background (non-object) overlap threshold</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> det_bg_threshold = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">55</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Fraction of batch that should be foreground objects</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">float</span> det_fg_fraction = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">56</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.25</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// optional bool OBSOLETE_can_clobber = 57 [default = true];</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Amount of contextual padding to add around a window</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// (used only by the window_data_layer)</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> det_context_pad = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">58</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Mode for cropping out a detection window</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// warp: cropped window is warped to a fixed size and aspect ratio</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// square: the tightest square around the window is cropped</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">string</span> det_crop_mode = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">59</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"warp"</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// For ReshapeLayer, one needs to specify the new dimensions.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> new_num = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">60</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> new_channels = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">61</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> new_height = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">62</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">int32</span> new_width = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">63</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// Whether or not ImageLayer should shuffle the list of files at every epoch.</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// It will also resize images if new_height or new_width are not zero.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">bool</span> shuffle_images = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">64</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-literal" style="color: rgb(0, 102, 102); box-sizing: border-box;">false</span>]; <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// For ConcatLayer, one needs to specify the dimension for concatenation, and</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// the other dimensions must be the same for all the bottom blobs.</span> <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">// By default it will concatenate blobs along the channels dimension.</span> optional <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">uint32</span> concat_dim = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">65</span> [<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">default</span> = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>]; optional HDF5OutputParameter hdf5_output_param = <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1001</span>; }</code>