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

transfered model do not work normally on tensorflow 1.3

Open ricther opened this issue 7 years ago • 5 comments

I have transfered a model from caffe 0.16. the Net is ResNet18.

the example of imagenet can run smoothly. but the output is incorrect, the output is always a fixed class with confidence 1 no matter what image feeded.

I have changed the code according to #128

ricther avatar Nov 01 '17 13:11 ricther

I am facing the same problem. I am using tensorflow 1.2.1. I have opened an issue #144 . Were you able to resolve this?

shresthamalik avatar Nov 08 '17 18:11 shresthamalik

maybe you can check your python,is it python3.x?if the answer is yes,the code is normal to make some problem.Because the environment of the author's code is python2.7. Maybe you can review my code based on the author's code https://github.com/GZHermit/caffe2tensorflow_python3.git If I do something wrong,please tell me.

GZHermit avatar Nov 14 '17 03:11 GZHermit

Hi,

I am using Python version 2.7 and tensorflow 1.2

shresthamalik avatar Nov 14 '17 23:11 shresthamalik

Hi,

I tried your @GZHermit code. It gives me this error in batch normalisation layer. I got the same error when I used the original (caffe-tensorflow) code also and I fixed it as below: variance *= scaling_factor.reshape(1)

I had to make few other changes also mostly for the batch normalisation layer to get the code working for me, not sure if my changes are the issue. Also, is there a specific data preprocessing that needs to be done to use the converted model? I noticed that caffe takes input as channel x width x height , while tensorflow takes as width x height x channel? Any inputs would be helpful!


WARNING: PyCaffe not found!
Falling back to a pure protocol buffer implementation.
* Conversions will be drastically slower.
* This backend is UNTESTED!

Converting data... ('hehe:', <type 'list'>) ('hehe:', <type 'list'>) Warning: parmaters not reshaped for node: [BatchNorm] conv1_bn ('hehe:', <type 'list'>) ('hehe:', <type 'list'>) Warning: parmaters not reshaped for node: [BatchNorm] conv2_bn ('hehe:', <type 'list'>) ('hehe:', <type 'list'>) Warning: parmaters not reshaped for node: [BatchNorm] conv3_bn ('hehe:', <type 'list'>) ('hehe:', <type 'list'>) ('hehe:', <type 'list'>) ('hehe:', <type 'list'>) Traceback (most recent call last): File "convert.py", line 60, in main() File "convert.py", line 56, in main args.phase) File "convert.py", line 30, in convert data = transformer.transform_data() File "/home/admin/caffe-shr/caffe2tensorflow_python3/kaffe/tensorflow/transformer.py", line 275, in transform_data self.graph = self.graph.transformed(transformers) File "/home/admin/caffe-shr/caffe2tensorflow_python3/kaffe/graph.py", line 107, in transformed graph = transformer(graph) File "/home/admin/caffe-shr/caffe2tensorflow_python3/kaffe/transformers.py", line 244, in call variance *= scaling_factor ValueError: non-broadcastable output operand with shape (10,) doesn't match the broadcast shape (1,1,1,10)

shresthamalik avatar Nov 15 '17 20:11 shresthamalik

@shresthamalik Try to install a caffe instead of the pure protobuf implementation.

kitstar avatar Dec 07 '17 05:12 kitstar