Skip to content

Bug when run caffe2keras #43

Open
Open
@lelechen63

Description

@lelechen63

Hi Marc,
I run the caffe2keras function to convert resNext50, but I got the error message as error1, the x is a list instead of a keras tensor, actually it's a structure like [tensor], and if I change the keras backend code to fit this (I change the 492 as shape = x[0].get_shape()), it will get to error2, which still caused by the list type.

Best,
Lele

error1:
(keras_env) lele@istiophorus:~/visualdx_test/keras/keras/caffe$ python caffe2keras.py -load_path /home/lele/visualdx_test/code_resnext -prototxt 'template.prototxt' -caffemodel 'resnext50.caffemodel'
Using TensorFlow backend.
Converting model...
CREATING MODEL
Traceback (most recent call last):
File "caffe2keras.py", line 46, in
main(args)
File "caffe2keras.py", line 34, in main
model = convert.caffe_to_keras(args.load_path+'/'+args.prototxt, args.load_path+'/'+args.caffemodel, debug=args.debug)
File "/home/lele/visualdx_test/keras/keras/caffe/convert.py", line 53, in caffe_to_keras
debug)
File "/home/lele/visualdx_test/keras/keras/caffe/convert.py", line 369, in create_model
net_node[layer_nb] = BatchNormalization(epsilon=epsilon, axis=axis, name=name)(input_layers)
File "/home/lele/visualdx_test/keras/keras/engine/topology.py", line 596, in call
output = self.call(inputs, **kwargs)
File "/home/lele/visualdx_test/keras/keras/layers/normalization.py", line 212, in call
input_shape = K.int_shape(inputs)
File "/home/lele/visualdx_test/keras/keras/backend/tensorflow_backend.py", line 492, in int_shape
shape = x.get_shape()
AttributeError: 'list' object has no attribute 'get_shape'

error2:
(keras_env) lele@istiophorus:~/visualdx_test/keras/keras/caffe$ python caffe2keras.py -load_path /home/lele/visualdx_test/code_resnext -prototxt 'template.prototxt' -caffemodel 'resnext50.caffemodel'
Using TensorFlow backend.
Converting model...
CREATING MODEL
Traceback (most recent call last):
File "caffe2keras.py", line 46, in
main(args)
File "caffe2keras.py", line 34, in main
model = convert.caffe_to_keras(args.load_path+'/'+args.prototxt, args.load_path+'/'+args.caffemodel, debug=args.debug)
File "/home/lele/visualdx_test/keras/keras/caffe/convert.py", line 53, in caffe_to_keras
debug)
File "/home/lele/visualdx_test/keras/keras/caffe/convert.py", line 369, in create_model
net_node[layer_nb] = BatchNormalization(epsilon=epsilon, axis=axis, name=name)(input_layers)
File "/home/lele/visualdx_test/keras/keras/engine/topology.py", line 596, in call
output = self.call(inputs, **kwargs)
File "/home/lele/visualdx_test/keras/keras/layers/normalization.py", line 262, in call
epsilon=self.epsilon)
File "/home/lele/visualdx_test/keras/keras/backend/tensorflow_backend.py", line 1653, in normalize_batch_in_training
shift=None, name=None, keep_dims=False)
File "/home/lele/keras_env/local/lib/python2.7/site-packages/tensorflow/python/ops/nn_impl.py", line 634, in moments
y = math_ops.cast(x, dtypes.float32) if x.dtype == dtypes.float16 else x
AttributeError: 'list' object has no attribute 'dtype'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions