用keras做了一个CNN MNIST, 想把已经保存的模组转成Core ML. 运行转换程序时报错了.

转换的程序:
import coremltools

output_labels = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
scale = 1/255.
coreml_model = coremltools.converters.keras.convert('MNIST.h5',
                                                   input_names='image',
                                                   image_input_names='image',
                                                   output_names='output',
                                                   class_labels=output_labels,
                                                   image_scale=scale)

coreml_model.author = 'Jiayu Li'
coreml_model.license = 'MIT'
coreml_model.short_description = 'Model to classify hand written digit'

coreml_model.input_description['image'] = 'Grayscale image of hand written digit'
coreml_model.output_description['output'] = 'Predicted digit'

coreml_model.save('MNIST.mlmodel')
报的错:
/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/bin/python2.7 /Users/jiayuli/work/STEM_project_2018/convert.py
2018-01-21 17:13:07.107815: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2018-01-21 17:13:07.107831: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2018-01-21 17:13:07.107836: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2018-01-21 17:13:07.107842: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
/usr/local/lib/python2.7/site-packages/keras/models.py:281: UserWarning: Error in loading the saved optimizer state. As a result, your model is starting with a freshly initialized optimizer.
  warnings.warn('Error in loading the saved optimizer '
0 : conv2d_1_input, <keras.engine.topology.InputLayer object at 0x103de52d0>
1 : conv2d_1, <keras.layers.convolutional.Conv2D object at 0x103de5110>
2 : conv2d_1__activation__, <keras.layers.core.Activation object at 0x112400e50>
3 : conv2d_2, <keras.layers.convolutional.Conv2D object at 0x110dd7190>
4 : conv2d_2__activation__, <keras.layers.core.Activation object at 0x1124298d0>
5 : max_pooling2d_1, <keras.layers.pooling.MaxPooling2D object at 0x110dd7c90>
6 : flatten_1, <keras.layers.core.Flatten object at 0x110e16710>
7 : dense_1, <keras.layers.core.Dense object at 0x110e2e910>
8 : dense_1__activation__, <keras.layers.core.Activation object at 0x11245fdd0>
9 : dense_2, <keras.layers.core.Dense object at 0x110ec4bd0>
10 : dense_2__activation__, <keras.layers.core.Activation object at 0x11247ca10>
Fatal Python error: PyThreadState_Get: no current thread

Process finished with exit code 134 (interrupted by signal 6: SIGABRT)
keras MNIST CNN: https://github.com/jiayulinfs/mnist-keras

要回复问题请先登录注册