TensorFlow模型到TFlite转换错误

时间:2019-03-05 02:25:20

标签: python tensorflow keras tensorflow-lite

我正试图通过两个步骤将Keras模型(LSTM)转换为TFlite,以便在Android上进行部署。

  1. 要将Keras转换为.pb,我使用了此GitHub repo中的代码。
  2. 要将Pb转换为.lite,我正在使用tflite_converter。无论是在终端还是在python中,保存的模型和冻结的图均会失败。

我已经调整了代码,并将其与我的模型结合起来:

from sklearn.utils import class_weight
from sklearn.model_selection import train_test_split
from keras.models import Sequential
from keras.layers import Dense
from keras.layers import LSTM
from keras.layers import Dropout
from keras.layers import Flatten
from keras.utils import to_categorical
from keras.optimizers import Adam
from keras import backend as K
from tensorflow.python.framework.graph_util import convert_variables_to_constants
import tensorflow as tf
from tensorflow.python.tools import freeze_graph
from tensorflow.python.tools import optimize_for_inference_lib
import os
import os.path as path

MODEL_NAME = 'pronation_classifier'


def evaluate_model(X_train, labels_train_cat, X_test, labels_test_cat):
    verbose, epochs, batch_size = 1, 50, 64
    n_timesteps, n_features, n_outputs = X_train.shape[1], X_train.shape[2], labels_train_cat.shape[1]

    model = Sequential()
    model.add(LSTM(100, return_sequences=True, input_shape=(n_timesteps,n_features)))
    model.add(LSTM(100, return_sequences=True))
    model.add(LSTM(100))
    model.add(Dropout(0.5))
    model.add(Dense(100, activation='relu'))

    model.add(Dense(n_outputs, activation='softmax'))
    model.compile(Adam(lr=1e-2), loss='categorical_crossentropy', metrics=['accuracy', ])
    model.fit(X_train, labels_train_cat, epochs=epochs, batch_size=batch_size, verbose=verbose, class_weight=class_weights)

    return model

def export_model(saver, model, input_node_names, output_node_name):
    tf.train.write_graph(K.get_session().graph_def, 'out', \
        MODEL_NAME + '_graph.pbtxt')

    saver.save(K.get_session(), 'out/' + MODEL_NAME + '.chkp')

    freeze_graph.freeze_graph('out/' + MODEL_NAME + '_graph.pbtxt', None, \
    False, 'out/' + MODEL_NAME + '.chkp', output_node_name, \
    "save/restore_all", "save/Const:0", \
    'out/frozen_' + MODEL_NAME + '.pb', True, "")

    input_graph_def = tf.GraphDef()
    with tf.gfile.Open('out/frozen_' + MODEL_NAME + '.pb', "rb") as f:
        input_graph_def.ParseFromString(f.read())

    output_graph_def = optimize_for_inference_lib.optimize_for_inference(
        input_graph_def, input_node_names, [output_node_name],
        tf.float32.as_datatype_enum)

    with tf.gfile.FastGFile('out/opt_' + MODEL_NAME + '.pb', "wb") as f:
    f.write(output_graph_def.SerializeToString())

    print("graph saved!")

X_train, X_test, labels_train, labels_test = train_test_split(steps_stack, steps_labels, test_size = 0.2)
labels_train_cat = to_categorical(labels_train)
labels_test_cat = to_categorical(labels_test)
class_weights = class_weight.compute_class_weight('balanced', np.unique(labels_train), labels_train)


model, summary = evaluate_model(X_train, labels_train_cat, X_test, labels_test_cat)
input_node = [node.op.name for node in model.inputs]
output_node = [node.op.name for node in model.outputs]  
session = K.get_session()
min_graph = convert_variables_to_constants(session, session.graph_def, [node.op.name for node in model.outputs])
tf.train.write_graph(min_graph, "~/out/", "file.pb", as_text=True)
export_model(tf.train.Saver(), model, [input_node], output_node)

以上所有作品(或似乎)。

错误: 使用 GraphDef 中的 tfile_converter

tflite_convert \
>   --graph_def_file=/Users/mila/pronation_classification/out/frozen_pronation_classification.pb \
>   --output_file=/Users/mila/pronation_classification/checkpoint/pronation_classification.lite \
>   --input_format=TENSORFLOW_GRAPHDEF \
>   --output_format=TFLITE \
>   --input_shape=0,30,9 \
>   --input_array=lstm_10_input \
>   --output_array=dense_8/Softmax \
>   --inference_type=FLOAT \
>   --input_data_type=FLOAT
/Users/mila/anaconda3/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
2019-03-05 01:16:57.698443: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
Traceback (most recent call last):
  File "/Users/mila/anaconda3/bin/tflite_convert", line 11, in <module>
    sys.exit(main())
  File "/Users/mila/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/lite/python/tflite_convert.py", line 412, in main
    app.run(main=run_main, argv=sys.argv[:1])
  File "/Users/mila/anaconda3/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 125, in run
    _sys.exit(main(argv))
  File "/Users/mila/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/lite/python/tflite_convert.py", line 408, in run_main
    _convert_model(tflite_flags)
  File "/Users/mila/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/lite/python/tflite_convert.py", line 162, in _convert_model
    output_data = converter.convert()
  File "/Users/mila/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/lite/python/lite.py", line 453, in convert
    **converter_kwargs)
  File "/Users/mila/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/lite/python/convert.py", line 342, in toco_convert_impl
    input_data.SerializeToString())
  File "/Users/mila/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/lite/python/convert.py", line 135, in toco_convert_protos
    (stdout, stderr))
