본문 바로가기

분류 전체보기25

04-2. Tensor Flow 에서 csv 파일 읽기 및 queue 사용법 04-2. Loading Data from File 출처 : 모두를위한 머신러닝 (http://hunkim.github.io/ml/) Data manipulate using Numpy¶List Slicing¶Numpy Indexing In [18]: import numpy as np import pandas as pd xy = np.loadtxt('static/data-01-test-score.csv', delimiter=',', dtype=np.float32) x_data = xy[:, 0:-1] y_data = xy[:, [-1]] print(x_data) print(y_data) [[ 73. 80. 75.] [ 93. 88. 93.] [ 89. 91. 90.] [ 96. 98. 100.] [ 73... 2018. 8. 17.
04-1. Tensor Flow 변수가 여러개일때 Linear regression 04-1. Multi-variable Linear Regression 출처 : 모두를위한 머신러닝 (http://hunkim.github.io/ml/) 이론 변수가 여러개일때는 Matrix 를 이용¶ Matrix 사용 안한 코드¶ In [9]: import tensorflow as tf x1_data = [73., 93., 89., 96., 73.] x2_data = [80., 88., 91., 98., 66.] x3_data = [75., 93., 90., 100., 70.] y_data = [152., 185., 180., 196., 142.] x1 = tf.placeholder(tf.float32) x2 = tf.placeholder(tf.float32) x3 = tf.placeholder(tf.f.. 2018. 8. 17.
03. TensorFlow Linear Regression 의 cost 최소화 구현 03. Minimizing Cost Function in Linear Regression 출처 : 모두를위한 머신러닝 (http://hunkim.github.io/ml/) 이론 간소화 한 Hypothesis¶ W, cost(W) 스캔 해보기¶ In [9]: import tensorflow as tf import matplotlib.pyplot as plt X = [1, 2, 3] Y = [1, 2, 3] # W 는 계속 바뀌므로 place holder 로 W = tf.placeholder(tf.float32) hypothesis = X * W # H(x) = Wx cost = tf.reduce_mean(tf.square(hypothesis - Y)) # cost function sess = tf.Sess.. 2018. 8. 17.
02. Tensor Flow로 linear regression 예제 02. Linear Regression 의 개념 출처 : 모두를위한 머신러닝 (http://hunkim.github.io/ml/)이론 예제Hypothesis and cost function¶ 학슴을 통해 cost function 을 최소화 하는 W, b 를 찾아야 함. Build graph¶ In [1]: import tensorflow as tf x_train = [1, 2, 3] y_train = [1, 2, 3] # Variable : Tensorflow 가 사용하는 변수 # Training 과정중에서 변함 W = tf.Variable(tf.random_normal([1]), name='weight') # rank 가 1인 random 값 b = tf.Variable(tf.random_normal(.. 2018. 8. 16.