2024-01-03

Google TensorFlowバージョン2 の公式チュートリアルをすすめるメモ(1)
続きです。
●映画レビューのテキスト分類
https://www.tensorflow.org/tutorials/keras/text_classification?hl=ja
★出現したエラー
<string>:6: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray /usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/datasets/imdb.py:159: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray x_train, y_train = np.array(xs[:idx]), np.array(labels[:idx]) /usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/datasets/imdb.py:160: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray x_test, y_test = np.array(xs[idx:]), np.array(labels[idx:]) </string>
★解決法
Warningであるため以後の実行に支障は無かったのでそのままとした。
●TensorFlowハブによるテキスト分類:映画レビュー
https://www.tensorflow.org/tutorials/keras/text_classification_with_hub?hl=ja
★追加モジュールのインストール
sudo pip3 install tfds-nightly sudo pip3 install tensorflow-hub
★出現したエラー:なし
●回帰:燃費を予測する
https://www.tensorflow.org/tutorials/keras/regression?hl=ja
★追加モジュールのインストール
sudo pip3 install seaborn
★出現したエラー:なし
●過学習と学習不足について知る
https://www.tensorflow.org/tutorials/keras/overfit_and_underfit?hl=ja
★出現したエラー
<string>:6: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray /usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/datasets/imdb.py:159: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray x_train, y_train = np.array(xs[:idx]), np.array(labels[:idx]) /usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/datasets/imdb.py:160: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray x_test, y_test = np.array(xs[idx:]), np.array(labels[idx:]) </string>
★解決法
Warningであるため以後の実行に支障は無かったのでそのままとした。
しかしながらこの章のサンプルの「より小さいモデルの構築~より大きなモデルの構築」のところで、しばしばNotebookのフリーズ&リスタートが見られた。
いったんCtrl-Cでノートブックを終了し、ブラウザを閉じ、ノートブックを再起動してまた1から実行し直したら、問題無くなった。
●モデルの保存と復元
https://www.tensorflow.org/tutorials/keras/save_and_load?hl=ja
★追加モジュールのインストール
sudo pip3 install pyyaml h5py
★出現したエラー
# my_model ディレクトリ
ls saved_model
# assets フォルダと saved_model.pb, variables フォルダが含まれる
ls saved_model/my_model
File "<ipython-input-15-017179a2f945>", line 2
ls saved_model
^
SyntaxError: invalid syntax
</ipython-input-15-017179a2f945>
★解決法
# my_model ディレクトリ %ls saved_model # assets フォルダと saved_model.pb, variables フォルダが含まれる %ls saved_model/my_model
OSコマンドには%を付与する。このへんはColab Notebookとの違いか。
●Kerasチューナーの紹介
https://www.tensorflow.org/tutorials/keras/keras_tuner?hl=ja
★追加モジュールのインストール
sudo pip3 install keras-tuner
★出現したエラー
特に無し。最後の「ハイパーパラメータ検索を実行」が時間がかかり画面上無限ループ出力のように見えるが、待っていればちゃんと終わる。
※本記事内容の無断転載を禁じます。
ご連絡は以下アドレスまでお願いします★
CUDA13環境下でGPU使用版のllama-cpp-pythonを導入する
CUDA13環境下でGPU使用版のPyTorchを導入する
LetsEncrypt/certbotの証明書自動更新がエラーになる場合
Wav2Lipのオープンソース版を改造して外部から呼べるAPI化する
Wav2Lipのオープンソース版で静止画の口元のみを動かして喋らせる
【iOS】アプリアイコン・ロゴ画像の作成・設定方法
オープンソースリップシンクエンジンSadTalkerをAPI化してアプリから呼ぶ【2】
オープンソースリップシンクエンジンSadTalkerをAPI化してアプリから呼ぶ【1】
【Xcode】iPhone is not available because it is unpairedの対処法
CUDA13環境下でGPU使用版のPyTorchを導入する
Windows11+WSL2でUbuntuを使う【2】ブリッジ接続+固定IPの設定
【Windows10】リモートデスクトップ間のコピー&ペーストができなくなった場合の対処法
LinuxからWindowsの共有フォルダをマウントする
【PHP】Mail/mimeDecodeを使ってメールの中身を解析(準備編)
PHPでメールの中身をフルに分解して出力する(日本語&添付ファイル対応)
VirtualBoxの仮想マシンをWindows起動時に自動起動し終了時に自動サスペンドする
【ウマ娘】デイリーレースに雨の状態で出走するには
GitLabにHTTPS経由でリポジトリをクローン&読み書きを行う