CoreMLTools Keras simple Sequential Linear Regression model export error ('module' object has no attribute 'mobilenet')

678 views Asked by At

I've created a very simple Sequential Linear Regression model using Keras 2.0.4 (TensorFlow 1.1.0 backend) and my coremltools (0.6.3) export is failing with this error message:

--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) in () ----> 1 coreml_model = coremltools.converters.keras.convert(model, input_names="input", output_names="output") /Users/Jacopo/anaconda/envs/KerasTensorFlowCoreML/lib/python2.7/site-packages/coremltools/converters/keras/_keras_converter.pyc in convert(model, input_names, output_names, image_input_names, is_bgr, red_bias, green_bias, blue_bias, gray_bias, image_scale, class_labels, predicted_feature_name, predicted_probabilities_output) 489 predicted_probabilities_output = predicted_probabilities_output) 490 elif _HAS_KERAS2_TF: --> 491 from . import _keras2_converter 492 return _keras2_converter._convert(model = model, 493 input_names = input_names, /Users/Jacopo/anaconda/envs/KerasTensorFlowCoreML/lib/python2.7/site-packages/coremltools/converters/keras/_keras2_converter.py in () 66 _keras.layers.wrappers.TimeDistributed:_layers2.default_skip, 67 ---> 68 _keras.applications.mobilenet.DepthwiseConv2D:_layers2.convert_convolution, 69 70 } AttributeError: 'module' object has no attribute 'mobilenet'

I'm using Python 2.7 on macOS

As said this is a very simple Linear Regression and the module has no image input at all.

Any hint ?

Thanks, Jacopo

2

There are 2 answers

2
Sander de Ruiter On

Updating Keras to 2.0.6 worked for me...

0
mynameisvinn On

coremltools works when keras uses tensorflow, not theano, as its backend.

you can change keras' default backend at $HOME/.keras/keras.json, and changing to "backend": "tensorflow".