티스토리 뷰

TensorFlow Softmax

 - softmax 함수는 logits 또는 logit score라고 하는 입력을 0에서 1사이 값으로 채우고

 - 그 모든 logits의 합이 1이 되도록 output을 정규화 한다.

 - 즉, softmax 함수의 출력은 범주형 확률분포(categorical probability distribution)와 같다. 

 - 이 softmax 함수는 다중 클래스들을 예측할 때 output activation으로 사용하기 적절하다.




 - 텐서플로우를 사용하여 softmax 함수를 쓰려면 다음과 같이 해주면 된다.

 - tf.nn.softmax() 함수는 logits을 받아서 softmax activation을 리턴해준다.




<quiz.py>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
import tensorflow as tf
 
 
def run():
    output = None
    logit_data = [2.01.00.1]
    logits = tf.placeholder(tf.float32)
 
    softmax = tf.nn.softmax(logits)
 
    with tf.Session() as sess:
        output = sess.run(softmax, feed_dict={logits: logit_data})
 
    return output



cs

>>

참고_)

 - 텐서플로우 프로그래밍의 3단계 : Graph Build → Graph Run(세션을 통해) → Update Variable / Return Value

 - tf.placeholder() : 그래프를 실행시키기 전 값을 할당하게 도와줌

 - 또한 tf.placeholder를 통해 노드를 만들경우 feed_dict라는 키워드를 사용하여야 함

 - feed_dict는 dictionary 형태로 값을 넘겨주기 위한 인자 키워드이다.

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함