修改dtypes.py清除tensflow日志

修复TensorFlow中dtypes.py的量子整数类型定义
这篇博客介绍了如何修改TensorFlow的日志路径中`dtypes.py`文件里的量子整数类型定义。原始代码使用了一维数组,而更新后的代码将每个量子整数类型定义为固定大小的一维数组,例如:_np_qint8更改为_np_qint8=np.dtype([qint8 np.int8, (1,)])。这一改动可能与优化内存使用或兼容性有关。
部署运行你感兴趣的模型镜像
举例: 
_np_qint32 C:\Users\Administrator\AppData\Local\Programs\Python
\Python36\lib\site-packages\tensorflow\python\framework
\dtypes.py

看tensflow日志上显示的日志路径中dtypes.py
依次修改

举例:
_np_qint8 = np.dtype([("qint8", np.int8, 1)])
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])
_np_qint16 = np.dtype([("qint16", np.int16, 1)])
_np_quint16 = np.dtype([("quint16", np.uint16, 1)])
_np_qint32 = np.dtype([("qint32", np.int32, 1)])
依次改为: 
_np_qint8 = np.dtype([("qint8", np.int8, (1,))])
_np_quint8 = np.dtype([("quint8", np.uint8, (1,))])
_np_qint16 = np.dtype([("qint16", np.int16, (1,))])
_np_quint16 = np.dtype([("quint16", np.uint16, (1,))])
_np_qint32 = np.dtype([("qint32", np.int32, (1,))])

您可能感兴趣的与本文相关的镜像

TensorFlow-v2.15

TensorFlow-v2.15

TensorFlow

TensorFlow 是由Google Brain 团队开发的开源机器学习框架,广泛应用于深度学习研究和生产环境。 它提供了一个灵活的平台,用于构建和训练各种机器学习模型

