GithubHelp home page GithubHelp logo

mxnet2caffe's Introduction

MXNet2Caffe: Convert MXNet model to Caffe model

You are welcome to file issues either for bugs in the source code, feature requests!

Brief Guide

Given a MXNet Model, MXNet2Caffe can automatically generate both .prototxt and .caffemodel.

Before starting using MXNet2Caffe, you need to manually set the path in find_caffe.py and find_mxnet.py.

After that, simply run python json2prototxt.py to generate the corresponding .prototxt.

And then, using python mxnet2caffe.py to generate the corresponding .caffemodel.

TODO

[1] Since there is no Flatten layer in caffe, you have to manually modify the automatically generated .prototxt. In other words, you have to change the bottom of the layer just after the Flatten layer making it linking to the layer before the Flatten layer. Currently, this part has to be done manually.

[2] The converted model scores a little bit worse than the original MXNet model.

[3] Code for automatically reversing the weight (and bias) of the first layer to support BGR input.

[4] Better support for caffe's in-place feature.

[5] Several TODOs in prototxt_basic.py

mxnet2caffe's People

Contributors

cypw avatar vermeille avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mxnet2caffe's Issues

Unknown bottom blob 'flatten' (layer 'fc', bottom index 0)

Hi, Thanks for your effort.

Here I encountered a problem when converting the default examples in this repo.
The procedure is quite simple:

$python json2prototxt.py

0, 	op:null                , name:data                           -> data
2, 	op:Convolution         , name:conv1__conv                    -> conv1__conv
           use shared weight -> data
5, 	op:BatchNorm           , name:conv1__bn__bn                  -> conv1__bn__bn
6, 	op:Activation          , name:conv1__bn__relu                -> conv1__bn__relu
8, 	op:Convolution         , name:conv2__conv                    -> conv2__conv
11, 	op:BatchNorm           , name:conv2__bn__bn                  -> conv2__bn__bn
12, 	op:Activation          , name:conv2__bn__relu                -> conv2__bn__relu
14, 	op:Convolution         , name:conv3_c1x1-a__conv             -> conv3_c1x1-a__conv
17, 	op:BatchNorm           , name:conv3_c1x1-a__bn__bn           -> conv3_c1x1-a__bn__bn
18, 	op:Activation          , name:conv3_c1x1-a__bn__relu         -> conv3_c1x1-a__bn__relu
20, 	op:Convolution         , name:conv3_c3x3-b__conv             -> conv3_c3x3-b__conv
23, 	op:BatchNorm           , name:conv3_c3x3-b__bn__bn           -> conv3_c3x3-b__bn__bn
24, 	op:Activation          , name:conv3_c3x3-b__bn__relu         -> conv3_c3x3-b__bn__relu
26, 	op:Convolution         , name:conv3_c1x1-c__conv             -> conv3_c1x1-c__conv
29, 	op:BatchNorm           , name:conv3_c1x1-c__bn__bn           -> conv3_c1x1-c__bn__bn
30, 	op:ElementWiseSum      , name:conv3_ele-sum                  -> conv3_ele-sum
31, 	op:Activation          , name:conv3_sum-act__relu            -> conv3_sum-act__relu
33, 	op:Convolution         , name:conv4_c1x1-w(s/2)__conv        -> conv4_c1x1-w(s/2)__conv
36, 	op:BatchNorm           , name:conv4_c1x1-w(s/2)__bn__bn      -> conv4_c1x1-w(s/2)__bn__bn
38, 	op:Convolution         , name:conv4_c1x1-a__conv             -> conv4_c1x1-a__conv
41, 	op:BatchNorm           , name:conv4_c1x1-a__bn__bn           -> conv4_c1x1-a__bn__bn
42, 	op:Activation          , name:conv4_c1x1-a__bn__relu         -> conv4_c1x1-a__bn__relu
44, 	op:Convolution         , name:conv4_c3x3-b__conv             -> conv4_c3x3-b__conv
47, 	op:BatchNorm           , name:conv4_c3x3-b__bn__bn           -> conv4_c3x3-b__bn__bn
48, 	op:Activation          , name:conv4_c3x3-b__bn__relu         -> conv4_c3x3-b__bn__relu
50, 	op:Convolution         , name:conv4_c1x1-c__conv             -> conv4_c1x1-c__conv
53, 	op:BatchNorm           , name:conv4_c1x1-c__bn__bn           -> conv4_c1x1-c__bn__bn
54, 	op:ElementWiseSum      , name:conv4_ele-sum                  -> conv4_ele-sum
55, 	op:Activation          , name:conv4_sum-act__relu            -> conv4_sum-act__relu
57, 	op:Convolution         , name:conv5_c1x1-a__conv             -> conv5_c1x1-a__conv
60, 	op:BatchNorm           , name:conv5_c1x1-a__bn__bn           -> conv5_c1x1-a__bn__bn
61, 	op:Activation          , name:conv5_c1x1-a__bn__relu         -> conv5_c1x1-a__bn__relu
63, 	op:Convolution         , name:conv5_c3x3-b__conv             -> conv5_c3x3-b__conv
66, 	op:BatchNorm           , name:conv5_c3x3-b__bn__bn           -> conv5_c3x3-b__bn__bn
67, 	op:Activation          , name:conv5_c3x3-b__bn__relu         -> conv5_c3x3-b__bn__relu
69, 	op:Convolution         , name:conv5_c1x1-c__conv             -> conv5_c1x1-c__conv
72, 	op:BatchNorm           , name:conv5_c1x1-c__bn__bn           -> conv5_c1x1-c__bn__bn
73, 	op:ElementWiseSum      , name:conv5_ele-sum                  -> conv5_ele-sum
74, 	op:Activation          , name:conv5_sum-act__relu            -> conv5_sum-act__relu
76, 	op:Convolution         , name:conv6_c1x1-w(s/2)__conv        -> conv6_c1x1-w(s/2)__conv
79, 	op:BatchNorm           , name:conv6_c1x1-w(s/2)__bn__bn      -> conv6_c1x1-w(s/2)__bn__bn
81, 	op:Convolution         , name:conv6_c1x1-a__conv             -> conv6_c1x1-a__conv
84, 	op:BatchNorm           , name:conv6_c1x1-a__bn__bn           -> conv6_c1x1-a__bn__bn
85, 	op:Activation          , name:conv6_c1x1-a__bn__relu         -> conv6_c1x1-a__bn__relu
87, 	op:Convolution         , name:conv6_c3x3-b__conv             -> conv6_c3x3-b__conv
90, 	op:BatchNorm           , name:conv6_c3x3-b__bn__bn           -> conv6_c3x3-b__bn__bn
91, 	op:Activation          , name:conv6_c3x3-b__bn__relu         -> conv6_c3x3-b__bn__relu
93, 	op:Convolution         , name:conv6_c1x1-c__conv             -> conv6_c1x1-c__conv
96, 	op:BatchNorm           , name:conv6_c1x1-c__bn__bn           -> conv6_c1x1-c__bn__bn
97, 	op:ElementWiseSum      , name:conv6_ele-sum                  -> conv6_ele-sum
98, 	op:Activation          , name:conv6_sum-act__relu            -> conv6_sum-act__relu
99, 	op:Pooling             , name:pool5                          -> pool5
100, 	op:Flatten             , name:flatten                        -> flatten
103, 	op:FullyConnected      , name:fc                             -> fc
105, 	op:SoftmaxOutput       , name:softmax                        -> softmax

$python mxnet2caffe.py

