Tensorflow: FutureWarning: استدعاءات numpy API مهملة في tf.python.framework.dtypes

تم إنشاؤها على ٥ يوليو ٢٠١٩  ·  33تعليقات  ·  مصدر: tensorflow/tensorflow

معلومات النظام

  • هل قمت بكتابة رمز مخصص (على عكس استخدام نص برمجي كمثال للمخزون متوفر في TensorFlow): ليس حقًا
  • النظام الأساسي لنظام التشغيل والتوزيع (مثل Linux Ubuntu 16.04): MacOS Mojave 10.14.5 (18F132)
  • تم تثبيت TensorFlow من (المصدر أو الثنائي): tensorflow == 2.0.0b1 من https://pypi.org/
  • إصدار TensorFlow (استخدم الأمر أدناه): v2.0.0-beta0-16-g1d91213fe7 2.0.0-beta1
  • إصدار Python: Python 3.6.8
  • إصدار Bazel (إذا كان التجميع من المصدر): N / A
  • إصدار GCC / Compiler (إذا كان يتم التحويل من المصدر): N / A
  • إصدار CUDA / cuDNN: N / A
  • طراز GPU والذاكرة: N / A

صف السلوك الحالي

الكثير من أخطاء FutureWarning:

/xxx/venv/lib/python3.6/site-packages/tensorflow-2.0.0b1-py3.6-macosx-10.14-x86_64.egg/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)])
/xxx/venv/lib/python3.6/site-packages/tensorflow-2.0.0b1-py3.6-macosx-10.14-x86_64.egg/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)])
/xxx/venv/lib/python3.6/site-packages/tensorflow-2.0.0b1-py3.6-macosx-10.14-x86_64.egg/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)])
/xxx/venv/lib/python3.6/site-packages/tensorflow-2.0.0b1-py3.6-macosx-10.14-x86_64.egg/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)])
/xxx/venv/lib/python3.6/site-packages/tensorflow-2.0.0b1-py3.6-macosx-10.14-x86_64.egg/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)])
/xxx/venv/lib/python3.6/site-packages/tensorflow-2.0.0b1-py3.6-macosx-10.14-x86_64.egg/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)])
/xxx/venv/lib/python3.6/site-packages/tb_nightly-1.14.0a20190603-py3.6.egg/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)])
/xxx/venv/lib/python3.6/site-packages/tb_nightly-1.14.0a20190603-py3.6.egg/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)])
/xxx/venv/lib/python3.6/site-packages/tb_nightly-1.14.0a20190603-py3.6.egg/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)])
/xxx/venv/lib/python3.6/site-packages/tb_nightly-1.14.0a20190603-py3.6.egg/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)])
/xxx/venv/lib/python3.6/site-packages/tb_nightly-1.14.0a20190603-py3.6.egg/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)])
/xxx/venv/lib/python3.6/site-packages/tb_nightly-1.14.0a20190603-py3.6.egg/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)])

صف السلوك المتوقع

لا تحذيرات.

رمز إعادة إنتاج المشكلة

import tensorflow.python.framework.dtypes

print("Hello world")
TF 2.0 apis awaiting response support

التعليق الأكثر فائدة

Akeaakar وفي الوقت الحالي ، pip install "numpy<1.17" للعودة إلى الإصدار 1.16.4

ال 33 كومينتر

habernal لقد قمنا بتنفيذ التعليمات البرمجية الخاصة بك في Google colab وفي دفتر Jupyter بإصدار TF
2.0 beta 1 و numpy version 1.16.4. لم نتلق أي تحذيرات ، يرجى ترقية نسختك الفارغة والتحقق مما إذا كانت التحذيرات لا تزال قائمة.

شكرًا ، ravikyram - لقد تحققت مرتين من المكتبات المثبتة ووجدت الجاني.

يأتي TF 2.0.b1 مع تبعية numpy 1.16.4 ولا يظهر أي تحذير. لذلك فمن الصحيح أنه لا يمكنك إعادة إنتاج الخطأ ، ولا أنا كذلك.

ومع ذلك ، اتضح أن لدي numpy 1.17.0rc1 مثبتًا في المشروع (لا توجد فكرة من أي مكتبة تم ربطها لأنني بالتأكيد لم أقم بتثبيتها يدويًا).

Numpy 1.17.0rc1 مسؤول عن تقديم شكوى بخصوص FutureWarnings. ربما لم يكن الإصلاح عاجلاً في الوقت الحالي ولكن بمجرد إجراء ترقية إلى np 17 ، سيظهر هذا مرة أخرى ، على ما أعتقد.

في الواقع ، يتم التعامل مع التبعية غير المعقدة بشكل مختلف نظرًا للأداة التي تثبتها TF ( pip مقابل setuptools ). تم اختبار كلاهما في بيئة افتراضية نظيفة مع تثبيت هذه المكتبات فقط في البداية:

