Tensorflow: TF 1.x: إزالة رسائل التحذير "المهملة"

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

أعرف أن واجهات برمجة التطبيقات الوظيفية ، مثل tf.layers.dense ، ستختفي في TF 2.0. ومع ذلك ، فإن بدائلها ، tf.keras.layers ، غير متوافقة مع المكونات الأخرى لـ TF 1.x ، على سبيل المثال ، حتى أنها لا تدعم النطاق المتغير (# 27016). لذلك سألتزم بواجهات برمجة التطبيقات التي تم إهمالها في TF 1.x.
هل تسمح من فضلك بإزالة رسائل التحذير "المهملة" المثيرة للاشمئزاز مثل هذه: xxx (from tensorflow.python.layers.core) is deprecated and will be removed in a future version. Use keras.layers.xxx instead.

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

يعمل هذا فقط على 1.14.0 :

import tensorflow as tf
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)

ال 29 كومينتر

يمكنك استخدام هذا: -
استيراد نظام التشغيل
استيراد tensorflow مثل tf
os.environ ['TF_CPP_MIN_LOG_LEVEL'] = '3'

بالتفصيل: -
0 = تم تسجيل جميع الرسائل (السلوك الافتراضي)
1 = لا تتم طباعة رسائل INFO
2 = لم تتم طباعة رسائل INFO و WARNING
3 = لم تتم طباعة رسائل INFO و WARNING و ERROR

هذا ما كنت أستخدمه منذ سنوات
لا يمكنه إيقاف تحذير الإيقاف

بالمناسبة ، قبل إهمال المكونات القديمة ، هل من فضلك أكمل الوظيفة الحالية؟ انظر # 27042. يبدو أن TF جيد جدًا في إهمال الوظائف المستخدمة على نطاق واسع ، ولكنه ضعيف في تحسين نقاط ضعفها

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

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

import tensorflow.python.util.deprecation as deprecation
deprecation._PRINT_DEPRECATION_WARNINGS = False

شكرا
انظر # 27045 ، هل من اقتراحات؟

أعطاني هذا الرمز خطأ:

import tensorflow.python.util.deprecation as deprecation
deprecation._PRINT_DEPRECATION_WARNINGS = False
AttributeError: module 'tensorflow' has no attribute 'python'

لكن تغيير بند الاستيراد جعله يعمل (ويمنع تحذيرات الإيقاف حسب الرغبة):

from tensorflow.python.util import deprecation
deprecation._PRINT_DEPRECATION_WARNINGS = False

شكرا

@ skylogic004 هل هذا من حديث ليلي / بناء من مصدر حديث للسيد؟

mihaimaruseac أوه ، أنا أستخدم tf 1.13 من أناكوندا (لست على دراية بالفرع والبناء الذي كان سيأتي منه في الأصل ، آسف ، ولكن ربما تكون هذه معلومات كافية لك؟).

$ python
Python 3.6.6 | packaged by conda-forge | (default, Jul 26 2018, 11:48:23) [MSC v.1900 64 bit (AMD64)] on win32  
Type "help", "copyright", "credits" or "license" for more information.                                          
>>> import tensorflow as tf                                                                                     
>>> tf.__version__                                                                                              
'1.13.1'                                                                                                        

$ conda list | grep tensor
tensorboard               1.13.1           py36h33f27b4_0
tensorflow                1.13.1          gpu_py36h1635174_0
tensorflow-base           1.13.1          gpu_py36h0fff12a_0
tensorflow-estimator      1.13.0                     py_0
tensorflow-gpu            1.13.1               h0d30ee6_0

رابط حزمة أناكوندا: https://anaconda.org/anaconda/tensorflow-gpu

إذن ، هذا ليس شيئًا يجب أن أقلق بشأنه (السياق الكامل: خلال الأسبوع الماضي ، كانت هناك بعض الإخفاقات في الواردات بسبب بعض التغييرات التي أجريتها ؛ ولكن هذه فقط على الكود الرئيسي ، وهو ما لا يبدو كذلك)

تحذيرات الإيقاف مهمة للمطورين. قد لا تكون مفيدة للغاية للمستخدمين. لذلك هناك حالات يكون من المستحسن فيها إيقاف تشغيلها.

يوجد في Python sys.warnoptions والذي يمكن تعيينه على سبيل المثال عبر PYTHONWARNINGS ، على سبيل المثال:
PYTHONWARNINGS=ignore .

TensorFlow لديه خيار TF_CPP_MIN_LOG_LEVEL كما أشرنا سابقًا.

وهناك أيضًا واجهة برمجة تطبيقات تسجيل TensorFlow Python (التي اعتقدت أنها نجحت من قبل):

import tensorflow as tf

tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)

يبدو أن عدم وجود أي من الخيارات أعلاه يمنع طباعة رسائل التحذير يعد خطأً.

يبدو أن العلامة _PRINT_DEPRECATION_WARNINGS داخلية ويمكن إزالتها في أي وقت.

تحرير: اعتذارات ، كنت أخلط بين

يعمل هذا فقط على 1.14.0 :

import tensorflow as tf
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)

بالنسبة لـ r1.14 وما بعده ، جرب هذا:

try:
    from tensorflow.python.util import module_wrapper as deprecation
except ImportError:
    from tensorflow.python.util import deprecation_wrapper as deprecation
deprecation._PER_MODULE_WARNING_LIMIT = 0

على أي حال ، إنه داخلي وخاضع للتغيير.

أو قم بالتبديل إلى TF2.0 حيث تتم إزالة تحذيرات الإهمال (حسب عدم الحاجة).

