Moglobin's
article thumbnail
Linear Regression and How to minimize cost 를 TensorFlow 로 구현하기
컴공 2021. 1. 26. 21:35

- 선형회귀(Linear Regression)의 비용을 최소화하는 방법을 코드로 알아보자. - 선형회귀(Linear Regression), 가설(Hypothesis), 비용함수(Cost function), 경사하강법(Gradient Descent), 블록함수(Convex function) 편차 제곱의 평균이 cost이다. cost 함수를 파이썬으로 구현해보자. W 값의 -3 부터 5 까지 15 구간으로 쪼개 이에 대응하는 cost 값을 보면 값이 감소하다 다시 증가하는 것을 볼 수 있다. Gradient descent 도 Tensorflow 코드로 옮겨보면 위와 같다. descent 가 새로운 W 값. Gradient descent 식을 추가하여 코드 구현. random_seed 초기화. 결과를 출력하면..

article thumbnail
Linear Regression and How to minimize cost
컴공 2021. 1. 25. 23:55

학습목표: 선형회귀(Linear Regression)의 비용을 최소화하는 방법을 알아본다. 핵심키워드: 선형회귀(Linear Regression), 가설(Hypothesis), 비용함수(Cost Function), 경사 하강법(Gradient Descent), 블록 함수(Convex function) 복습. 우리의 가설(H(x))과 실제 데이터(y)의 차이의 제곱한 값을 데이터 전체 개수(m)로 나눠서 계산. 에러 제곱의 평균이라고 말함. cost 값이 작아야 실제를 잘 반영한다고 볼 수 있음. 간략화된 버전. b가 생략. b 는 나중에 W가 matrix 가 되면서 그 안으로 들어감. 간단한 예제를 통해 cost 가 W 의 값에 따라 어떻게 변화하는지 알아보자. 더 촘촘하게 값을 대입해보면 cost 가 ..

article thumbnail
Simple Linear Regression 를 TensorFlow 로 구현하기
컴공 2021. 1. 25. 18:35

목표: 선형회귀(Linear Regression)를 코드로 구현한다, 핵심키워드: 선형회귀(Linear Regression), 가설(Hypothesis), 비용함수(Cost Function) Cost-> 에러 제곱의 평균값 텐서플로우 내장 함수 reduce_mean() -> 랭크를 하나 줄이고 평균 구하기 square()-> 제곱값 구하기 - 경사하강법 GradientTape() 함수로 구현. 변수들(w, b)에 대한 정보를 tape 에 기록. tape.gradient 로 경사도(미분값)을 구함. assign_sub 로 해당 연산 수행 텐서플로우 import 하고, tf.enable_eager_execution 활성화로 즉시 실행 가능하게 x_data, y_data 준비 변수 W(기울기), b(절편) 선..

article thumbnail
Simple Linear Regression
컴공 2021. 1. 25. 15:14

학습목표 선형회귀(Linear Regression)의 개념에 대해 알아본다. 핵심키워드 -Regression -Linear Regression (선형회귀) -Hypothesis (가설) -Which hypothesis is better? -Cost, Cost function (비용과 비용함수) -Goal: Minimize cost (목표: 비용 최소화) Regression : 후퇴, 퇴보, 되돌아가다 ML 에서의 Regression => "Regression towards the mean" 전체 평균을 향한 회귀 데이터를 가장 잘 대변하는 직선의 방정식을 찾는 것. 기울기와 y 절편을 알아내는 것. ex) regression 을 통한 시험 점수 예측 가설함수는 H(x). 빨간 선들의 총 합이 작으면 작을..

article thumbnail
[C++] 포인터(Pointers) (1)
컴공 2021. 1. 20. 11:19

Pointers In earlier chapters, variables have been explained as locations in the computer's memory which can be accessed by their identifier (their name). This way, the program does not need to care about the physical address of the data in memory; it simply uses the identifier whenever it needs to refer to the variable. 앞의 챕터들에서, 변수들은 그들의 식별자(지정한 이름)에 의해 열람이 가능한 컴퓨터 메모리 상의 위치로 설명되었다. 이 방법으로, 프로그..