tensorflow - tensorflow 无法将 dtype 资源的张量转换为 NumPy 数组。特飞特
问题描述
我已经训练了一个网络(下面的 git 链接)并以保存的模型格式保存。并想将其转换为 tflite。我正在为 tflite 转换器使用 python API(tflite.py
在下面的 git 链接中)。但我不能这样做。
系统信息:
OS平台和发行版: Ubuntu 18.04.3 LTS
TensorFlow版本: tensorflow/tensorflow:2.2.0-gpu (docker)
网络链接并保存模型代码。
转换器调用的输出:
File "tflite.py", line 22, in convert_model
tflite_model = converter.convert()
File "/usr/local/lib/python3.6/dist-packages/tensorflow/lite/python/lite.py", line 459, in convert
self._funcs[0], lower_control_flow=False))
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/convert_to_constants.py", line 706, in convert_variables_to_constants_v2_as_graph
func, lower_control_flow, aggressive_inlining)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/convert_to_constants.py", line 457, in _convert_variables_to_constants_v2_impl
tensor_data = _get_tensor_data(func)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/convert_to_constants.py", line 217, in _get_tensor_data
data = val_tensor.numpy()
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py", line 961, in numpy
maybe_arr = self._numpy() # pylint: disable=protected-access
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py", line 929, in _numpy
six.raise_from(core._status_to_exception(e.code, e.message), None)
File "<string>", line 3, in raise_from
tensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot convert a Tensor of dtype resource to a NumPy array.
已保存模型的链接
解决方案
推荐阅读
- quickbooks-online - 如何使用 REST 或 SDK 将数据发布到 QuickBook Online
- google-drive-api - 关于“向所有相关团队云端硬盘字段的迁移请求”
- python - 如何有效地使用 python pool.imap_unordered?
- json - Sequelizer - JSON 中第 65 位的意外标记 z
- c# - 无法反序列化当前 JSON.Net 数组 C#
- mysql - MySQL Regex 如果字符串在 5 位数字后包含连字符
- postgresql - 将 Apache Airflow 配置为使用 postgres 数据库时出错
- javascript - Paperjs 在不使用 Paperjs 代码时导致类语法错误
- javascript - Javascript 表单验证不适用于注册弹出表单
- c# - 在 Entity Framework Core 3 中使用 TransactionScope 时,SET IDENTITY_INSERT 不起作用