0
0

More than 3 years have passed since last update.

tensorflow.python.framework.errors_impl.FailedPreconditionErrorの発生と解決

Posted at

概要

Kerasで単純なGANを実行するとき、tensorflowのエラーに躓いたので、その備忘録

やりたかったこと

  • GANのサンプルコードを動かしみる
  • 参考にさせていただいたのは こちら

エラー内容

tensorflow.python.framework.errors_impl.FailedPreconditionError: Error while reading resource variable AnonymousVar44 from Container: localhost. This could mean that the variable was uninitialized. Not found: Resource localhost/_AnonymousVar44/class tensorflow::Var does not exist.
[[node mul_28/ReadVariableOp (defined at C:\Python\envs\virtualenv001\lib\site-packages\keras\backend\tensorflow_backend.py:3009) ]] [Op:
_inference_keras_scratch_graph_2136]

Function call stack:
keras_scratch_graph

理由

どうもtensorflowの変数初期化エラーらしい(参考
どの変数で初期化エラー起こっているかがよく分からなかったけど、ここで解決方法を発見
※エラーの原因は不明

対策

  • optimizerはkerasではなく、tensorflowを使う。(from tensorflow.keras.optimizers import Adam)

もしエラーの原因が分かる方がいたらコメントいただけますと幸いです。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0