Closed trohit920 closed 6 years ago
Hi! Keras has significant API difference within minor version changes, could you try Keras 2.1.2?
Keras 2.1.2 works for your given models but not for my own model as it requires keras 2.1.3. I am getting an error :
'passed to optimizer: ' + str(k))
TypeError: Unexpected keyword argument passed to optimizer: amsgrad
Is there any work around here ? Or do i need to define my models again?
Thanks for your reply. After training model again with current Keras installation i can successfully convert to Caffe Model. Closing this now. Thanks.
@trohit920 Hi ! Did you convert MobileNet-keras to caffemodel ? I met the same problem with you : AttributeError: 'Dense' object has no attribute 'inbound_nodes' with Keras2.1.3 and TypeError: Unexpected keyword argument passed to optimizer: amsgrad with keras2.1.2 . How did you solve the problem? Thanks!
@FlYWMe I downgraded to Keras 2.1.2 version and everything works fine.
@trohit920 Thanks for reply! What did u do with "TypeError: Unexpected keyword argument passed to optimizer: amsgrad"? Did u mean retraining mobilenet with keras2.1.2 ? If so,how to import 'DepthwiseConv2D' ?
@FlYWMe No need for retraining again. If you run the script convert_mobilenet.py given here, your keras model will be changed to equivalent caffe model. DepthwiseConv2D is already defined in converter.py in keras2caffe.
@trohit920 Ok, so how to solve the Unexpected keyword amsgrad ?
@FlYWMe If you have your own Keras model than this error is removed once you finished training it again with Keras2.1.2 version and you can define your own converter python script accordingly. Otherwise this script should work fine for default MobileNet. I had my own Keras model and i successfully converted it to Caffe using this converter. I am not sure what is causing problem at your end.
@FlYWMe AMSgrad has been added to Keras 2.1.3, it's not available in Keras 2.1.2. You could use another optimizer, or create the stub implementation of amsgrad in Keras 2.1.2 (I don't know is it possible). I will try to migrate to newer version of Keras next week.
@uhfband @trohit920 Thanks !
Hello @uhfband , Thanks for your work, really appreciated it. I trained my own CNN in Keras for a classification application and have weights and model saved accordingly. However when i tried to convert .h5 model to file to caffe model i am facing an error. My conversion script is similar to given scripts. Error looks like this:
I am using Caffe : 1, Tensorflow : 1.9 and Keras : 2.1.3. Please take a look. Do you think it is because of different version of Tensorflow and Keras?