2. 이름 : 장훈
나이 : 30세(1988-06-16)
이메일 : lunawyrd@gmail.com
블로그 : http://devhoon.tistory.com
Github : https://github.com/jang-hoon
[주요경력]
2016.08 ~ 현재 (주)EXEM, WAS 및 Web Server 모니터링 프로그램(APM) 개발
2015.09 ~ 2016.03 (주)두꺼비세상, 두꺼비세상 Android 앱 개발 및 Spring
Boot를 이용한 REST, Batch, Gateway 서버 개발
2015.04 ~ 2015.08 (주)옐로쇼핑미디어, 쿠차 Android 앱 개발
2009.12 ~ 2013.02 (주)아이콘랩, Android 및 BlackBerry 앱 개발,
산업기능요원 대체복무
13. Hypothesis설정
import tensorflow as tf
# 학습 데이터
x_data = [1, 2, 3]
y_data = [1, 2, 3]
W = tf.Variable(tf.random_uniform([1], -1.0, 1.0))
b = tf.Variable(tf.random_uniform([1], -1.0, 1.0))
X = tf.placeholder(tf.float32)
Y = tf.placeholder(tf.float32)
# 가설 Y_ = WX + b
hypothesis = W * X + b
14. 비용함수와오차보정
# 비용함수 cost = 평균( (Y_ - Y)^2 )
cost = tf.reduce_mean(tf.square(hypothesis - Y))
# cost를 줄이는 방향으로 W, b를 수정하기 위한 경사하강법
a = tf.Variable(0.1) # Learning rate, alpha
optimizer = tf.train.GradientDescentOptimizer(a)
train = optimizer.minimize(cost)
15. TensorFlow실행을통해학습
init = tf.initialize_all_variables()
sess = tf.Session()
sess.run(init)
# 학습
for step in range(2001):
# hypothesis = W * X + b
# cost = tf.reduce_mean(tf.square(hypothesis - Y))
# train = tf.train.GradientDescentOptimizer(0.1).minimize(cost)
sess.run(train, feed_dict={X: x_data, Y: y_data})
if step % 20 == 0:
print(step, sess.run(cost, feed_dict={X: x_data, Y: y_data}), sess.run(W),
16. 학습된모델을테스트
# Hypothesis 테스트, hypothesis = W * X + b
print(sess.run(hypothesis, feed_dict={X: 5}))
print(sess.run(hypothesis, feed_dict={X: 2.5}))
32. Sampleload및초기화
from tensorflow.examples.tutorials.mnist import input_data
import tensorflow as tf
import numpy as np
#학습 데이터 로드
mnist = input_data.read_data_sets("MNIST__data/", one_hot=True)
x = tf.placeholder("float", [None, 784]) # [?] x [784]
y = tf.placeholder("float", [None, 10]) # [?] x [10]
W = tf.Variable(tf.zeros([784, 10])) # [784] x [10]
b = tf.Variable(tf.zeros([10])) # [10]
33. Softmax와비용함수,오차보정
# y_ = softmax(Wx + b)
y_ = tf.nn.softmax(tf.matmul(x, W) + b)
# cost = -∑(y * log(y_)
cross_entropy = -tf.reduce_sum(y * tf.log(y_))
# cost를 줄이는 방향으로 W, b를 수정하기 위한 경사하강법
train_step = tf.train.GradientDescentOptimizer(0.01).minimize(cross_entropy)