Tensorflow: TF 1.x: Entfernen Sie die "veralteten" Warnmeldungen

Erstellt am 22. März 2019  ·  29Kommentare  ·  Quelle: tensorflow/tensorflow

Ich weiß, dass die funktionalen APIs wie tf.layers.dense in TF 2.0 verschwinden werden. Ihre Alternativen, tf.keras.layers, sind jedoch nicht mit anderen Komponenten von TF 1.x kompatibel, zum Beispiel unterstützen sie nicht einmal den Gültigkeitsbereich von Variablen (#27016). Also bleibe ich bei den veralteten APIs in TF 1.x.
Würden Sie bitte die ekelhaften "veralteten" Warnmeldungen wie diese entfernen: xxx (from tensorflow.python.layers.core) is deprecated and will be removed in a future version. Use keras.layers.xxx instead.

Hilfreichster Kommentar

Auf 1.14.0 funktioniert nur das:

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

Alle 29 Kommentare

Sie können dies verwenden:-
Importieren von OS
Tensorflow als tf importieren
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'

Im Detail:-
0 = alle Nachrichten werden protokolliert (Standardverhalten)
1 = INFO-Meldungen werden nicht gedruckt
2 = INFO- und WARNING-Meldungen werden nicht gedruckt
3 = INFO-, WARNING- und ERROR-Meldungen werden nicht gedruckt

das benutze ich seit jahren
es kann die Veraltungswarnung nicht stoppen

Übrigens, bevor Sie alte Komponenten einstellen, würden Sie bitte die aktuelle Funktionalität vervollständigen? Siehe #27042. Es scheint, dass TF sehr gut darin ist, weit verbreitete Funktionen zu verwerfen, aber schlecht darin, seine Schwachstellen zu verbessern

Einstellungsnachrichten werden benötigt, um Personen, die eine aktuelle Version von TensorFlow verwenden möchten, über zukünftige Entwicklungen zu informieren und ihnen Zeit zur Anpassung zu geben.

Daher können wir diese Nachrichten nicht entfernen. Sie können sie mit dieser privaten API für sich selbst deaktivieren

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

Vielen Dank
Siehe #27045, irgendwelche Vorschläge?

Dieser Code hat mir einen Fehler gegeben:

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

Aber das Ändern der Importzeile hat es funktioniert (und unterdrückt die Veraltungswarnungen wie gewünscht):

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

Vielen Dank

@ skylogic004 ist dies von einem kürzlichen nächtlichen / Build aus der Quelle des aktuellen Masters?

@mihaimaruseac Oh, ich verwende tf 1.13 von Anaconda (ich bin nicht vertraut mit welchem ​​Branch & Build es ursprünglich gekommen wäre, sorry, aber vielleicht sind dies genug Informationen für Sie?).

$ 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

Link zum Anaconda-Paket: https://anaconda.org/anaconda/tensorflow-gpu

Dann sollte ich mir keine Sorgen machen (vollständiger Kontext: In der letzten Woche gab es einige Fehler beim Import aufgrund einiger Änderungen, die ich vorgenommen habe; aber diese betreffen nur den Mastercode, was nicht der Fall zu sein scheint)

Warnungen zu veralteten Versionen sind für Entwickler wichtig. Sie sind für Benutzer möglicherweise nicht allzu nützlich. Daher gibt es Situationen, in denen es wünschenswert ist, sie auszuschalten.

Python hat sys.warnoptions was zum Beispiel über PYTHONWARNINGS , zB:
PYTHONWARNINGS=ignore .

TensorFlow hat seine eigene Option TF_CPP_MIN_LOG_LEVEL wie bereits erwähnt.

Und es gibt auch die TensorFlow Python-Logging-API (von der ich glaubte, dass sie zuvor funktioniert hat):

import tensorflow as tf

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

Dass keine der oben genannten Optionen das Drucken der Warnmeldungen verhindert, scheint ein Fehler zu sein.

Das Flag _PRINT_DEPRECATION_WARNINGS scheint intern zu sein und kann jederzeit entfernt werden.

EDIT: Entschuldigung, ich habe die numpy FuturreWarning s mit Tensorflow-Warnungen verwechselt. Die letzte Option zum Einstellen des Logging-Levels sollte im Allgemeinen noch funktionieren.

Auf 1.14.0 funktioniert nur das:

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

Versuchen Sie für r1.14 und höher Folgendes:

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

Wie auch immer, es ist intern und kann sich ändern.

Oder wechseln Sie zu TF2.0, wo Warnungen zu veralteten Versionen entfernt werden (sofern nicht benötigt).

Es sei denn, Sie verwenden eine gute Auswahl an IDEs: p
Das einzige, was mich zum Rollback veranlasste, war das Problem der automatischen Vervollständigung, sodass diese Unterdrückungsanforderungen imo gültig sind.

Autovervollständigung wurde größtenteils gelöst

Habe alles ausprobiert, was vorgeschlagen wurde:

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

Trotzdem einen Haufen Warnungen.

/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
Python 3.6.8

@pyotr777 Für Python-integrierte Warnungen sollten Sie Folgendes verwenden, um Folgendes zu unterdrücken:

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

@pyotr777 die kommen von numpy. Sie verwenden eine numpy-Version, die mit der von Ihnen verwendeten TF-Version leicht inkompatibel ist.

Auf die Gefahr hin, mehr Downvotes zu erhalten, wechseln Sie bitte zu 2.0

Zukunftswarnung

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

hat nicht unterdrückt

/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)])

