0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Tensorflow】Tensorflowの古いコードを最新の環境でビルドする方法

0
Last updated at Posted at 2026-08-01

1.目的

TesorFlowの最新の環境下で2.0未満のAPIで作ったコードを動かす方法を備忘録として記載します。

例としては、placeholderやsessionなどです。

2.対策

対策として、下記コードに書き換えてください。

最新のTensorflow環境でTensorFlow2.0未満の関数を使ったコードを書く方法

# 最新のtensorflowのAPIを使用する場合
# import tensorflow as tf
# と書きますが、2.0未満のAPIを使う場合は、tfを以下のように定義します。
import tensorflow.compat.v1 as tf

# eager exception対策
tf.disable_eager_execution()

この2行を書くだけで、解決します。

同じ問題で困っている方がいらっしゃったら、参考になれば幸いです。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?