Python 无法将tf模型转换为tflite模型
我尝试了很多方法,但我无法将保存的模型文件转换为tf lite模型,每次运行新代码时都会出现不同的错误。从形状错误到下面列出的错误Python 无法将tf模型转换为tflite模型,python,tensorflow,keras,model,google-colaboratory,Python,Tensorflow,Keras,Model,Google Colaboratory,我尝试了很多方法,但我无法将保存的模型文件转换为tf lite模型,每次运行新代码时都会出现不同的错误。从形状错误到下面列出的错误 File "C:\\models\py\lib\site-packages\tensorflow\python\eager\monitoring.py", line 407, in __del__ AttributeError: 'NoneType' object has no attribute 'TFE_MonitoringDeleteBu
File "C:\\models\py\lib\site-packages\tensorflow\python\eager\monitoring.py", line 407, in __del__
AttributeError: 'NoneType' object has no attribute 'TFE_MonitoringDeleteBuckets'
我正在使用以下代码:
将tensorflow导入为tf
#转换模型
converter=tf.lite.TFLiteConverter.from_saved_model('new_graph/saved_model')#指向SavedModel目录的路径
tflite_model=converter.convert()
#保存模型。
将open('facemask_model.tflite','wb')作为f:
write(tflite\u model)
您的模型似乎包含的不仅仅是内置的tflite操作。你能试着使用SELECT_TF_OPS吗
我最近也遇到了同样的问题,这似乎是最近tf夜间版本中的一个bug。例如,您可以按如下方式复制错误
Python 3.7.9 (default, Aug 31 2020, 12:42:55)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
2020-10-21 13:48:47.162423: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
>>>
>>> exit()
Exception ignored in: <function Buckets.__del__ at 0x7f8b017e2830>
Traceback (most recent call last):
File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/tensorflow/python/eager/monitoring.py", line 407, in __del__
AttributeError: 'NoneType' object has no attribute 'TFE_MonitoringDeleteBuckets'
Python 3.7.9(默认,2020年8月31日,12:42:55)
[GCC 7.3.0]::linux上的Anaconda公司
有关详细信息,请键入“帮助”、“版权”、“信用证”或“许可证”。
>>>导入tensorflow作为tf
2020-10-21 13:48:47.162423:I tensorflow/stream_executor/platform/default/dso_loader.cc:49]成功打开动态库libcudart.so.11.0
>>>
>>>退出()
在中忽略异常:
回溯(最近一次呼叫最后一次):
文件“/home/ubuntu/anaconda3/lib/python3.7/site packages/tensorflow/python/eager/monitoring.py”,第407行,在__
AttributeError:“非类型”对象没有属性“TFE\u MonitoringDeleteBucket”
请尝试版本2.4.0.dev20200901。该错误将随此版本一起消失。希望它能帮助大家,谢谢