[09:31:04] src/nnvm/legacy_json_util.cc:190: Loading symbol saved by previous version v0.8.0. Attempting to upgrade...
[09:31:04] src/nnvm/legacy_json_util.cc:198: Symbol successfully upgraded!
WARNING: Logging before InitGoogleLogging() is written to STDERR
I0308 09:31:04.431555 2737054528 net.cpp:51] Initializing net from parameters: 
name: "mxnet-mdoel"
state {
  phase: TRAIN
  level: 0
}
layer {
  name: "data"
  type: "Input"
  top: "data"
  input_param {
    shape {
      dim: 10
      dim: 3
      dim: 224
      dim: 224
    }
  }
}
layer {
  name: "conv1__conv"
  type: "Convolution"
  bottom: "data"
  top: "conv1__conv"
  param {
    name: "data"
  }
  convolution_param {
    num_output: 16
    bias_term: false
    pad: 1
    kernel_size: 3
    group: 1
    stride: 2
  }
}
layer {
  name: "conv1__bn__bn"
  type: "BatchNorm"
  bottom: "conv1__conv"
  top: "conv1__bn__bn"
  batch_norm_param {
    use_global_stats: true
    moving_average_fraction: 0.9
    eps: 0.001
  }
}
layer {
  name: "conv1__bn__bn_scale"
  type: "Scale"
  bottom: "conv1__bn__bn"
  top: "conv1__bn__bn"
  scale_param {
    bias_term: true
  }
}
layer {
  name: "conv1__bn__relu"
  type: "ReLU"
  bottom: "conv1__bn__bn"
  top: "conv1__bn__relu"
}
layer {
  name: "conv2__conv"
  type: "Convolution"
  bottom: "conv1__bn__relu"
  top: "conv2__conv"
  convolution_param {
    num_output: 16
    bias_term: false
    pad: 1
    kernel_size: 3
    group: 1
    stride: 2
  }
}
layer {
  name: "conv2__bn__bn"
  type: "BatchNorm"
  bottom: "conv2__conv"
  top: "conv2__bn__bn"
  batch_norm_param {
    use_global_stats: true
    moving_average_fraction: 0.9
    eps: 0.001
  }
}
layer {
  name: "conv2__bn__bn_scale"
  type: "Scale"
  bottom: "conv2__bn__bn"
  top: "conv2__bn__bn"
  scale_param {
    bias_term: true
  }
}
layer {
  name: "conv2__bn__relu"
  type: "ReLU"
  bottom: "conv2__bn__bn"
  top: "conv2__bn__relu"
}
layer {
  name: "conv3_c1x1-a__conv"
  type: "Convolution"
  bottom: "conv2__bn__relu"
  top: "conv3_c1x1-a__conv"
  convolution_param {
    num_output: 16
    bias_term: false
    pad: 0
    kernel_size: 1
    group: 1
    stride: 1
  }
}
layer {
  name: "conv3_c1x1-a__bn__bn"
  type: "BatchNorm"
  bottom: "conv3_c1x1-a__conv"
  top: "conv3_c1x1-a__bn__bn"
  batch_norm_param {
    use_global_stats: true
    moving_average_fraction: 0.9
    eps: 0.001
  }
}
layer {
  name: "conv3_c1x1-a__bn__bn_scale"
  type: "Scale"
  bottom: "conv3_c1x1-a__bn__bn"
  top: "conv3_c1x1-a__bn__bn"
  scale_param {
    bias_term: true
  }
}
layer {
  name: "conv3_c1x1-a__bn__relu"
  type: "ReLU"
  bottom: "conv3_c1x1-a__bn__bn"
  top: "conv3_c1x1-a__bn__relu"
}
layer {
  name: "conv3_c3x3-b__conv"
  type: "Convolution"
  bottom: "conv3_c1x1-a__bn__relu"
  top: "conv3_c3x3-b__conv"
  convolution_param {
    num_output: 16
    bias_term: false
    pad: 1
    kernel_size: 3
    group: 1
    stride: 1
  }
}
layer {
  name: "conv3_c3x3-b__bn__bn"
  type: "BatchNorm"
  bottom: "conv3_c3x3-b__conv"
  top: "conv3_c3x3-b__bn__bn"
  batch_norm_param {
    use_global_stats: true
    moving_average_fraction: 0.9
    eps: 0.001
  }
}
layer {
  name: "conv3_c3x3-b__bn__bn_scale"
  type: "Scale"
  bottom: "conv3_c3x3-b__bn__bn"
  top: "conv3_c3x3-b__bn__bn"
  scale_param {
    bias_term: true
  }
}
layer {
  name: "conv3_c3x3-b__bn__relu"
  type: "ReLU"
  bottom: "conv3_c3x3-b__bn__bn"
  top: "conv3_c3x3-b__bn__relu"
}
layer {
  name: "conv3_c1x1-c__conv"
  type: "Convolution"
  bottom: "conv3_c3x3-b__bn__relu"
  top: "conv3_c1x1-c__conv"
  convolution_param {
    num_output: 16
    bias_term: false
    pad: 0
    kernel_size: 1
    group: 1
    stride: 1
  }
}
layer {
  name: "conv3_c1x1-c__bn__bn"
  type: "BatchNorm"
  bottom: "conv3_c1x1-c__conv"
  top: "conv3_c1x1-c__bn__bn"
  batch_norm_param {
    use_global_stats: true
    moving_average_fraction: 0.9
    eps: 0.001
  }
}
layer {
  name: "conv3_c1x1-c__bn__bn_scale"
  type: "Scale"
  bottom: "conv3_c1x1-c__bn__bn"
  top: "conv3_c1x1-c__bn__bn"
  scale_param {
    bias_term: true
  }
}
layer {
  name: "conv3_ele-sum"
  type: "Eltwise"
  bottom: "conv2__bn__relu"
  bottom: "conv3_c1x1-c__bn__bn"
  top: "conv3_ele-sum"
}
layer {
  name: "conv3_sum-act__relu"
  type: "ReLU"
  bottom: "conv3_ele-sum"
  top: "conv3_sum-act__relu"
}
layer {
  name: "conv4_c1x1-w(s/2)__conv"
  type: "Convolution"
  bottom: "conv3_sum-act__relu"
  top: "conv4_c1x1-w(s/2)__conv"
  convolution_param {
    num_output: 32
    bias_term: false
    pad: 0
    kernel_size: 1
    group: 1
    stride: 2
  }
}
layer {
  name: "conv4_c1x1-w(s/2)__bn__bn"
  type: "BatchNorm"
  bottom: "conv4_c1x1-w(s/2)__conv"
  top: "conv4_c1x1-w(s/2)__bn__bn"
  batch_norm_param {
    use_global_stats: true
    moving_average_fraction: 0.9
    eps: 0.001
  }
}
layer {
  name: "conv4_c1x1-w(s/2)__bn__bn_scale"
  type: "Scale"
  bottom: "conv4_c1x1-w(s/2)__bn__bn"
  top: "conv4_c1x1-w(s/2)__bn__bn"
  scale_param {
    bias_term: true
  }
}
layer {
  name: "conv4_c1x1-a__conv"
  type: "Convolution"
  bottom: "conv3_sum-act__relu"
  top: "conv4_c1x1-a__conv"
  convolution_param {
    num_output: 32
    bias_term: false
    pad: 0
    kernel_size: 1
    group: 1
    stride: 1
  }
}
layer {
  name: "conv4_c1x1-a__bn__bn"
  type: "BatchNorm"
  bottom: "conv4_c1x1-a__conv"
  top: "conv4_c1x1-a__bn__bn"
  batch_norm_param {
    use_global_stats: true
    moving_average_fraction: 0.9
    eps: 0.001
  }
}
layer {
  name: "conv4_c1x1-a__bn__bn_scale"
  type: "Scale"
  bottom: "conv4_c1x1-a__bn__bn"
  top: "conv4_c1x1-a__bn__bn"
  scale_param {
    bias_term: true
  }
}
layer {
  name: "conv4_c1x1-a__bn__relu"
  type: "ReLU"
  bottom: "conv4_c1x1-a__bn__bn"
  top: "conv4_c1x1-a__bn__relu"
}
layer {
  name: "conv4_c3x3-b__conv"
  type: "Convolution"
  bottom: "conv4_c1x1-a__bn__relu"
  top: "conv4_c3x3-b__conv"
  convolution_param {
    num_output: 32
    bias_term: false
    pad: 1
    kernel_size: 3
    group: 1
    stride: 2
  }
}
layer {
  name: "conv4_c3x3-b__bn__bn"
  type: "BatchNorm"
  bottom: "conv4_c3x3-b__conv"
  top: "conv4_c3x3-b__bn__bn"
  batch_norm_param {
    use_global_stats: true
    moving_average_fraction: 0.9
    eps: 0.001
  }
}
layer {
  name: "conv4_c3x3-b__bn__bn_scale"
  type: "Scale"
  bottom: "conv4_c3x3-b__bn__bn"
  top: "conv4_c3x3-b__bn__bn"
  scale_param {
    bias_term: true
  }
}
layer {
  name: "conv4_c3x3-b__bn__relu"
  type: "ReLU"
  bottom: "conv4_c3x3-b__bn__bn"
  top: "conv4_c3x3-b__bn__relu"
}
layer {
  name: "conv4_c1x1-c__conv"
  type: "Convolution"
  bottom: "conv4_c3x3-b__bn__relu"
  top: "conv4_c1x1-c__conv"
  convolution_param {
    num_output: 32
    bias_term: false
    pad: 0
    kernel_size: 1
    group: 1
    stride: 1
  }
}
layer {
  name: "conv4_c1x1-c__bn__bn"
  type: "BatchNorm"
  bottom: "conv4_c1x1-c__conv"
  top: "conv4_c1x1-c__bn__bn"
  batch_norm_param {
    use_global_stats: true
    moving_average_fraction: 0.9
    eps: 0.001
  }
}
layer {
  name: "conv4_c1x1-c__bn__bn_scale"
  type: "Scale"
  bottom: "conv4_c1x1-c__bn__bn"
  top: "conv4_c1x1-c__bn__bn"
  scale_param {
    bias_term: true
  }
}
layer {
  name: "conv4_ele-sum"
  type: "Eltwise"
  bottom: "conv4_c1x1-w(s/2)__bn__bn"
  bottom: "conv4_c1x1-c__bn__bn"
  top: "conv4_ele-sum"
}
layer {
  name: "conv4_sum-act__relu"
  type: "ReLU"
  bottom: "conv4_ele-sum"
  top: "conv4_sum-act__relu"
}
layer {
  name: "conv5_c1x1-a__conv"
  type: "Convolution"
  bottom: "conv4_sum-act__relu"
  top: "conv5_c1x1-a__conv"
  convolution_param {
    num_output: 32
    bias_term: false
    pad: 0
    kernel_size: 1
    group: 1
    stride: 1
  }
}
layer {
  name: "conv5_c1x1-a__bn__bn"
  type: "BatchNorm"
  bottom: "conv5_c1x1-a__conv"
  top: "conv5_c1x1-a__bn__bn"
  batch_norm_param {
    use_global_stats: true
    moving_average_fraction: 0.9
    eps: 0.001
  }
}
layer {
  name: "conv5_c1x1-a__bn__bn_scale"
  type: "Scale"
  bottom: "conv5_c1x1-a__bn__bn"
  top: "conv5_c1x1-a__bn__bn"
  scale_param {
    bias_term: true
  }
}
layer {
  name: "conv5_c1x1-a__bn__relu"
  type: "ReLU"
  bottom: "conv5_c1x1-a__bn__bn"
  top: "conv5_c1x1-a__bn__relu"
}
layer {
  name: "conv5_c3x3-b__conv"
  type: "Convolution"
  bottom: "conv5_c1x1-a__bn__relu"
  top: "conv5_c3x3-b__conv"
  convolution_param {
    num_output: 32
    bias_term: false
    pad: 1
    kernel_size: 3
    group: 1
    stride: 1
  }
}
layer {
  name: "conv5_c3x3-b__bn__bn"
  type: "BatchNorm"
  bottom: "conv5_c3x3-b__conv"
  top: "conv5_c3x3-b__bn__bn"
  batch_norm_param {
    use_global_stats: true
    moving_average_fraction: 0.9
    eps: 0.001
  }
}
layer {
  name: "conv5_c3x3-b__bn__bn_scale"
  type: "Scale"
  bottom: "conv5_c3x3-b__bn__bn"
  top: "conv5_c3x3-b__bn__bn"
  scale_param {
    bias_term: true
  }
}
layer {
  name: "conv5_c3x3-b__bn__relu"
  type: "ReLU"
  bottom: "conv5_c3x3-b__bn__bn"
  top: "conv5_c3x3-b__bn__relu"
}
layer {
  name: "conv5_c1x1-c__conv"
  type: "Convolution"
  bottom: "conv5_c3x3-b__bn__relu"
  top: "conv5_c1x1-c__conv"
  convolution_param {
    num_output: 32
    bias_term: false
    pad: 0
    kernel_size: 1
    group: 1
    stride: 1
  }
}
layer {
  name: "conv5_c1x1-c__bn__bn"
  type: "BatchNorm"
  bottom: "conv5_c1x1-c__conv"
  top: "conv5_c1x1-c__bn__bn"
  batch_norm_param {
    use_global_stats: true
    moving_average_fraction: 0.9
    eps: 0.001
  }
}
layer {
  name: "conv5_c1x1-c__bn__bn_scale"
  type: "Scale"
  bottom: "conv5_c1x1-c__bn__bn"
  top: "conv5_c1x1-c__bn__bn"
  scale_param {
    bias_term: true
  }
}
layer {
  name: "conv5_ele-sum"
  type: "Eltwise"
  bottom: "conv4_sum-act__relu"
  bottom: "conv5_c1x1-c__bn__bn"
  top: "conv5_ele-sum"
}
layer {
  name: "conv5_sum-act__relu"
  type: "ReLU"
  bottom: "conv5_ele-sum"
  top: "conv5_sum-act__relu"
}
layer {
  name: "conv6_c1x1-w(s/2)__conv"
  type: "Convolution"
  bottom: "conv5_sum-act__relu"
  top: "conv6_c1x1-w(s/2)__conv"
  convolution_param {
    num_output: 32
    bias_term: false
    pad: 0
    kernel_size: 1
    group: 1
    stride: 2
  }
}
layer {
  name: "conv6_c1x1-w(s/2)__bn__bn"
  type: "BatchNorm"
  bottom: "conv6_c1x1-w(s/2)__conv"
  top: "conv6_c1x1-w(s/2)__bn__bn"
  batch_norm_param {
    use_global_stats: true
    moving_average_fraction: 0.9
    eps: 0.001
  }
}
layer {
  name: "conv6_c1x1-w(s/2)__bn__bn_scale"
  type: "Scale"
  bottom: "conv6_c1x1-w(s/2)__bn__bn"
  top: "conv6_c1x1-w(s/2)__bn__bn"
  scale_param {
    bias_term: true
  }
}
layer {
  name: "conv6_c1x1-a__conv"
  type: "Convolution"
  bottom: "conv5_sum-act__relu"
  top: "conv6_c1x1-a__conv"
  convolution_param {
    num_output: 32
    bias_term: false
    pad: 0
    kernel_size: 1
    group: 1
    stride: 1
  }
}
layer {
  name: "conv6_c1x1-a__bn__bn"
  type: "BatchNorm"
  bottom: "conv6_c1x1-a__conv"
  top: "conv6_c1x1-a__bn__bn"
  batch_norm_param {
    use_global_stats: true
    moving_average_fraction: 0.9
    eps: 0.001
  }
}
layer {
  name: "conv6_c1x1-a__bn__bn_scale"
  type: "Scale"
  bottom: "conv6_c1x1-a__bn__bn"
  top: "conv6_c1x1-a__bn__bn"
  scale_param {
    bias_term: true
  }
}
layer {
  name: "conv6_c1x1-a__bn__relu"
  type: "ReLU"
  bottom: "conv6_c1x1-a__bn__bn"
  top: "conv6_c1x1-a__bn__relu"
}
layer {
  name: "conv6_c3x3-b__conv"
  type: "Convolution"
  bottom: "conv6_c1x1-a__bn__relu"
  top: "conv6_c3x3-b__conv"
  convolution_param {
    num_output: 32
    bias_term: false
    pad: 1
    kernel_size: 3
    group: 1
    stride: 2
  }
}
layer {
  name: "conv6_c3x3-b__bn__bn"
  type: "BatchNorm"
  bottom: "conv6_c3x3-b__conv"
  top: "conv6_c3x3-b__bn__bn"
  batch_norm_param {
    use_global_stats: true
    moving_average_fraction: 0.9
    eps: 0.001
  }
}
layer {
  name: "conv6_c3x3-b__bn__bn_scale"
  type: "Scale"
  bottom: "conv6_c3x3-b__bn__bn"
  top: "conv6_c3x3-b__bn__bn"
  scale_param {
    bias_term: true
  }
}
layer {
  name: "conv6_c3x3-b__bn__relu"
  type: "ReLU"
  bottom: "conv6_c3x3-b__bn__bn"
  top: "conv6_c3x3-b__bn__relu"
}
layer {
  name: "conv6_c1x1-c__conv"
  type: "Convolution"
  bottom: "conv6_c3x3-b__bn__relu"
  top: "conv6_c1x1-c__conv"
  convolution_param {
    num_output: 32
    bias_term: false
    pad: 0
    kernel_size: 1
    group: 1
    stride: 1
  }
}
layer {
  name: "conv6_c1x1-c__bn__bn"
  type: "BatchNorm"
  bottom: "conv6_c1x1-c__conv"
  top: "conv6_c1x1-c__bn__bn"
  batch_norm_param {
    use_global_stats: true
    moving_average_fraction: 0.9
    eps: 0.001
  }
}
layer {
  name: "conv6_c1x1-c__bn__bn_scale"
  type: "Scale"
  bottom: "conv6_c1x1-c__bn__bn"
  top: "conv6_c1x1-c__bn__bn"
  scale_param {
    bias_term: true
  }
}
layer {
  name: "conv6_ele-sum"
  type: "Eltwise"
  bottom: "conv6_c1x1-w(s/2)__bn__bn"
  bottom: "conv6_c1x1-c__bn__bn"
  top: "conv6_ele-sum"
}
layer {
  name: "conv6_sum-act__relu"
  type: "ReLU"
  bottom: "conv6_ele-sum"
  top: "conv6_sum-act__relu"
}
layer {
  name: "pool5"
  type: "Pooling"
  bottom: "conv6_sum-act__relu"
  top: "pool5"
  pooling_param {
    pool: AVE
    kernel_size: 14
    stride: 1
    pad: 0
  }
}
layer {
  name: "fc"
  type: "InnerProduct"
  bottom: "flatten"
  top: "fc"
  inner_product_param {
    num_output: 1000
  }
}
F0308 09:31:04.433809 2737054528 insert_splits.cpp:29] Unknown bottom blob 'flatten' (layer 'fc', bottom index 0)
*** Check failure stack trace: ***
Abort trap: 6

