AttributeError:モジュール 'tensorflow'には属性 'reset_default_graph'がありません



Attributeerror Moduletensorflowhas No Attributereset_default_graph



AttributeError:モジュール 'tensorflow'には属性 'reset_default_graph'がありません

環境構成:

python3.7
tensorflow2.0
ウィンドウ10



初期コード:

tf.reset_default_graph()

実行エラー:



画像

解決:

import tensorflow as tf tf.compat.v1.reset_default_graph()

またはこのようなもの:



import tensorflow.compat.v1 as tf tf.reset_default_graph()