2017-06-15 8 views

答えて

3

ケラを通してモデルをトレーニングすることができます。

coreml_model = coremltools.converters.keras.convert('./Any.h5', 
               input_names='image', 
               image_input_names='image', 
               output_names='output', 
               class_labels=['1', '2'], 
               image_scale=1/255) 
coreml_model.save('abc.mlmodel') 

.h5を容易にすることによって作成することができる「シーケンシャル」

0

不可能です。主に、モデルを保存する際にすべてのNNフレームワークが遵守すべきフォーマットがないためです。

だから、おそらくあなたがあなた自身を記述する必要があると思います(現在、少なくとも用)のドキュメントによると

1

はい、あなたのマシン学習モデルが次のフォーマットのいずれかである場合、 Caffe、Keras、XGBoost、Scikit-learn、MXNet、LibSVMのいずれかになります。 それぞれのチュートリアルと例がAwesome Core MLにあります。

Tensorflowからの直接変換はまだサポートされていませんが、TFでCaffeアーキテクチャを使用して機能させることができます。

0

KerasがハイレベルニューラルネットワークのAPI、Pythonで書かれており、TensorFlow、CNTK、又はTheanoの上で動作することが可能です。

現在、coremltools 0.7Keras (1.2.2, 2.0.4+) with Tensorflow (1.0.x, 1.1.x)

# Make a Keras model 
>>> model = Sequential() 
>>> model.add(Dense(num_channels, input_dim = input_dim)) 

# Convert it with default input and output names 
>>> import coremltools 
>>> coreml_model = coremltools.converters.keras.convert(model) 

# Saving the Core ML model to a file. 
>>> coreml_model.save('my_model.mlmodel') 

のモデルに変換することができますあなたは私のプロジェクトを見てみることができますhere

3

​​

あなたがしてCoreMLにある共通Tensorflowモデルを変換することができます

​​パッケージ。この執筆時点ではまだかなり新しい(1月16日)。これはAppleのエンジニアによって作られたようです。その例に基づいて

概要

、最初CoreMLオブジェクトを生成するtfcoreml.convertメソッドを使用し、その後、tensorflow.python.tools.freeze_graphを使用してTFモデルを凍結。

one of their examples

""" 
Step 1: "Freeze" your tensorflow model - convert your TF model into a 
stand-alone graph definition file 
Inputs: 
(1) TensorFlow code 
(2) trained weights in a checkpoint file 
(3) The output tensors' name you want to use in inference 
(4) [Optional] Input tensors' name to TF model 
Outputs: 
(1) A frozen TensorFlow GraphDef, with trained weights frozen into it 
""" 

# Provide these to run freeze_graph: 
# Graph definition file, stored as protobuf TEXT 
graph_def_file = './model.pbtxt' 
# Trained model's checkpoint name 
checkpoint_file = './checkpoints/model.ckpt' 
# Frozen model's output name 
frozen_model_file = './frozen_model.pb' 
# Output nodes. If there're multiple output ops, use comma separated string, e.g. "out1,out2". 
output_node_names = 'Softmax' 


# Call freeze graph 
freeze_graph(input_graph=graph_def_file, 
      input_saver="", 
      input_binary=False, 
      input_checkpoint=checkpoint_file, 
      output_node_names=output_node_names, 
      restore_op_name="save/restore_all", 
      filename_tensor_name="save/Const:0", 
      output_graph=frozen_model_file, 
      clear_devices=True, 
      initializer_nodes="") 

""" 
Step 2: Call converter 
""" 

# Provide these inputs in addition to inputs in Step 1 
# A dictionary of input tensors' name and shape (with batch) 
input_tensor_shapes = {"Placeholder:0":[1,784]} # batch size is 1 
# Output CoreML model path 
coreml_model_file = './model.mlmodel' 
output_tensor_names = ['Softmax:0'] 


# Call the converter 
coreml_model = tfcoreml.convert(
     tf_model_path=frozen_model_file, 
     mlmodel_path=coreml_model_file, 
     input_name_shape_dict=input_tensor_shapes, 
     output_feature_names=output_tensor_names) 
+1

を引用すると、このリンクは質問に答えるかもしれないが、ここでは答えの重要な部分が含まれており、参考のためにリンクを提供することをお勧めします。リンクされたページが変更された場合、リンクのみの回答は無効になります。 - [レビューから](/レビュー/低品質の投稿/ 18535009) – MarqueIV

関連する問題