ethereon / caffe-tensorflow

Caffe models in TensorFlow
Other
2.8k stars 1.04k forks source link

Can it convert 3d model? And how? #125

Open qingwusunny opened 7 years ago

qingwusunny commented 7 years ago

I found the form of convolution in network.py is 2d. Can it convert a 3d model?

mgarbade commented 7 years ago

Same problem here. The convolutions of the underlying model are of the form

layer {
  name: "conv1_1"
  type: "Convolution"
  bottom: "data"
  top: "conv1_1"
  convolution_param {
    num_output: 16
    pad: 3
    pad: 3
    pad: 3
    kernel_size: 7
    kernel_size: 7
    kernel_size: 7
    stride: 2
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
    engine: CUDNN
    axis: 1
  }
}

which is a 3d convolution in caffe. The conversion using convert.py fails with this error message:

F0705 18:11:13.636178 13657 base_conv_layer.cpp:36] Check failed: num_kernel_dims == 1 || num_kernel_dims == num_spatial_axes_ kernel_size must be specified once, or once per spatial dimension (kernel_size specified 3 times; 2 spatial dims).
*** Check failure stack trace: ***
Aborted (core dumped)
qingwusunny commented 7 years ago

I found it can't convert 3d model. You can found it from Kaffe/tensorflow/network.py: def conv(self, input, k_h, k_w, c_o, s_h, s_w, name, relu=True, padding=DEFAULT_PADDING, group=1, biased=True): It's parameters of convolutional layer is 2d, which only have k_h,k_w.

mgarbade commented 7 years ago

Any idea how to fix this? I mean one could add a slightly modified version in Kaffe/tensorflow/network.py which does respect 3D convolutions using tf.nn.conv3d.

Question is where in the code the reading of the caffe.prototxt happens... which now should read 3D convolutions...