--- lang: ja-jp breaks: true --- # Python TesorFlow 「`model.predict_classes()` is deprecated」と警告が出力される。 2021-07-25 ## 環境 ```shell= python -V Python 3.8.10 ``` ```shell= pip list | find "Keras" Keras 2.4.3 Keras-Preprocessing 1.1.2 ``` ```shell= pip list | find "tensorflow" tensorflow 2.4.2 tensorflow-estimator 2.4.0 ``` ## 出力内容 ```shell= C:\Users\xxxx\anaconda3\envs\AI\lib\site-packages\tensorflow\python\keras\engine\sequential.py:450: UserWarning: `model.predict_classes()` is deprecated and will be removed after 2021-01-01. Please use instead:* `np.argmax(model.predict(x), axis=-1)`, if your model does multi-class classification (e.g. if it uses a `softmax` last-layer activation).* `(model.predict(x) > 0.5).astype("int32")`, if your model does binary classification (e.g. if it uses a `sigmoid` last-layer activation). warnings.warn('`model.predict_classes()` is deprecated and ' ``` UserWarning: `model.predict_classes()`は非推奨とマークされており、2021-01-01以降に削除されます。 代わりに以下をお使いください: * マルチクラス分類をモデルの場合(例:最後の層の活性化に`softmax`を使用する場合) * `result = np.argmax(model.predict(test_data), axis=-1)` * 二値分類を行うモデルの場合(例:最後の層の活性化に`sigmoid`を使用する場合) * `result = (model.predict(test_data) > 0.5).astype("int32")` ###### tags: `Python` `TesorFlow` `非推奨` `Keras`