簡體   English   中英

Tensorflow contrib 學習棄用警告

[英]Tensorflow contrib learn deprecation warnings

當我在我的代碼中使用以下行時

vocab_processor = learn.preprocessing.VocabularyProcessor(max_document_length,詞匯=弓)

我收到論文警告。 我如何消除它們?

WARNING:tensorflow:From /usr/local/lib/python3.5/dist-packages/tensorflow/contrib/learn/python/learn/datasets/base.py:198: retry (from tensorflow.contrib.learn.python.learn.datasets.base) is deprecated and will be removed in a future version. Instructions for updating: Use the retry module or similar alternatives. WARNING:tensorflow:From /tmp/anyReader-376H566fJpAUSEt/anyReader-376qtSRQxT2gOiq.tmp:67: VocabularyProcessor.__init__ (from tensorflow.contrib.learn.python.learn.preprocessing.text) is deprecated and will be removed in a future version. Instructions for updating: Please use tensorflow/transform or tf.data. WARNING:tensorflow:From /usr/local/lib/python3.5/dist-packages/tensorflow/contrib/learn/python/learn/preprocessing/text.py:154: CategoricalVocabulary.__init__ (from tensorflow.contrib.learn.python.learn.preprocessing.categorical_vocabulary) is deprecated and will be removed in a future version. Instructions for updating: Please use tensorflow/transform or tf.data. WARNING:tensorflow:From /usr/local/lib/python3.5/dist-packages/tensorflow/contrib/learn/python/learn/preprocessing/text.py:170: tokenizer (from tensorflow.contrib.learn.python.learn.preprocessing.text) is deprecated and will be removed in a future version. Instructions for updating: Please use tensorflow/transform or tf.data.

沒有100%替換功能。 但是,有一些暗示方法可能有助於替換 vocab_processor() 的功能

1.compute_and_apply_vocabulary()

# Need to install tensorflow_transform with tf 2.3 
import tensorflow_transform as tft
review_indices = tft.compute_and_apply_vocabulary(review_tokens, top_k=VOCAB_SIZE)

參考代碼: https : //github.com/tensorflow/transform/blob/master/examples/sentiment_example.py

2.采用tensorflow.keras的預處理

from tensorflow.keras.preprocessing import text, sequence
x = tf.keraspreprocessing.sequence.pad_sequences(x, maxlen=max_document_length, padding='post', truncating='post')

參考: https : //github.com/dennybritz/cnn-text-classification-tf/issues/147

無論如何,想出一種方法來 100% 替換它並不容易。

所有這些警告都有更新說明。 按照說明:切換到 tf.data 進行預處理。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM