Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 경사 하강법 실습 오류 수정 (코드 4-1, p.79-80) #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions deeplearning/deeplearning_class/03_Linear_Regression.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@
"\n",
"#경사 하강법을 시작합니다.\n",
"for i in range(epochs): # epoch 수 만큼 반복\n",
" y_hat = a * x_data + b #y를 구하는 식을 세웁니다\n",
" error = y_data - y_hat #오차를 구하는 식입니다.\n",
" y_pred = a * x_data + b #y를 구하는 식을 세웁니다\n",
" error = y_data - y_pred #오차를 구하는 식입니다.\n",
" a_diff = -(1/len(x_data)) * sum(x_data * (error)) # 오차함수를 a로 미분한 값입니다. \n",
" b_diff = -(1/len(x_data)) * sum(error) # 오차함수를 b로 미분한 값입니다. \n",
" a = a - lr * a_new # 학습률을 곱해 기존의 a값을 업데이트합니다.\n",
" b = b - lr * b_new # 학습률을 곱해 기존의 b값을 업데이트합니다.\n",
" a = a - lr * a_diff # 학습률을 곱해 기존의 a값을 업데이트합니다.\n",
" b = b - lr * b_diff # 학습률을 곱해 기존의 b값을 업데이트합니다.\n",
" if i % 100 == 0: # 100번 반복될 때마다 현재의 a값, b값을 출력합니다.\n",
" print(\"epoch=%.f, 기울기=%.04f, 절편=%.04f\" % (i, a, b))"
]
Expand Down