pip==19.1.1 setuptools==41.0.1 wheel==0.33.4

  1. تركيب TF باستخدام النقطة:
$ pip install tensorflow==2.0.0b1 --no-cache-dir
...
Collecting numpy<2.0,>=1.14.5 (from tensorflow==2.0.0b1)
  Downloading https://files.pythonhosted.org/packages/...cc/numpy-1.16.4-cp36-cp....whl (13.9MB)
...
  1. تثبيت TF باعتباره تابعًا في setup.py يحتوي فقط على:
from setuptools import setup
setup(
    name='tf30427',
    version='0.0.1',
    install_requires=['tensorflow==2.0.0b1'],
)

ثم تثبيت كملف

$ python setup.py install
...
Searching for numpy<2.0,>=1.14.5
Reading https://pypi.org/simple/numpy/
Downloading https://files.pythonhosted.org/packages/e...17/numpy-1.17.0rc1-cp36-cp36...25e0
Best match: numpy 1.17.0rc1
Processing numpy-1.17.0rc1-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Installing numpy-1.17.0rc1-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl to /xxx/venv/lib/python3.6/site-packages
Adding numpy 1.17.0rc1 to easy-install.pth file
...

إنهم يفهمون المتطلبات numpy<2.0,>=1.14.5 مختلف: تثبيت النقطة 1.16.4 بينما setuptools 1.17.0rc1.

الإصلاح المقترح:

غيّر التبعية إلى numpy<1.17,>=1.14.5 للتمسك بالإصدار 1.16 بغض النظر عن إجراء التثبيت.

وإليك جوهر المشكلة: https://github.com/pypa/setuptools/issues/855

كما اكتشفها الآخرون أيضًا: https://stackoverflow.com/q/54796975

habernal اسمحوا لي أن أعرف ما إذا كان بإمكاننا إغلاق هذه المشكلة منذ أن وجدنا الحل. شكرا!

habernal أعتقد أنه يمكن تحديث Tensorflow لجعله متوافقًا مع numpy 1.17+. إنشاء رقم PR # 30559 للإصلاح.

مرحبا لدي نفس الخطأ. هل يمكنك إخباري بما يجب فعله بالتعليمات لحل هذه المشكلة. شكرًا

Akeaakar تم إصلاح المشكلة ودمجها في الفرع الرئيسي. في الإصدار القادم من TF ، يجب أن تختفي المشكلة.

Akeaakar وفي الوقت الحالي ، pip install "numpy<1.17" للعودة إلى الإصدار 1.16.4

مع Ubuntu19.04 ، فإن الجمع بين tensorflow-gpu 1.14.0 (أو tensorflow-gpu 1.12.2) مع numpy 1.17.0 له نفس التحذيرات أيضًا. عند تغيير الإصدار الفارغ إلى 1.16.3 ، تختفي التحذيرات.

أو يمكنك إلغاء التحذيرات باستخدام الكود أدناه.

import warnings
import tensorflow as tf

warnings.filterwarnings('ignore')

أو يمكنك إلغاء التحذيرات باستخدام الكود أدناه.

import warnings
import tensorflow as tf

warnings.filterwarnings('ignore')

يبدو أن هذا لا يعمل بالنسبة لي. (numpy 1.17.0 python3.7.3)

أو يمكنك إلغاء التحذيرات باستخدام الكود أدناه.

import warnings
import tensorflow as tf

warnings.filterwarnings('ignore')

يبدو أن هذا لا يعمل بالنسبة لي. (numpy 1.17.0 python3.7.3)

import warnings
warnings.filterwarnings('ignore',category=FutureWarning)
import tensorflow as tf

يجب أن يكون قبل الاستيراد ، حيث أن هذا هو مصدر التحذيرات. تمت أيضًا إضافة قيد للتأثير على فئة التحذير تلك فقط بدلاً من إسكات جميع التحذيرات.

تحذيرات الاستيراد
warnings.filterwarnings ('ignore'، category = FutureWarning)
استيراد tensorflow مثل tf
إنه يعمل بالنسبة لي حتى في ظل بيئة افتراضية

لدي numpy في ./venv/lib/python3.7/site-packages (1.17.2). في كل من Jupyter و VS Code ، حصلت على الفكرة. أنا حقا لا أحب فكرة تجاهل التحذير. سيكون موضع تقدير أي إصلاحات.

تثبيت نقطة "numpy <1.17"

بعد القيام بذلك ، قام النظام بتثبيت numpy-1.16.5 . ولكن الآن import tensorflow يقول:
ImportError: Something is wrong with the numpy installation.

numpy: pip install --upgrade numpy
كراس: conda install -c conda-forge keras

قم بترقية numpy وتثبيت keras باستخدام الأمر أعلاه في Anaconda موجه.

مرحبًا ، كمرجع ، لقد تم إصلاح هذا مع هذين الإصدارين:

