When I convert onnx model to caffe mode, there is a problem. I want to adding two feature map pixel by pixel, like matrix shape A is (3x80x80x2) and B is (3x80x80x2). And A is from caffe layer output, but B is a constant matrix (from learned param in onnx). I consider use Eltwise layer in caffe but the layer must have two input blob. Then I use Bias layer and set the only 1 input blob, because if Bias layer have only 1 input, it will use filler blob to adding.
Bias layer have filler parameter, how can I fit my constant matrix data to the filler blob using pycaffe?
my prototxt like this:
layer {
name: "bias"
type: "Bias"
bottom: "A"
top: "bias_output"
}
my code like this:
layer = net.params['bias'][0].data[...] = B
raise some error: shape not match, error: B shape is (3x80x80x2), net.params['bias'][0].data shape is (3,)
or other ideas? How can I solve this problem?
in caffe src prototxt, BiasParameter define in below.
message BiasParameter {
// The first axis of bottom[0] (the first input Blob) along which to apply
// bottom[1] (the second input Blob). May be negative to index from the end
// (e.g., -1 for the last axis).
//
// For example, if bottom[0] is 4D with shape 100x3x40x60, the output
// top[0] will have the same shape, and bottom[1] may have any of the
// following shapes (for the given value of axis):
// (axis == 0 == -4) 100; 100x3; 100x3x40; 100x3x40x60
// (axis == 1 == -3) 3; 3x40; 3x40x60
// (axis == 2 == -2) 40; 40x60
// (axis == 3 == -1) 60
// Furthermore, bottom[1] may have the empty shape (regardless of the value of
// "axis") -- a scalar bias.
optional int32 axis = 1 [default = 1];
// (num_axes is ignored unless just one bottom is given and the bias is
// a learned parameter of the layer. Otherwise, num_axes is determined by the
// number of axes by the second bottom.)
// The number of axes of the input (bottom[0]) covered by the bias
// parameter, or -1 to cover all axes of bottom[0] starting from `axis`.
// Set num_axes := 0, to add a zero-axis Blob: a scalar.
optional int32 num_axes = 2 [default = 1];
// (filler is ignored unless just one bottom is given and the bias is
// a learned parameter of the layer.)
// The initialization for the learned bias parameter.
// Default is the zero (0) initialization, resulting in the BiasLayer
// initially performing the identity operation.
optional FillerParameter filler = 3;
}
and