⚒️ 코드 에러 모음집 ⚒️

[Tensorflow 오류] AttributeError: module 'tensorflow' has no attribute 'placeholder'

공대생 배기웅 2020. 7. 15. 19:38
반응형

https://better-coding.com/solved-attributeerror-module-tensorflow-has-no-attribute-placeholder/

 

[SOLVED] - AttributeError: module 'tensorflow' has no attribute 'placeholder'

The cause of the mentioned problem is incompatibile code with installed tensorflow library. In this case you have code compatible with tensorflow 1.0 version but installed tensorflow 2.0 or higher. Let's see what you can do to solve the problem.

better-coding.com

 

import tensorflow.compat.v1 as tf
x = tf.placeholder(shape=[None, 2], dtype=tf.float32)

 

tensorflow의 placeholder함수를 사용하다보면 아래와 같은 오류가 발생한다. 

 

 

이 문구를 추가해주면 해결이 된다. 

 

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
x = tf.placeholder(shape=[None, 2], dtype=tf.float32)
728x90
반응형