如何在大网中设置学习率以在 Caffe 中进行微调?

How to set learning rate in a big net for fine-tuning in Caffe?

我有一张多层的大网。我在网络中添加了一个新的全连接层,想做一个微调。然而,除了新层之外,很难在每一层都设置lr_mult: 0,因为网络中有很多层。
有什么好的方法可以解决这些问题吗?

谢谢。

怎么样,而不是将所有参数设置为 lr_mult: 0 到新的全连接层之前的所有层,只是在新层之后停止反向传播?

您可以通过设置 propagate_down: false 来做到这一点。
例如:

layer {
  name: "new_layer"
  type: "InnerProduct"
  ...
  inner_product_param {
    ...
  }
  propagate_down: false # do not continue backprop after this layer
}

或者,您可以使用命令行实用程序 sed 直接更改 prototxt 文件中的所有条目:

~$ sed -i -E 's/lr_mult *: *[0-9]+/lr_mult: 0/g' train_val.prototxt

这一行会将您 train_val.prototxt 中的所有 lr_mult 更改为零。您只需要手动为新图层设置lr_mult