본문 바로가기

linear regression

Multi Variables Linear Regression을 Tensor Flow 에서 구현하기 Multi Variables 을 이용한 Linear Regression 을 학습하고자 한다.이전에 알아본 Single Variable Linear Regression 에서 여러개의 변수가 추가되었을 때 보다 실용적인 결과값을 구현할 수 있을 것이다.x1, x2, x3 이렇게 3개의 instances의 값을 가지고 보다 더 cost function 값을 줄인 결과값을 얻고자 할 때의 코딩이다. 위의 코드를 실행하면 아래와 같은 결과 값을 얻을 수 있다. 처음 부분과 마지막 부분만을 캡쳐하여 올려둔다. 그러나, 여기서 문제점은, 위와 같은 형태에서는 instance와 data 값이 늘어나면 코드가 지저분해 진다는 데 있다. 이를 수학적(?)으로 보다 깔끔하게 하기 위해서는 아래와 같은 Matrix(행렬 or.. 더보기
TensorFlow Linear Regression with place holder As we studied before, we can use 'placeholder' as a source of input value. So, I changed the source code uploaded on this blog with placeholder. You might know the differences if you check on here.import tensorflow as tf # X and Y data #x_train = [1,2,3] #y_train = [1,2,3] W = tf.Variable(tf.random_normal([1]), name = 'weight') b = tf.Variable(tf.random_normal([1]), name = 'bias') X = tf.placeho.. 더보기
Linear Regression Ex1 H(x) = wx + b 의 Linear Regression example code import tensorflow as tf # X and Y data x_train = [1,2,3] y_train = [1,2,3] W = tf.Variable(tf.random_normal([1]), name = 'weight') b = tf.Variable(tf.random_normal([1]), name = 'bias') # Our hypothesis XW + b hypothesis = x_train * W + b # cost/Loss function cost = tf.reduce_mean(tf.square(hypothesis - y_train)) # Minimize optimizer = tf.train.Gradi.. 더보기