본문 바로가기
반응형

Study/Machine&Deep Learning17

[ML] TensorFlow로 파일에서 데이터 읽어오기 우선 파일을 읽어오는 소스는 다음과 같다. file_input_linear_regression.py12345678910111213141516171819202122232425262728293031323334# Lab 4 Multi-variable linear regressionimport tensorflow as tfimport numpy as npxy = np.loadtxt('data-01-test-score.csv', delimiter=',', dtype=np.float32)x_data = xy[:, 0:-1]y_data = xy[:, [-1]]# placeholders for a tensor that will be always fed.X = tf.placeholder(tf.float32, shape=.. 2018. 5. 16.
[ML] multi-variable linear regression multi-variable linear regression x의 값이 여러개이면 위와 같이 여러번 곱해주면 된다. 하지만 단점이 있다. 값이 100, 1000 ... 너무 많아지면 연산이 매우 복잡해진다. 우리는 이러한 문제를 Matrix를 이용하여 해결할 수 있다. 기본 원리는 아래와 같다. Matrix를 사용하면 n개를 편하게 연산할 수 있다. ※ 주의사항tensorflow 계산할 때는 H(x) = XW로 해주자! tensorflow 소스 1234567891011121314151617181920212223242526272829303132333435363738394041# Lab 4 Multi-variable linear regressionimport tensorflow as tf x1_data = [.. 2018. 5. 8.
[ML] Linear Regression의 cost 최소화 cost를 미분 minimzing_cost_gradient_update.py1234567891011121314151617181920212223242526272829import tensorflow as tf x_data = [1, 2, 3]y_data = [1, 2, 3] W = tf.Variable(tf.random_normal([1]), name='weight')X = tf.placeholder(tf.float32)Y = tf.placeholder(tf.float32) # Our hypothesis for linear model X * Whypothesis = X * W # cost/loss functioncost = tf.reduce_mean(tf.square(hypothesis - Y)) # Min.. 2018. 5. 8.
[ML] Linear Regression의 Hypothesis와 cost tf.Variable : tensorflow가 자체적으로 변경시키는 variable, trainable 한 variable. reduce_mean : 평균을 내줌ex) t = [1, 2, 3, 4] tf.reduce_mean(t) ==> 2.5 linear_regression.py 123456789101112131415161718192021222324252627282930313233# Lab 2 Linear Regression import tensorflow as tf # X and Y datax_train = [1, 2, 3]y_train = [1, 2, 3] # H(x) = Wx + bW = tf.Variable(tf.random_normal([1]), name = 'weight')b = tf.Var.. 2018. 5. 4.
[ML] 기본적인 Machine Learning의 용어와 개념 What is ML? - 개발자들이 일일이 프로그래밍 하지말고 어떤 자료 또는 현상에서 자동으로 배우면 어떨까? - 개발자가 일일이 정하지 않고 이 프로그램 자체가 어떤 데이터를 보고 학습해서 무언가를 배우는 능력을 가지는 것이 머신러닝이다. Supervised / Unsupervised learniang ● Supervised Learning - learning with labeled examples - training set - Most common problem type in ML -> Image labeling : learning from tagged images -> Email spam filter : learning from labeled (spam or ham) email -> Predict.. 2018. 5. 4.
반응형