ما لم تستخدم مجموعة جيدة من IDE: p
الشيء الوحيد الذي جعلني أتراجع هو مشكلة الإكمال التلقائي ، لذا فإن طلبات القمع هذه هي imo صالحة.

تم حل الإكمال التلقائي في الغالب

جربت كل ما تم اقتراحه:

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
import tensorflow as tf
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
from tensorflow.python.util import deprecation
deprecation._PRINT_DEPRECATION_WARNINGS = False
try:
    from tensorflow.python.util import module_wrapper as deprecation
except ImportError:
    from tensorflow.python.util import deprecation_wrapper as deprecation
deprecation._PER_MODULE_WARNING_LIMIT = 0

لا يزال ، لديك كومة من التحذيرات.

/usr/local/lib/python3.6/dist-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)])
/usr/local/lib/python3.6/dist-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)])
/usr/local/lib/python3.6/dist-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)])
/usr/local/lib/python3.6/dist-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)])
/usr/local/lib/python3.6/dist-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)])
/usr/local/lib/python3.6/dist-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)])
/usr/local/lib/python3.6/dist-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/local/lib/python3.6/dist-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/local/lib/python3.6/dist-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/local/lib/python3.6/dist-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/local/lib/python3.6/dist-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/local/lib/python3.6/dist-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 version 1.14.0

نظام التشغيل Ubuntu 16.04.0
بايثون 3.6.8

@ pyotr777 بالنسبة

warnings.filterwarnings('ignore', category=DeprecationWarning)
warnings.filterwarnings('ignore', category=FutureWarning)

@ pyotr777 هؤلاء يأتون من numpy. أنت تستخدم إصدارًا فارغًا غير متوافق قليلاً مع إصدار TF الذي تستخدمه.

لخطر الحصول على المزيد من الأصوات المعارضة ، يرجى التبديل إلى 2.0

تحذير المستقبل

import warnings
warnings.filterwarnings('ignore', category=DeprecationWarning)
warnings.filterwarnings('ignore', category=FutureWarning)

لم يقمع

/usr/local/lib/python3.7/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)])

بالنسبة لي هذا عمل لتحذير t2.0

import tensorflow as tf
tf.get_logger().warning('test')
# WARNING:tensorflow:test
tf.get_logger().setLevel('ERROR')
tf.get_logger().warning('test')

تم تغيير FYI Logging in TensorFlow لأن TF_CPP_MIN_LOG_LEVEL لا يعمل بعد الآن

لا يزال ، لديك كومة من التحذيرات.

/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:516: FutureWarning: تم إهمال التمرير (النوع ، 1) أو "النوع 1" كمرادف للنوع ؛ في إصدار مستقبلي من numpy ، سيتم فهمه على أنه (type، (1،)) / '(1،) type'.
_np_qint8 = np.dtype ([("qint8"، np.int8، 1)])
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:517: FutureWarning: تم إهمال التمرير (النوع ، 1) أو "النوع 1" كمرادف للنوع ؛ في إصدار مستقبلي من numpy ، سيتم فهمه على أنه (type، (1،)) / '(1،) type'.
_np_quint8 = np.dtype ([("quint8"، np.uint8، 1)])

يُرجى المحاولة مرة واحدة لتغيير 1 إلى 0 ، على سبيل المثال: _np_qint8 = np.dtype ([("qint8"، np.int8، 1)]) إلى _np_qint8 = np.dtype ([("qint8"، np.int8 ، 0)]) هذا يناسبني

solve warnings

أنت تستخدم إصدارًا فارغًا غير متوافق قليلاً مع إصدار TF الذي تستخدمه.

بالنسبة لي عمل وضع

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

قبل

import tensorflow as tf

وجميع الواردات الأخرى.

لدي TF 1.14.0 و numpy 1.18.1.

قبل استيراد tensorflow ، يجب تنفيذ ما يلي:
تحذيرات الاستيراد
warnings.filterwarnings ('ignore'، category = FutureWarning)
warnings.filterwarnings ('ignore'، category = DeprecationWarning)
يعمل مع tensorflow == 1.12.0 ، numpy == 1.18.1 ، python 3.6

حاولت هذا:

import warnings
warnings.filterwarnings('ignore',category=FutureWarning)
warnings.filterwarnings('ignore', category=DeprecationWarning)

وأنه لم يعمل بالنسبة لي عندما ركضت الثعبان غير تفاعلي tensorflow==1.14.0 ، numpy==1.18.1 ، python==3.6.10 ، لكنه عمل في جلسة تفاعلية.

لقد وجدت أن ما يلي نجح عندما أدير بايثون بشكل تفاعلي وغير تفاعلي. عند استخدام tensorflow 2.X ، يمكنك استخدام:

import tensorflow as tf
tf.logging.set_verbosity(tf.logging.ERROR)

وعند استخدام tensorflow 1.X (عملت على 1.14 بالنسبة لي):

import tensorflow as tf
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)

أنا أستخدم tf 1.13.1
هذا يعمل:

import tensorflow as tf
tf.logging.set_verbosity(tf.logging.ERROR)

.compat.v1 غير مطلوب.

جربت جميع الطرق ، لكن لم يعمل أي منها في دفتر Jupyter ...

warnings.filterwarnings('ignore',category=FutureWarning)
يمكن أن يتجاهل هذا التحذيرات عند استيراد Tensorflow ، ولكن لا يزال هناك العديد من التحذيرات إذا قمت بتحميل النموذج ...

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