Softmax(2)
-
[신경망] 선형회귀로 분류가 불가능한 경우(XOR problem)
xdata = np.array([[0,0],[0,1],[1,0],[1,1]]) ydata = np.array([[0],[1],[1],[0]]) 텐서플로우 기반 단일 퍼셉트론 x = tf.placeholder(tf.float32, [None,2]) y = tf.placeholder(tf.float32, [None,1]) # 0~9 digit w = tf.Variable(tf.random_normal([2,1])) b = tf.Variable(tf.random_normal([1])) hf= tf.sigmoid(tf.matmul(x, w) + b) cost = -tf.reduce_mean(y * tf.log(hf) + (1 - y) * tf.log(1 - hf)) train = tf.train.Gradient..
2020.04.21 -
[텐서플로우] 소프트맥스 회귀 (Softmax Regression) 분류 파이썬 코드
예제 데이터 x_data = [[1, 2, 1, 1], [2, 1, 3, 2], [3, 1, 3, 4], [4, 1, 5, 5], [1, 7, 5, 5], [1, 2, 5, 6], [1, 6, 6, 6], [1, 7, 7, 7]] y_data = [[0, 0, 1], #원핫인코딩 상태 [0, 0, 1], [0, 0, 1], [0, 1, 0], [0, 1, 0], [0, 1, 0], [1, 0, 0], [1, 0, 0]] 변수정의 x= tf.placeholder("float",shape=[None,4]) y= tf.placeholder("float",shape=[None,3]) #3: 분류기의 갯수 (분류 결과 종료의 가짓수) nb_classes = 3 w=tf.Variable(tf.random_norma..
2020.04.20