"синоним типа устарел; в следующей версии numpy он будет пониматься как (type, (1,))/'(1,) type'." проблема в TensorFlow

Я установил TensorFlow 1.10.1, но когда я попытался импортировать TensorFlow, он сказал, что мне нужна версия TensorFlow 1.10.0. Таким образом, я установил его и теперь получаю следующие предупреждения:

>>> import tensorflow
C:\Users\PC\Anaconda3\envs\tut\lib\site-packages\tensorflow\python\framework\dtypes.py:516: 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)])
C:\Users\PC\Anaconda3\envs\tut\lib\site-packages\tensorflow\python\framework\dtypes.py:517: 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)])
C:\Users\PC\Anaconda3\envs\tut\lib\site-packages\tensorflow\python\framework\dtypes.py:518: 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)])
C:\Users\PC\Anaconda3\envs\tut\lib\site-packages\tensorflow\python\framework\dtypes.py:519: 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)])
C:\Users\PC\Anaconda3\envs\tut\lib\site-packages\tensorflow\python\framework\dtypes.py:520: 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)])
C:\Users\PC\Anaconda3\envs\tut\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_resource = np.dtype([("resource", np.ubyte, 1)])
C:\Users\PC\Anaconda3\envs\tut\lib\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:541: 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)])
C:\Users\PC\Anaconda3\envs\tut\lib\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:542: 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)])
C:\Users\PC\Anaconda3\envs\tut\lib\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:543: 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)])
C:\Users\PC\Anaconda3\envs\tut\lib\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:544: 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)])
C:\Users\PC\Anaconda3\envs\tut\lib\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:545: 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)])
C:\Users\PC\Anaconda3\envs\tut\lib\site-packages\tensorboard\compat\tensorflow_stub\dtypes.py:550: 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)])

Ответы

Ответ 1

Это просто предупреждение, а не ошибка. Это происходит потому, что ваша текущая версия nray-libray несовместима с версией tenorflow. Вы должны понизить версию NumPy.

tensorflow 1.10.0 имеет требование numpy<=1.14.5,>=1.13.3, но у вас должна быть установлена более поздняя версия (это предупреждение появляется в последней версии numpy 1.17.0).

Ответ 2

Если вы используете TF 2.0 , быстрое решение было бы понизить ваш NumPy до 1.16.4. (Я использовал 1.17 и получил те же предупреждения).

1. pip uninstall numpy 
2. pip install numpy==1.16.4

Смотрите здесь (спасибо ymodak)

Ответ 3

Новейшие заметки о выпуске (1.17):

Future Changes

Shape-1 fields in dtypes wont be collapsed to scalars in a future version
Currently, a field specified as [(name, dtype, 1)] or "1type" is interpreted 
as a scalar field (i.e., the same as [(name, dtype)] or [(name, dtype, ()]). 
This now raises a FutureWarning; in a future version, it will be interpreted 
as a shape-(1,) field, i.e. the same as [(name, dtype, (1,))] or "(1,)type" 
(consistently with [(name, dtype, n)] / "ntype" with n>1, which is already 
equivalent to [(name, dtype, (n,)] / "(n,)type").

https://docs.scipy.org/doc/numpy/release.html

Таким образом, с вашим выражением:

In [123]: np.dtype([("qint8", np.int8, 1)])                                                                  
/usr/local/bin/ipython3:1: 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'.
  #!/usr/bin/python3
Out[123]: dtype([('qint8', 'i1')])

In [124]: np.dtype([("qint8", np.int8, (1,))])                                                               
Out[124]: dtype([('qint8', 'i1', (1,))])

In [125]: np.dtype([("qint8", np.int8)])                                                                     
Out[125]: dtype([('qint8', 'i1')])

In [126]: np.dtype([("qint8", np.int8, 2)])                                                                  
Out[126]: dtype([('qint8', 'i1', (2,))])

In [127]: np.__version__                                                                                     
Out[127]: '1.17.0'

Ответ 4


У меня была такая же проблема в моем ноутбуке с Linux с tenorflow в Python3 v3.6
На самом деле, вам просто нужно изменить несколько строк в 2 файлах:
 - 1

~/.local/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py

в вашем случае:

C:\Users\PC\Anaconda3\envs\tut\lib\site-packages\tensorflow\python\framework\dtypes.py



Теперь измените этот код: (строка 516)

_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_bfloat16 is defined by a module import.

# Custom struct dtype for directly-fed ResourceHandles of supported type(s).
np_resource = np.dtype([("resource", np.ubyte, 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,))])

# _np_bfloat16 is defined by a module import.

# Custom struct dtype for directly-fed ResourceHandles of supported type(s).
np_resource = np.dtype([("resource", np.ubyte, (1,))])

вы должны сделать то же самое с этим файлом:

  • 2

    ~/.Local/Library/python3.6/сайт-пакеты/tensorboard/Compat/tensorflow_stub/dtypes.py

в вашем случае:

C:\Users\PC\Anaconda3\envs\tut\lib\site-packages\tensorboard/compat/tensorflow_stub/dtypes.py

и это будет работать, инчаллах.

Ответ 5

pip install "numpy<1.17"  to revert to numpy version 1.16.4