>>> import tensorflow as tf
>>> print(tf.__version__)
2.0.0-rc1
>>> import numpy as np
>>> print(np.__version__)
1.17.2
>>> exit()

24/09/19 ، أتمنى أن يساعدك هذا

شكرا @ Namburger . اختفت التحذيرات في الإصدار 2.0.0-rc1.

مع أحدث إصدار من Tensorflow (أي 2.0.0) و numpy 1.17.2 ، عاد التحذير.

هل يمكنك توفير الناسخ ،

>>> import tensorflow as tf
>>> tf.__version__
'2.0.0'
>>> import numpy as np
>>> np.__version__
'1.17.2'
>>> import tensorflow.python.framework.dtypes
>>> 

تمت المحاولة أيضًا من ملف:

import tensorflow as tf
import numpy as np

print("TF", tf.__version__)
print("NP", np.__version__)

import tensorflow.python.framework.dtypes

لكن بدون تحذيرات:

(gh_numpty) mihaimaruseac<strong i="13">@ankh</strong>:/tmp/gh_numpty$ python test.py 
TF 2.0.0
NP 1.17.2

mihaimaruseac ، يمكنني إعادة إنتاج المشكلة بكلا المثالين

2019-10-14 12:20:56.438892: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.1
/usr/lib/python3.7/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)])
/usr/lib/python3.7/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)])
/usr/lib/python3.7/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)])
/usr/lib/python3.7/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)])
/usr/lib/python3.7/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)])
/usr/lib/python3.7/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)])
TF 2.0.0
NP 1.17.2

أنا أستخدم القوس. القوس ، إذا كنت أتذكر بشكل صحيح ، يكيّف Tensorflow للعمل مع Python 3.7.4. أم أن هذا الإصدار من Python مدعوم بالفعل بواسطة Tensorflow؟

UndeadKernel أنا أدير Arch أيضًا ، لكني لا أتلقى أي تحذيرات حتى الآن (كانت موجودة في وقت سابق). حزمتي هي:

  • python-tensorflow-opt-cuda: 2.0.0-2
  • python-numpy-openblas: 1.17.2-1

هذا في الواقع غريب جدًا @ rharish101 ، لدي نفس الإصدارات بالضبط. حاولت استخدام python-numpy من الريبو الرسمي و python-numpy-openblas` من AUR وأرى نفس رسائل FutureWarning.

UndeadKernel هل يمكنك محاولة إعادة تثبيت حزمة TensorFlow؟ ربما تغير في التحديث الأخير (2.0.0-2 مقابل 2.0.0-1). أتذكر أنني أيضًا رأيت تلك التحذيرات في الأيام القليلة الماضية ، ولكن اعتبارًا من اليوم ، اختفت ، مع الاختلاف الوحيد الذي قمت بتحديثه TensorFlow منذ 9 أيام.

@ rharish101 ، شكرا على الاقتراح.
لقد لاحظت أن إصدار tensorboard ليس هو نفس إصدار tensorflow . بعد إعادة تثبيت tensorboard (لاحظ أن هذا هو "tensorBoard" وليس "TensorFlow") ، اختفى التحذير.

يوجد إصدار رسمي من 2.0 ، ولن تحتاج إلى استخدام الإصدارات المصححة.

إلى أي بقع تشير إلىmihaimaruseac؟

2.0.0-1 و 2.0.0-2 مذكوران في التعليقات أعلاه

يجب أن يعمل pip install tensorflow==2.0.0 (قد تحتاج إلى ترقية النقطة إلى أحدث إصدار إذا كنت تستخدم إصدارًا قديمًا ، نظرًا لأن التغيير متوافق مع manylinux2010)

محاولة

pip3 [نقطة] تثبيت tf-nightly

يبدو أن البناء الليلي لـ Tensorflow قد تم حل هذه المشكلة ، حظًا سعيدًا

مقابل tensorflow==2.0.0 و numpy==1.17.4

لا أحصل على الخطأ / التحذير.

يمكنك المحاولة على النحو التالي:

>>> import tensorflow as tf
>>> tf.__version__
'2.0.0'
>>> import numpy as np
>>> np.__version__
'1.17.4'
>>> import tensorflow.python.framework.dtypes
>>>

Akeaakar وفي الوقت الحالي ، pip install "numpy<1.17" للعودة إلى الإصدار 1.16.4

وكذلك أناكوندا:
conda install "numpy<1.17"

وفي الوقت الحالي ، pip install "numpy<1.17" للعودة إلى الإصدار 1.16.4

بعد كم ساعة كان هذا هو الذي حل مشكلتي. لقد قمت بتثبيت TF الذي تم تثبيت الإصدار numpy عليه (18.0) وعندما أعادته إلى 1.16.4 كان يعمل! شكرا

هل كانت هذه الصفحة مفيدة؟
0 / 5 - 0 التقييمات