목록머신러닝 (3)
함께 배워가는 학생개발자
MNIST 0 ~ 9 손글씨 데이터를 이용하여 인식률을 확인하고 그래프를 나타내는 프로그램주석으로 코드 설명했으니 참고하시기 바랍니다.import tensorflow as tf import matplotlib.pyplot as plt import random from tensorflow.examples.tutorials.mnist import input_data # data를 mnist 변수에 대입 # one_hot mnist = input_data.read_data_sets("MNIST_data/", one_hot = True) # classes가 10 -> 인식 할 숫자가 0 ~ 9 nb_classes = 10 # X, Y 생성 (?, 784) (?, 10) # 784는 픽셀 개수 (28 by 28)..
정규화(Normalization)아무리 learning_rate를 적절한 값을 넣어도 Input 데이터의 차이가 크다면 제대로 학습이 되지 않는다.이럴때는 정규화(Normalization)를 통해 값을 바꿔야 한다. 정규화 함수 중 하나인 MinMaxScaler() 함수 예시def MinMaxScaler(data): numerator = data - np.min(data, 0) denominator = np.max(data, 0) - np.min(data, 0) # noise term prevents the zero division return numerator / (denominator + 1e-7)xy = np.array([[828.659973, 833.450012, 908100, 828.349976..
Softmax Function 식 : tensorflow 코드 : * cost 식 직접 구할 때hypothesis = tf.nn.softmax(tf.matmul(X,W)+b)cost = tf.reduce_mean(-tf.reduce_sum(Y * tf.log(hypothesis), axis = 1)optimizer = tf.train.GradientDescentOptimizer(learning_rate = 0.1).minimize(cost) * cost cross_entropy_with_logits 함수 사용할 때Y_one_hot = tf.one_hot(Y, nb_classes) # shape = (?, 1, 7)Y_one_hot = tf.reshape(Y_one_hot, [-1, nb_classes])..