<p>让我们看看BVLC/caffe提供的一个示例:<a href="https://github.com/BVLC/caffe/tree/master/models/bvlc_reference_caffenet" rel="nofollow noreferrer">^{<cd1>}</a>。<br/>
您会注意到,实际上有<strong>3</strong><code>'.prototxt'</code>文件:</p>
<ul>
<li><a href="https://github.com/BVLC/caffe/blob/master/models/bvlc_reference_caffenet/train_val.prototxt" rel="nofollow noreferrer">^{<cd3>}</a>:这个文件描述了训练阶段的网络体系结构。在</li>
<li><a href="https://github.com/BVLC/caffe/blob/master/models/bvlc_reference_caffenet/deploy.prototxt" rel="nofollow noreferrer">^{<cd4>}</a>:这个文件描述了测试时的网络体系结构(“部署”)。在</li>
<li><a href="https://github.com/BVLC/caffe/blob/master/models/bvlc_reference_caffenet/solver.prototxt" rel="nofollow noreferrer">^{<cd5>}</a>:这个文件非常小,包含用于训练的“元参数”。例如,<a href="https://stackoverflow.com/questions/30033096/what-is-lr-policy-in-caffe/30045244#30045244">learning rate policy</a>,<a href="https://stackoverflow.com/questions/32177764/what-is-weight-decay-meta-parameter-in-caffe">regulariztion</a>等</li>
</ul>
<p>由<code>train_val.prototxt</code>和<code>deploy.prototxt</code>表示的网络体系结构应该基本相似。两者之间几乎没有什么主要区别:</p>
<ul>
<li><p>输入数据:在培训期间,通常使用一组预定义的输入进行培训/验证。因此,<code>train_val</code>通常包含显式输入层,例如<code>"HDF5Data"</code>层或<code>"Data"</code>层。另一方面,<code>deploy</code>通常不知道它将得到什么输入,它只包含一个语句:</p>
<pre><code>input: "data"
input_shape {
dim: 10
dim: 3
dim: 227
dim: 227
}
</code></pre>
<p>它声明了网络需要什么输入以及它的维度是什么。<br/>
或者,可以放置<a href="http://caffe.help/manual/layers/input.html" rel="nofollow noreferrer">^{<cd12>}</a>层:</p>
<pre><code>layer {
name: "input"
type: "Input"
top: "data"
input_param { shape { dim: 10 dim: 3 dim: 227 dim: 227 } }
}
</code></pre></li>
<li>输入标签:在训练期间,我们向网络提供“基本真实”的预期输出,在<code>deploy</code>期间,这些信息显然不可用。在</li>
<li>损失层:在培训期间,必须定义损失层。该层告诉解算器在每次迭代时应该调整参数的方向。这个损失将网络当前的预测与预期的“真实情况”相比较。损失的梯度会反向传播到网络的其他部分,这就是驱动学习过程的原因。在<code>deploy</code>期间,没有丢失和反向传播。在</li>
</ul>
<p>在caffe中,您提供一个<code>train_val.prototxt</code>来描述网络、train/val数据集和丢失。此外,您还提供了一个<code>solver.prototxt</code>来描述用于训练的元参数。训练过程的<em>输出</em>是一个<code>.caffemodel</code>二进制文件,包含网络的训练参数。<br/>
一旦训练完网络,就可以使用<code>deploy.prototxt</code>和<code>.caffemodel</code>参数来预测新的和未看到的输入的输出。在</p>