Bei mir hat das für die t2.0-Warnung funktioniert

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

Zu Ihrer Information Die Protokollierung in TensorFlow wurde geändert, da TF_CPP_MIN_LOG_LEVEL nicht mehr funktioniert

Trotzdem einen Haufen Warnungen.

/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:516: FutureWarning: Die Übergabe von (type, 1) oder '1type' als Synonym für type ist veraltet; in einer zukünftigen Version von numpy wird es als (type, (1,)) / '(1,)type' verstanden.
_np_qint8 = np.dtype([("qint8", np.int8, 1)])
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/dtypes.py:517: FutureWarning: Die Übergabe von (type, 1) oder '1type' als Synonym für type ist veraltet; in einer zukünftigen Version von numpy wird es als (type, (1,)) / '(1,)type' verstanden.
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])

Bitte versuchen Sie nacheinander, die 1 in 0 zu ändern, zB: _np_qint8 = np.dtype([("qint8", np.int8, 1)]) to _np_qint8 = np.dtype([("qint8", np.int8 , 0)]) das funktioniert bei mir

solve warnings

Sie verwenden eine numpy-Version, die mit der von Ihnen verwendeten TF-Version leicht inkompatibel ist.

Bei mir hat das Putten funktioniert

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

Vor

import tensorflow as tf

und alle anderen Importe.

Ich habe TF 1.14.0 und numpy 1.18.1.

Bevor Sie tensorflow importieren, sollten Sie Folgendes implementieren:
Importwarnungen
warnings.filterwarnings('ignore',category=FutureWarning)
warnings.filterwarnings('ignore', category=DeprecationWarning)
es funktioniert für tensorflow = = 1.12.0, numpy = = 1.18.1, Python 3.6

Ich habe das versucht:

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

Und es hat bei mir nicht funktioniert, als ich Python nicht interaktiv ausführte tensorflow==1.14.0 , numpy==1.18.1 , python==3.6.10 , aber es funktionierte in einer interaktiven Sitzung.

Ich habe festgestellt, dass das Folgende funktioniert, wenn ich Python sowohl interaktiv als auch nicht interaktiv ausführe. Wenn Sie tensorflow 2.X verwenden, können Sie Folgendes verwenden:

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

Und bei Verwendung von tensorflow 1.X (hat bei mir an 1.14 gearbeitet):

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

Ich verwende tf 1.13.1
Das funktioniert:

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

.compat.v1 ist nicht erforderlich.

Ich habe alle Methoden ausprobiert, aber keine davon hat im Jupyter-Notebook funktioniert ...

warnings.filterwarnings('ignore',category=FutureWarning)
Dies kann Warnungen beim Importieren von Tensorflow ignorieren, aber es gibt immer noch viele viele viele WARN, wenn ich das Modell lade ...

War diese Seite hilfreich?
0 / 5 - 0 Bewertungen