2016-11-15 5 views
1

GPU 시스템에서 TensorFLow 모델을 교육 받았습니다. 다음으로, 그것을 내 보내서 CPU 전용 생산 시스템에 전개해야합니다.TensorFlow에서 내 보낸 모델로드

MNIST export example에 설명 된대로 내보내기를 사용했습니다. Saver 객체가 위에 초기화되었습니다. 어떻게 할 수

Traceback (most recent call last): 
File "script_test_classifier.py", line 4, in <module> 
... 
line 33, in __initialize_session__ 
new_saver = tf.train.import_meta_graph('assets/saved_model/export.meta') 
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 1711, in import_meta_graph 
read_meta_graph_file(meta_graph_or_file), clear_devices) 
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 1598, in _import_meta_graph_def 
input_graph_def, name="", producer_op_list=producer_op_list) 
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/importer.py", line 258, in import_graph_def 
op_def = op_dict[node.op] 
KeyError: u'SaveV2' 

오류의 원인은 무엇이며 :

with graph.as_default(): 
    saver = tf.train.Saver(tf.all_variables(), sharded=True) 

... 


export_path = 'resnet34_rmsprop_wd1e-1/saves/' 
print('Exporting trained model to %s' % export_path) 
init_op = tf.group(tf.initialize_all_tables(), name='init_op') 
model_exporter = exporter.Exporter(saver) 
model_exporter.init(sess.graph.as_graph_def(), 
          init_op=init_op, 
          default_graph_signature=exporter.classification_signature(input_tensor=inference_images, 
                         classes_tensor=inference_class, 
                         scores_tensor=inference_predictions), 
          named_graph_signatures={'inputs': exporter.generic_signature({'images': inference_images}), 
                'outputs': exporter.generic_signature({'class': inference_class, 'predictions': inference_predictions})}) 
model_exporter.export(export_path, tf.constant(1), sess) 
print('Done exporting!') 

다음, 나는 함께 저장 모델을로드하려고 :

new_saver = tf.train.import_meta_graph('assets/saved_model/export.meta') 
new_saver.restore(sess, 'assets/saved_model/export') 

그리고 내가 무엇을 얻고 것은 고정 되니?

또한 TensorFlow 모델을 Python으로 가져 오는 다른 방법이 있습니까? https://tensorflow.github.io/serving/serving_basic

이 오류는 'SaveV2'이 등록 된 작전에서 발견되지 말한다 :

답변

0

이 TensorFlow 내 보낸 모델을로드하는 역할을 사용하는 것이 바람직하다. 따라서 TensorFlow를 최신 버전으로 업그레이드 할 수 있습니다.

+0

TF를 최신 버전으로 업데이트하려고했습니다. 도움이되지 않았고, 여전히 "KeyError : u'SaveV2" –