caffe-tensorflow icon indicating copy to clipboard operation
caffe-tensorflow copied to clipboard

TypeError: Input 'split_dim' of 'Split' Op has type float32 that does not match expected type of int32

Open murtazarang opened this issue 8 years ago • 2 comments

I am trying to convert a caffemodel to tensorflow and I am getting this error. Could anyone please help me out.

Traceback (most recent call last): File "convert.py", line 130, in main() File "convert.py", line 126, in main args.standalone_output_path, args.phase) File "convert.py", line 76, in convert net = KaffeNet({input_node: data_placeholder}) File "/home/tagomago/caffe-tensorflow/kaffe/tensorflow/network.py", line 47, in init self.setup() File "/home/tagomago/caffe-tensorflow/output21.py", line 9, in setup .conv(5, 5, 256, 1, 1, group=2, name='conv2') File "/home/tagomago/caffe-tensorflow/kaffe/tensorflow/network.py", line 21, in layer_decorated layer_output = op(self, layer_input, *args, **kwargs) File "/home/tagomago/caffe-tensorflow/kaffe/tensorflow/network.py", line 133, in conv input_groups = tf.split(3, group, input) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/array_ops.py", line 1265, in split split_dim=axis, num_split=num_or_size_splits, value=value, name=name) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 5094, in _split name=name) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 533, in _apply_op_helper (prefix, dtypes.as_dtype(input_arg.type).name)) TypeError: Input 'split_dim' of 'Split' Op has type float32 that does not match expected type of int32.

murtazarang avatar Nov 24 '17 05:11 murtazarang

I ran into this problem myself and resolved this by reading this post and following their advice - https://github.com/tensorflow/models/issues/933. Basically there are some tensorflow API changes (https://github.com/tensorflow/tensorflow/blob/master/RELEASE.md) and you might have to manually reverse the order of the arguments for "split" in network.py. It worked for me.

hainingren avatar Nov 30 '17 20:11 hainingren

To add to hainingren's answer, update the following lines in kaffe/tensorflow/network.py to reflect the changes in tensorflow:

                input_groups = tf.split(3, group, input)
                kernel_groups = tf.split(3, group, kernel)
                output_groups = [convolve(i, k) for i, k in zip(input_groups, kernel_groups)]
                # Concatenate the groups
                output = tf.concat(3, output_groups)

to

                input_groups = tf.split(input, group, 3)
                kernel_groups = tf.split(kernel, group, 3)
                output_groups = [convolve(i, k) for i, k in zip(input_groups, kernel_groups)]
                # Concatenate the groups
                output = tf.concat(output_groups, 3)

morrisfranken avatar Feb 14 '18 23:02 morrisfranken