AI학교

placeholder 본문

STUDY

placeholder

ai-world.tistory.com 2019. 12. 10. 17:27

 

 

import tensorflow as tf

텐서플로를 사용하기 위해 import해줍니다.

 

mathScore = [85, 99, 84, 97, 92]
englishScore = [59, 80, 84, 68, 77]

mathScores에 5명의 수학 점수를 입력해줍니다.

englishscore에 5명의 영어 점수를 입력해줍니다.


a = tf.placeholder(dtype=tf.float32)
b = tf.placeholder(dtype=tf.float32)

placeholder라는 그릇을 a, b 로 두개 만들어 줍니다.


y = (a + b) / 2 

y라는 평균값을 만들어줍니다.


sess = tf.Session()

session을 설정해주고


init = tf.global_variables_initializer()
sess.run(init)  

초기값을 설정해줍니다.

 

sess.run(y, feed_dict={a: mathScore, b: englishScore})

a에는 수학 성적이, b에는 영어 성적이 들어가도록 설정해줍니다.

그럼 각 사람의 평균값이 나옵니다.

 

'STUDY' 카테고리의 다른 글

K-평균 클러스터링 ( K-means)  (0) 2019.12.12
텐서플로-세션  (0) 2019.12.12
텐서플로 기본 함수  (0) 2019.12.10
상수와 변수  (0) 2019.12.10
경사하강법 연습  (0) 2019.12.10
Comments