Not sure why the blob "flatten" is not correctly recognized. Any idea?

Segmentation fault

when I use the command:
python mxnet2caffe.py --mx-model model --mx-epoch 31 --cf-prototxt model_caffe/res.prototxt --cf-model model_caffe/res.caffemodel
An error occurred:

Segmentation fault: 11

*** Error in `python': malloc(): memory corruption: 0x0000000063c45e50 ***

I need help.

error! key error mxnet: mobilenet0_batchnorm0_beta

error! key error mxnet: mobilenet0_batchnorm0_beta
error! key error mxnet: mobilenet0_batchnorm0_gamma
Warning! unknown mxnet: mobilenet0_batchnorm0_runing_mean
转化模型师,出现以上错误,怎么解决?

mxnet

Traceback (most recent call last):
File "json2prototxt.py", line 38, in
write_node(prototxt_file, info)
File "/root/MXNet2Caffe/prototxt_basic.py", line 143, in write_node
Convolution(txt_file, info)
File "/root/MXNet2Caffe/prototxt_basic.py", line 16, in Convolution
if info['param']['no_bias'] == 'True':
KeyError: 'param'

conversion error

I get an error in prototxt_basic.py
Convolution(txt_file, info)
if info['param']['no_bias'] == 'True':
KeyError: 'param'

feature map mismatch

I am tring to convert a mxnet model into a caffe model. The feature maps of 'conv1a' layer in mxnet and caffe are the same, but the feature maps of 'bn' layer in mxnet differs from the ones in caffe. The parameters 'moving_men', 'moving_var', 'gamma', 'beta' of mxnet model are suitable put into the caffe model.
And, when i tried to test the caffe model on ilsvrc2012 val, predicted classes of all images are 0. There must be some mistakes when i converted the model.
This bothers me for quite a while,can u give me some suggestions? thx a lot~

Licence

Can you please clarify the license requirements? Is it MIT, BSD or some other license?

incompatible number of blobs for layer bn0

hi,I am trying to convert a model trained by mxnet into caffemodel,however after i get the caffemodel file,and tring to test the model on caffe framework,the error occurs:check failed:target_blobs.size() == source_layer.blobs_size() (3 vs 5) incompatible number of blobs for layer bn0.how to solve it

Different inference output

Hi all,

This is my original question: https://github.com/deepinsight/insightface/issues/937

I also tried this repo to do the conversion. But the inference output is also problematic. The converted weights seems to be fine. And the first few hidden layer's output is almost the same as mxnet output. But the outputs afterwards becomes more and more different.

And ideas how to solve this problem?

Many thanks!

Time cosumming and GPU memory

After I transformed the mxnet model into caffe model using the provided codes, I found the time comsumming and GPU memory of caffe model was much larger than the mxnet model. Is that normal?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.