RuntimeError: TOCO failed see console for info.
b'2019-03-05 01:17:10.366148: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: TensorArrayV3\n2019-03-05 01:17:10.366662: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1127] Op node missing output type attribute: lstm_10/TensorArray\n2019-03-05 01:17:10.366703: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: TensorArrayV3\n2019-03-05 01:17:10.366732: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1127] Op node missing output type attribute: lstm_10/TensorArray_1\n2019-03-05 01:17:10.366831: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: TensorArrayScatterV3\n2019-03-05 01:17:10.366852: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1127] Op node missing output type attribute: lstm_10/TensorArrayUnstack/TensorArrayScatter/TensorArrayScatterV3\n2019-03-05 01:17:10.366886: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.366914: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.366936: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.366956: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.366975: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.367025: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.367052: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.367083: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: LoopCond\n2019-03-05 01:17:10.367095: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1127] Op node missing output type attribute: lstm_10/while/LoopCond\n2019-03-05 01:17:10.367172: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.367189: I tensorflow/contrib/lite/toco/import_tensorflow.cc:189] Unsupported data type in placeholder op: 20\n2019-03-05 01:17:10.367204: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.367225: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: TensorArrayReadV3\n2019-03-05 01:17:10.367250: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.367285: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.367315: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.367345: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.367373: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.367402: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.367428: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.367453: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.367481: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.367558: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.367637: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.367682: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.367795: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.367817: I tensorflow/contrib/lite/toco/import_tensorflow.cc:189] Unsupported data type in placeholder op: 20\n2019-03-05 01:17:10.367840: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: TensorArrayWriteV3\n2019-03-05 01:17:10.367856: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1127] Op node missing output type attribute: lstm_10/while/TensorArrayWrite/TensorArrayWriteV3\n2019-03-05 01:17:10.367897: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Exit\n2019-03-05 01:17:10.367913: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: TensorArraySizeV3\n2019-03-05 01:17:10.367925: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1127] Op node missing output type attribute: lstm_10/TensorArrayStack/TensorArraySizeV3\n2019-03-05 01:17:10.367963: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: TensorArrayGatherV3\n2019-03-05 01:17:10.368468: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: TensorArrayV3\n2019-03-05 01:17:10.368488: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1127] Op node missing output type attribute: lstm_11/TensorArray\n2019-03-05 01:17:10.368506: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: TensorArrayV3\n2019-03-05 01:17:10.368521: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1127] Op node missing output type attribute: lstm_11/TensorArray_1\n2019-03-05 01:17:10.368587: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: TensorArrayScatterV3\n2019-03-05 01:17:10.368601: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1127] Op node missing output type attribute: lstm_11/TensorArrayUnstack/TensorArrayScatter/TensorArrayScatterV3\n2019-03-05 01:17:10.368629: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.368648: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.368665: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.368682: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.368698: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.368735: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.368758: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.368780: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: LoopCond\n2019-03-05 01:17:10.368790: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1127] Op node missing output type attribute: lstm_11/while/LoopCond\n2019-03-05 01:17:10.368854: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.368867: I tensorflow/contrib/lite/toco/import_tensorflow.cc:189] Unsupported data type in placeholder op: 20\n2019-03-05 01:17:10.368880: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.368899: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: TensorArrayReadV3\n2019-03-05 01:17:10.368916: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.368941: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.368965: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.368989: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.369013: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.369035: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.369058: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.369080: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.369101: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.369165: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.369231: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.369269: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.369336: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.369350: I tensorflow/contrib/lite/toco/import_tensorflow.cc:189] Unsupported data type in placeholder op: 20\n2019-03-05 01:17:10.369367: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: TensorArrayWriteV3\n2019-03-05 01:17:10.369380: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1127] Op node missing output type attribute: lstm_11/while/TensorArrayWrite/TensorArrayWriteV3\n2019-03-05 01:17:10.369420: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Exit\n2019-03-05 01:17:10.369435: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: TensorArraySizeV3\n2019-03-05 01:17:10.369446: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1127] Op node missing output type attribute: lstm_11/TensorArrayStack/TensorArraySizeV3\n2019-03-05 01:17:10.369485: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: TensorArrayGatherV3\n2019-03-05 01:17:10.369961: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: TensorArrayV3\n2019-03-05 01:17:10.369980: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1127] Op node missing output type attribute: lstm_12/TensorArray\n2019-03-05 01:17:10.369998: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: TensorArrayV3\n2019-03-05 01:17:10.370012: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1127] Op node missing output type attribute: lstm_12/TensorArray_1\n2019-03-05 01:17:10.370085: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: TensorArrayScatterV3\n2019-03-05 01:17:10.370100: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1127] Op node missing output type attribute: lstm_12/TensorArrayUnstack/TensorArrayScatter/TensorArrayScatterV3\n2019-03-05 01:17:10.370128: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.370149: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.370166: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.370182: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.370199: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.370236: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.370258: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.370281: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: LoopCond\n2019-03-05 01:17:10.370291: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1127] Op node missing output type attribute: lstm_12/while/LoopCond\n2019-03-05 01:17:10.370353: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.370366: I tensorflow/contrib/lite/toco/import_tensorflow.cc:189] Unsupported data type in placeholder op: 20\n2019-03-05 01:17:10.370380: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.370398: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: TensorArrayReadV3\n2019-03-05 01:17:10.370415: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.370439: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.370463: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.370487: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.370510: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.370532: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.370555: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.370576: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.370598: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.370660: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.370725: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.370763: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.370830: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: Enter\n2019-03-05 01:17:10.370843: I tensorflow/contrib/lite/toco/import_tensorflow.cc:189] Unsupported data type in placeholder op: 20\n2019-03-05 01:17:10.370859: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported operation: TensorArrayWriteV3\n2019-03-05 01:17:10.370872: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1127] Op node missing output type attribute: lstm_12/while/TensorArrayWrite/TensorArrayWriteV3\n2019-03-05 01:17:10.370910: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1080] Converting unsupported tensorflow --version03-05 01:17:10.370

