numpy 썸네일형 리스트형 00. numpy로 구현한 경사하강법 코드 흐름 def get_cost(y, y_pred): N = len(y) cost = np.sum(np.square(y - y_pred))/N return costdef get_weight_updates(w1, w0, X, y, learning_rate=0.01): N = len(y) w1_update = np.zeros_like(w1) w0_update = np.zeros_like(w0) y_pred = np.dot(X, w1.T) + w0 diff = y - y_pred w0_factors = np.ones((N, 1)) w1_update = -(2/N)*learning_rate*(np.dot(X.T, diff)) w0_update = .. 더보기 이전 1 다음