Deep Learning

Deep Learning

Kerasでのload_modelでエラー ValueError: Cannot create group in read-only mode.

ModelCheckpointで保存した重みを tensorflow.keras.models.load_model で読み込むと表題のエラー。ModelCheckpoint の save_weight_only = True にしていたの...
Deep Learning

KerasでエラーUnboundLocalError: local variable ‘logs’ referenced before assignment

tensorflow.kerasでmodel.fit()を実行した時に表題のエラー。(中略)in fit epoch_logs = copy.copy(logs) UnboundLocalError: local variable 'log...
Deep Learning

stringのTFRecordを作る時にTypeError

猫の画像とラベルを含んだTFRecordを作ろうとして表題のエラー。TypeError: 'cat' has type str, but expected one of: bytes使ったコードは公式チュートリアルに記載のもの。def _b...
Deep Learning

Kerasでval_acc、val_auc、val_lossが同じ値のまま更新されない

Tensorflow.kerasでDensenetとMobileNetを使っていた時のこと。accやauc、lossは更新されるが、val_aucが0.5000のまま一切更新されず、val_accやval_lossも同じ値を取り続けていた。...
Deep Learning

KerasでRuntimeError: The name is used 2 times in the model.All layer names should be unique

Kerasで同じモデルを複数使った時に表題のエラー。model1 = vgg16.VGG16(...)model2 = vgg16.VGG16(...)みたいなコードを書いていたら、RuntimeError: The name is use...
Deep Learning

TensowflowでFP16をいい感じに使って自動で高速化してくれるAutomatic Mixed Precision

NVIDIA RTXシリーズのGPUはTensor Coreを搭載しており、FP16で計算することでFP32よりも計算量を落とし、ディープラーニングにかかる時間を短くしてくれる。ただし、FP16にしてもいいレイヤーとFP32の方がいいレイヤ...
Deep Learning

StyleGAN2でInvalid argument: input depth must be evenly divisible by filter depth: 1 vs 3

StyleGAN2の学習中に表記エラー。1 vs 3 が何なのか調べてもさっぱりわからなかった。全く関係ない別のことを調べていた時に、もしかしてチャンネル数なのではとひらめき、データセットを確認したところグレースケールの画像を学習させようと...
Deep Learning

StyleGAN2でエラーint() argument must be a string, a bytes-like object or a number, not ‘Tensor’

上記リポジトリからcloneしたStyleGAN2を実行した時にエラーが発生。int() argument must be a string, a bytes-like object or a number, not 'Tensor'エラー...
Deep Learning

Kerasでカテゴリ変数をEntity Embeddingする時の次元数

画像とカテゴリのデータがあって、その両方をmodelに入力したくなった時にカテゴリ変数の扱いがわからなかった。テキストのディープラーニングで使われるEmbeddingがカテゴリ変数にも有効らしいので試してみた所、次元数を決めあぐねていたので...
Deep Learning

Kerasのmodel.fitが返すhistoryをpandasで保存して図のplotまで

model.fit() や model.fit_generator() はコールバックのHistoryを返す。これを保存しておくとエポック毎のAccuracyやLossの推移が見れて面白いので、生データの保存と可視化を行いたい。# 生データ...