其要点是重复“转换不支持的操作”和“缺少操作节点”,但我不知道如何解决。

使用 saved_model 中的 tflite_convert

    tflite_convert --output_file=convModel.tflite --saved_model_dir /Users/mila/Bioengineering_Year_4/MHML/pronation_classification/checkpoint

The code above leaves me with:

   /Users/mila/anaconda3/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
2019-03-05 02:05:00.668165: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
Traceback (most recent call last):utput_array=dense_8/Softmax   --inference_type=FLOAT   --input_data_type=FLOAT-output_format=TFLITE   --input_shape=0,30,9   
  File "/Users/mila/anaconda3/bin/tflite_convert", line 11, in <module>
    sys.exit(main())
  File "/Users/mila/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/lite/python/tflite_convert.py", line 412, in main
    app.run(main=run_main, argv=sys.argv[:1])
  File "/Users/mila/anaconda3/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 125, in run
    _sys.exit(main(argv))
  File "/Users/mila/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/lite/python/tflite_convert.py", line 408, in run_main
    _convert_model(tflite_flags)
  File "/Users/mila/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/lite/python/tflite_convert.py", line 100, in _convert_model
    converter = _get_toco_converter(flags)
  File "/Users/mila/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/lite/python/tflite_convert.py", line 87, in _get_toco_converter
    return converter_fn(**converter_kwargs)
  File "/Users/mila/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/lite/python/lite.py", line 340, in from_saved_model
    output_arrays, tag_set, signature_key)
  File "/Users/mila/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/lite/python/convert_saved_model.py", line 239, in freeze_saved_model
    meta_graph = get_meta_graph_def(saved_model_dir, tag_set)
  File "/Users/mila/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/lite/python/convert_saved_model.py", line 61, in get_meta_graph_def
    return loader.load(sess, tag_set, saved_model_dir)
  File "/Users/mila/anaconda3/lib/python3.6/site-packages/tensorflow/python/saved_model/loader_impl.py", line 197, in load
    return loader.load(sess, tags, import_scope, **saver_kwargs)
  File "/Users/mila/anaconda3/lib/python3.6/site-packages/tensorflow/python/saved_model/loader_impl.py", line 350, in load
    **saver_kwargs)
  File "/Users/mila/anaconda3/lib/python3.6/site-packages/tensorflow/python/saved_model/loader_impl.py", line 275, in load_graph
    meta_graph_def = self.get_meta_graph_def_from_tags(tags)
  File "/Users/mila/anaconda3/lib/python3.6/site-packages/tensorflow/python/saved_model/loader_impl.py", line 251, in get_meta_graph_def_from_tags
    " could not be found in SavedModel. To inspect available tag-sets in"
RuntimeError: MetaGraphDef associated with tags {'serve'} could not be found in SavedModel. To inspect available tag-sets in the SavedModel, please use the SavedModel CLI: `saved_model_cli`

再次,我已经调查了此错误,但无法修复。

我尝试了其他将keras转换为.pb的方法,以查看是否可能是导致错误的原因,但它们在步骤2中也失败了。我还尝试了将其从会话的GraphDef以及tfile_converter进行转换。使用python(而不是控制台)-长话短说,这也不起作用。

我知道thisthis帖子(以及许多其他令人遗憾的未答复帖子),但它们与我的错误有所不同。

谢谢!非常感谢您的帮助!

0 个答案:

没有答案