Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/364.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python jupyter笔记本中keras模型到tflite模型的转换_Python_Tensorflow_Keras_Jupyter Notebook_Tensorflow Lite - Fatal编程技术网

Python jupyter笔记本中keras模型到tflite模型的转换

Python jupyter笔记本中keras模型到tflite模型的转换,python,tensorflow,keras,jupyter-notebook,tensorflow-lite,Python,Tensorflow,Keras,Jupyter Notebook,Tensorflow Lite,我用以下代码行保存了一个keras模型 keras.save("saved_model.h5") 当我尝试使用以下代码优化并转换为.tflite模型时 converter=tt.lite.TFLiteConverter.from_keras_model_file("saved_model.h5") converter.optimizations = [tf.lite.Optimize.DEFAULT] tflite_model = converter.convert() 我得到这个错误 在

我用以下代码行保存了一个keras模型

keras.save("saved_model.h5")
当我尝试使用以下代码优化并转换为.tflite模型时

converter=tt.lite.TFLiteConverter.from_keras_model_file("saved_model.h5")
converter.optimizations = [tf.lite.Optimize.DEFAULT]
tflite_model = converter.convert()
我得到这个错误


在toco_convert_impl(输入数据、输入张量、输出张量、*args、, **kwargs) 402 data=toco\u convert\u protos(model\u flags.SerializeToString(), 403 toco_标志。SerializeToString(), -->404输入\ u数据。SerializeToString() 405返回数据 406

~/.local/lib/python3.6/site-packages/tensorflow/lite/python/convert.py
在toco_convert_protos中(model_flags_str、toco_flags_str、, 输入(数据) 170 stderr=\u try\u convert\u到\u unicode(stderr) 171升起转换器错误( -->172“TOCO失败。有关信息,请参阅控制台。\n%s\n%s\n”%(标准输出,标准输出)) 173.最后: 174#必须手动清理文件

ConverterError: TOCO failed. See console for info.
/home/scripter/.local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:516:
未来警告:将(type,1)或“1type”作为type的同义词传递是错误的 不赞成;在numpy的未来版本中,它将被理解为 (类型,(1,)/“(1,)类型”。 _np_qint8=np.dtype([(“qint8”,np.int8,1)]) /home/scripter/.local/lib/python3.6/site packages/tensorflow/python/framework/dtypes.py:517: 未来警告:将(type,1)或“1type”作为type的同义词传递是错误的 不赞成;在numpy的未来版本中,它将被理解为 (类型,(1,)/“(1,)类型”。 _np_quint8=np.dtype([(“quint8”,np.uint8,1)]) /home/scripter/.local/lib/python3.6/site packages/tensorflow/python/framework/dtypes.py:518: 未来警告:将(type,1)或“1type”作为type的同义词传递是错误的 不赞成;在numpy的未来版本中,它将被理解为 (类型,(1,)/“(1,)类型”。 _np_qint16=np.dtype([(“qint16”,np.int16,1)]) /home/scripter/.local/lib/python3.6/site packages/tensorflow/python/framework/dtypes.py:519: 未来警告:将(type,1)或“1type”作为type的同义词传递是错误的 不赞成;在numpy的未来版本中,它将被理解为 (类型,(1,)/“(1,)类型”。 _np_quint16=np.dtype([(“quint16”,np.uint16,1)]) /home/scripter/.local/lib/python3.6/site packages/tensorflow/python/framework/dtypes.py:520: 未来警告:将(type,1)或“1type”作为type的同义词传递是错误的 不赞成;在numpy的未来版本中,它将被理解为 (类型,(1,)/“(1,)类型”。 _np_qint32=np.dtype([(“qint32”,np.int32,1)]) /home/scripter/.local/lib/python3.6/site packages/tensorflow/python/framework/dtypes.py:525: 未来警告:将(type,1)或“1type”作为type的同义词传递是错误的 不赞成;在numpy的未来版本中,它将被理解为 (类型,(1,)/“(1,)类型”。 np_resource=np.dtype([(“resource”,np.ubyte,1)]) /home/scripter/.local/lib/python3.6/site packages/tensorboard/compat/tensorflow_stub/dtypes.py:541: 未来警告:将(type,1)或“1type”作为type的同义词传递是错误的 不赞成;在numpy的未来版本中,它将被理解为 (类型,(1,)/“(1,)类型”。 _np_qint8=np.dtype([(“qint8”,np.int8,1)]) /home/scripter/.local/lib/python3.6/site packages/tensorboard/compat/tensorflow_stub/dtypes.py:542: 未来警告:将(type,1)或“1type”作为type的同义词传递是错误的 不赞成;在numpy的未来版本中,它将被理解为 (类型,(1,)/“(1,)类型”。 _np_quint8=np.dtype([(“quint8”,np.uint8,1)]) /home/scripter/.local/lib/python3.6/site packages/tensorboard/compat/tensorflow_stub/dtypes.py:543: 未来警告:将(type,1)或“1type”作为type的同义词传递是错误的 不赞成;在numpy的未来版本中,它将被理解为 (类型,(1,)/“(1,)类型”。 _np_qint16=np.dtype([(“qint16”,np.int16,1)]) /home/scripter/.local/lib/python3.6/site packages/tensorboard/compat/tensorflow_stub/dtypes.py:544: 未来警告:将(type,1)或“1type”作为type的同义词传递是错误的 不赞成;在numpy的未来版本中,它将被理解为 (类型,(1,)/“(1,)类型”。 _np_quint16=np.dtype([(“quint16”,np.uint16,1)]) /home/scripter/.local/lib/python3.6/site packages/tensorboard/compat/tensorflow_stub/dtypes.py:545: 未来警告:将(type,1)或“1type”作为type的同义词传递是错误的 不赞成;在numpy的未来版本中,它将被理解为 (类型,(1,)/“(1,)类型”。 _np_qint32=np.dtype([(“qint32”,np.int32,1)]) /home/scripter/.local/lib/python3.6/site packages/tensorboard/compat/tensorflow_stub/dtypes.py:550: 未来警告:将(type,1)或“1type”作为type的同义词传递是错误的 不赞成;在numpy的未来版本中,它将被理解为 (类型,(1,)/“(1,)类型”。 np_resource=np.dtype([(“resource”,np.ubyte,1)]) 回溯(最近一次呼叫最后一次): 文件“/home/scripter/.anaconda3/bin/toco_from_protos”,第7行,在 来自tensorflow.contrib.lite.toco.python.toco_from_protos import main ModuleNotFoundError:没有名为“tensorflow.contrib.lite”的模块


我使用的是tensorflow版本1.14.0。我可能做错了什么

您应该上传带有文本的异常,而不是使用屏幕截图。但是这个问题可能会对你有所帮助:谢谢@Guillem的帮助。我将对此进行编辑
~/.local/lib/python3.6/site-packages/tensorflow/lite/python/convert.py
ConverterError: TOCO failed. See console for info.
/home/scripter/.local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:516: