Skip to content

Borrowing Weights from a Pretrained Network

Domenic Curro edited this page Feb 23, 2016 · 5 revisions

Borrowing Weights

What are Weights

Weights are learnable parameters in the network, which are tuned by the back propagation phase.

Who Makes the Weights?

Weights are generated by caffe when your network in constructed.

Borrowing Weights from a Pretrained Network

To borrow the weights of an already trained model, we need to do two things:

  • Rename our layer to match the name of the original model's layer. The weights are assigned by layer name, thus using the original network's layer name, we get it's weights.

For example, let say the original model had a layer name ip1, then we should name our layer ip1:

layer {
  name: "ip1"
  type: "InnerProduct"
  bottom: "pool2"
  top: "ip1"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  inner_product_param {
    num_output: 500
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
}
  • Train our new hybrid model declaring the location of the weights:

caffe train —solver ourSolver.prototxt —weights theirModel.caffemodel

What About the Other Layers of Our Network?

The other layers of our network will be initialized just like any other brand new layer (usually ~zero).