비정상적인 위치에 매개 변수 theta가있는 지정된 가설로 감독 된 학습 알고리즘을 실행하고 싶습니다. = theta1 * (EXP (theta2의 *를 X)) I는 다음과 같은 기능을 가진 구배 하강하여 시도 + theta0비정상적인 위치에 매개 변수 theta가있는 지정된 가설로 감독 된 학습 알고리즘을 실행하고 싶습니다.
Y :
번호 : compute_cost 내 비용
m = length(y);
num_iters = 500;
J_history = zeros(num_iters, 1);
alpha = 0.1;
theta = zeros(3, 1);
for q = 1:m
A(q,:) = [2, (2*exp(theta(3, 1) * X(q, 1))), (2*theta(2, 1)*X(q, 1)*exp(theta(3, 1) * X(q, 1)))];
end
for iter = 1:num_iters
num_theta = length(theta);
for j = 1:num_theta
inner_sum = 0;
for i = 1:m
inner_sum = inner_sum + (theta(2, 1)*(exp(X(i, 1)*theta(3, 1))) + theta(1, 1) - y(i, 1)) * A(i, j);
end
theta(j, 1) = theta(j, 1) - (alpha * inner_sum/m)
end
J_history(iter) = compute_cost(X, y);
end
% Save the cost J in every iteration
J_history(iter) = compute_cost(X, y);
end
인 기능은 다음과 같습니다 :
predictions = theta(2, 1)*(exp(X*theta(3, 1))) + theta(1, 1); %hypothesis
sqrErrors = (predictions - y).^2;
J = sum(sqrErrors)/(2*m);
이제 내 쎄 타로 틈이 생겼습니다. (3, 1) == theta의 초기 값을 0 (0, 1)이 될 때 0이 될 것입니다. 그리고 초기 초기 theta (3, 1) 일 때 무한의 값을가집니다.
선형 가설에이 가설을 사용할 수 있습니까? 아니면 현재의 가설 대신 사용할 수있는 다른 유사한 가설 기능이 있습니까?
을 A는 변수이고, J '(세타) theta0, theta1, theta2에 대하여 즉, 편미분을 정당화 구배 하강에 사용되는 3 * 1 행렬 –