λͺ¨λμ λ₯λ¬λ -νμ΄ν μΉ ch1-ch2 μ 리
λͺ¨λμ λ₯λ¬λ λ§ν¬ : https://www.youtube.com/watch?v=SKq-pmkekTk&list=PLbbloOsdWVwTNNkjnLuqEWtzjRqfBALF7
λͺ¨λμ λ₯λ¬λ ch1
μ¬λμ΄ κ²°μ μ νλ λ°©μ
data-> human -> infer or predict
μ»΄ν¨ν°μ λ°©μ νλκ² machine learning
data -> computer -> infer or predict
λͺ¨λμ λ₯λ¬λ ch2
'μλ λ°μ΄ν°λ x μκ° κ³΅λΆνμλ point λ₯Ό yλ§νΌ λ°λλ€' λ°μ΄ν°μ΄λ€.
supervised learning μ x-y μ²λΌ μ λ΅μ΄ μλ λ°μ΄ν°μ νμ΅μ λ§νλ€.
κ°μ₯ κΈ°λ³Έμ μΈ μ
yν·μ μΆμ κ°μ μλ―Ένλ€.
Wλ κ°μ€μΉλ‘, λλ€μΌλ‘ μμνμ¬, μ€μ κ°-μΆμ κ°μ ν¬κΈ°λ₯Ό μ€μ΄λ λ°©ν₯μΌλ‘ μ§νν΄μΌ νλ€.
μ€μ κ°-μΆμ κ°μ μ°¨μ΄λ₯Ό μ¬λ¬κ°μ§ κ°μΌλ‘ λνλΌμ μλ€(loss ν¨μμ μ’
λ₯κ° μ¬λ¬κ°μ§μ΄λ€.)
λ¨Έμ λ¬λμ goalμ μ€μ°¨κ° κ°μ₯μμ wλ₯Ό ꡬνλκ²
μ£Όμ΄μ§ λ°μ΄ν°μ μ μ€μ°¨λ₯Ό νκ· μ ꡬν΄μ, μ§κΈ μΌλ§νΌ μ€μ κ°κ³Ό λ¨μ΄μ Έ μλμ§λ₯Ό ꡬνλ€.
μλλ κ°μ€μΉμ μ€μ°¨μ μλ―Έλ₯Ό μ 보μ¬μ£Όλ μμμ½λμ΄λ€.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | import numpy as np import matplotlib.pyplot as plt x_data = [1.0,2.0,3.0] y_data = [2.0,4.0,6.0] w=1.0 def forward(x): return x*w def loss(x,y): y_pred = forward(x) return (y_pred-y) * (y_pred-y) w_list =[] mse_list =[] for w in np.arange(0.0,4.1,0.1):#0.0λΆν° 4.1κΉμ§ 0.1 κ°κ²©μΌλ‘ w μ¦κ° print ("w=",w) l_sum =0 for x_val, y_val in zip(x_data, y_data): y_pred_val = forward(x_val)#xμ κ°μ y_pred_valμ λ£μ΄μ forward l = loss(x_val, y_val) l_sum += l#wμ λ°λ₯Έ loss κ³μ° print("\t",x_val, y_val, y_pred_val, 1) print("MSE= ", l_sum / 3)#mse : νκ· μ κ³±κ·Ό μ€μ°¨ w_list.append(w) mse_list.append(l_sum/3) plt.plot(w_list, mse_list) plt.ylabel('loss') plt.xlabel('w') plt.show() | cs |
weightμ λ°λ₯Έ mse(νκ· μ κ³±μ€μ°¨) κ° μΆλ ₯λκ² ν΄ λ³΄μλ€.
2.0 μΌλ‘ κ°μλ‘ μ€μ°¨κ° μ€μ΄λλ μ΄μ°¨ν¨μκ° λμ€λ κ²μ λ³Ό μ μμλ€.