Error in sgd (line 12) t_x(k) = x(k, :)';
this is my code :
function weight = sgd(weight, x, a, b, correct_output)alpha(1) = 0.7;alpha(2) = 0.6;alpha(3) = 0.4;beta = 0.01;gamma = 0.2;N = 3;for k = 1:N t_x(k) = x(k, :)'; d = correct_output(k); v(k) = a(k)*y(k-1) + (1-a(k))*v(k-1); w_sum = weight*t_x + b(k)*v(k-1); y = Sigmoid(w_sum); error = d - y; delta = y*(1-y)*error; dweight = alpha*delta*t_x; d_a = beta*delta*b(k)*(y(k-1) - v(k-1)); d_b = gamma*delta*v(k); weight(1) = weight(1) - dweight(1); weight(2) = weight(2) - dweight(2); weight(3) = weight(3) - dweight(3); a(k) = a(k) - d_a(k); b(k) = b(k) - d_b(k);end end
Best Answer