D:\anaconda3\envs\tf_legacy\lib\site-packages\tensorflow\python\framework\dtypes.py:523: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint8 = np.dtype([("qint8", np.int8, 1)]) D:\anaconda3\envs\tf_legacy\lib\site-packages\tensorflow\python\framework\dtypes.py:524: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_quint8 = np.dtype([("quint8", np.uint8, 1)]) D:\anaconda3\envs\tf_legacy\lib\site-packages\tensorflow\python\framework\dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint16 = np.dtype([("qint16", np.int16, 1)]) D:\anaconda3\envs\tf_legacy\lib\site-packages\tensorflow\python\framework\dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_quint16 = np.dtype([("quint16", np.uint16, 1)]) D:\anaconda3\envs\tf_legacy\lib\site-packages\tensorflow\python\framework\dtypes.py:527: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. _np_qint32 = np.dtype([("qint32", np.int32, 1)]) D:\anaconda3\envs\tf_legacy\lib\site-packages\tensorflow\python\framework\dtypes.py:532: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'. np_resource = np.dtype([("resource", np.ubyte, 1)]) usage: freeze_graph.py [-h] -bert_model_dir BERT_MODEL_DIR -model_dir MODEL_DIR [-model_pb_dir MODEL_PB_DIR] [-max_seq_len MAX_SEQ_LEN] [-n
03-27
>>> import tensorflow as tf A module that was compiled using NumPy 1.x cannot be run in NumPy 2.2.6 as it may crash. To support both 1.x and 2.x versions of NumPy, modules must be compiled with NumPy 2.0. Some module may need to rebuild instead e.g. with 'pybind11>=2.12'. If you are a user of the module, the easiest solution will be to downgrade to 'numpy<2' or try to upgrade the affected module. We expect that some modules will need time to support NumPy 2. Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Users\SHINING3D\anaconda3\envs\gpu_env\lib\site-packages\tensorflow\__init__.py", line 37, in <module> from tensorflow.python.tools import module_util as _module_util File "C:\Users\SHINING3D\anaconda3\envs\gpu_env\lib\site-packages\tensorflow\python\__init__.py", line 37, in <module> from tensorflow.python.eager import context File "C:\Users\SHINING3D\anaconda3\envs\gpu_env\lib\site-packages\tensorflow\python\eager\context.py", line 35, in <module> from tensorflow.python.client import pywrap_tf_session File "C:\Users\SHINING3D\anaconda3\envs\gpu_env\lib\site-packages\tensorflow\python\client\pywrap_tf_session.py", line 19, in <module> from tensorflow.python.client._pywrap_tf_session import * AttributeError: _ARRAY_API not found A module that was compiled using NumPy 1.x cannot be run in NumPy 2.2.6 as it may crash. To support both 1.x and 2.x versions of NumPy, modules must be compiled with NumPy 2.0. Some module may need to rebuild instead e.g. with 'pybind11>=2.12'. If you are a user of the module, the easiest solution will be to downgrade to 'numpy<2' or try to upgrade the affected module. We expect that some modules will need time to support NumPy 2. Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Users\SHINING3D\anaconda3\envs\gpu_env\lib\site-packages\tensorflow\__init__.py", line 37, in <module> from tensorflow.python.tools import module_util as _module_util File "C:\Users\SHINING3D\anaconda3\envs\gpu_env\lib\site-packages\tensorflow\python\__init__.py", line 42, in <module> from tensorflow.python import data File "C:\Users\SHINING3D\anaconda3\envs\gpu_env\lib\site-packages\tensorflow\python\data\__init__.py", line 21, in <module> from tensorflow.python.data import experimental File "C:\Users\SHINING3D\anaconda3\envs\gpu_env\lib\site-packages\tensorflow\python\data\experimental\__init__.py", line 96, in <module> from tensorflow.python.data.experimental import service File "C:\Users\SHINING3D\anaconda3\envs\gpu_env\lib\site-packages\tensorflow\python\data\experimental\service\__init__.py", line 419, in <module> from tensorflow.python.data.experimental.ops.data_service_ops import distribute File "C:\Users\SHINING3D\anaconda3\envs\gpu_env\lib\site-packages\tensorflow\python\data\experimental\ops\data_service_ops.py", line 24, in <module> from tensorflow.python.data.experimental.ops import compression_ops File "C:\Users\SHINING3D\anaconda3\envs\gpu_env\lib\site-packages\tensorflow\python\data\experimental\ops\compression_ops.py", line 16, in <module> from tensorflow.python.data.util import structure File "C:\Users\SHINING3D\anaconda3\envs\gpu_env\lib\site-packages\tensorflow\python\data\util\structure.py", line 23, in <module> from tensorflow.python.data.util import nest File "C:\Users\SHINING3D\anaconda3\envs\gpu_env\lib\site-packages\tensorflow\python\data\util\nest.py", line 36, in <module> from tensorflow.python.framework import sparse_tensor as _sparse_tensor File "C:\Users\SHINING3D\anaconda3\envs\gpu_env\lib\site-packages\tensorflow\python\framework\sparse_tensor.py", line 24, in <module> from tensorflow.python.framework import constant_op File "C:\Users\SHINING3D\anaconda3\envs\gpu_env\lib\site-packages\tensorflow\python\framework\constant_op.py", line 25, in <module> from tensorflow.python.eager import execute File "C:\Users\SHINING3D\anaconda3\envs\gpu_env\lib\site-packages\tensorflow\python\eager\execute.py", line 23, in <module> from tensorflow.python.framework import dtypes File "C:\Users\SHINING3D\anaconda3\envs\gpu_env\lib\site-packages\tensorflow\python\framework\dtypes.py", line 29, in <module> from tensorflow.python.lib.core import _pywrap_bfloat16 AttributeError: _ARRAY_API not found ImportError: numpy.core._multiarray_umath failed to import ImportError: numpy.core.umath failed to import Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Users\SHINING3D\anaconda3\envs\gpu_env\lib\site-packages\tensorflow\__init__.py", line 37, in <module> from tensorflow.python.tools import module_util as _module_util File "C:\Users\SHINING3D\anaconda3\envs\gpu_env\lib\site-packages\tensorflow\python\__init__.py", line 42, in <module> from tensorflow.python import data File "C:\Users\SHINING3D\anaconda3\envs\gpu_env\lib\site-packages\tensorflow\python\data\__init__.py", line 21, in <module> from tensorflow.python.data import experimental File "C:\Users\SHINING3D\anaconda3\envs\gpu_env\lib\site-packages\tensorflow\python\data\experimental\__init__.py", line 96, in <module> from tensorflow.python.data.experimental import service File "C:\Users\SHINING3D\anaconda3\envs\gpu_env\lib\site-packages\tensorflow\python\data\experimental\service\__init__.py", line 419, in <module> from tensorflow.python.data.experimental.ops.data_service_ops import distribute File "C:\Users\SHINING3D\anaconda3\envs\gpu_env\lib\site-packages\tensorflow\python\data\experimental\ops\data_service_ops.py", line 24, in <module> from tensorflow.python.data.experimental.ops import compression_ops File "C:\Users\SHINING3D\anaconda3\envs\gpu_env\lib\site-packages\tensorflow\python\data\experimental\ops\compression_ops.py", line 16, in <module> from tensorflow.python.data.util import structure File "C:\Users\SHINING3D\anaconda3\envs\gpu_env\lib\site-packages\tensorflow\python\data\util\structure.py", line 23, in <module> from tensorflow.python.data.util import nest File "C:\Users\SHINING3D\anaconda3\envs\gpu_env\lib\site-packages\tensorflow\python\data\util\nest.py", line 36, in <module> from tensorflow.python.framework import sparse_tensor as _sparse_tensor File "C:\Users\SHINING3D\anaconda3\envs\gpu_env\lib\site-packages\tensorflow\python\framework\sparse_tensor.py", line 24, in <module> from tensorflow.python.framework import constant_op File "C:\Users\SHINING3D\anaconda3\envs\gpu_env\lib\site-packages\tensorflow\python\framework\constant_op.py", line 25, in <module> from tensorflow.python.eager import execute File "C:\Users\SHINING3D\anaconda3\envs\gpu_env\lib\site-packages\tensorflow\python\eager\execute.py", line 23, in <module> from tensorflow.python.framework import dtypes File "C:\Users\SHINING3D\anaconda3\envs\gpu_env\lib\site-packages\tensorflow\python\framework\dtypes.py", line 34, in <module> _np_bfloat16 = _pywrap_bfloat16.TF_bfloat16_type() TypeError: Unable to convert function return value to a Python type! The signature was () -> handle >>> print("TF Version:", tf.__version__) Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'tf' is not defined >>> print("GPU Available:", tf.config.list_physical_devices('GPU')) Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'tf' is not defined
最新发布
10-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值