I have a cost function for 3-layer-feedforward propagation below. Theta is a vector including weight values of first and second layers and I need to convert it to matrices. Therefore, I am using reshape function. Function works, when I try it with correct values of theta, X, y, s1, s2, s3 in command window.
function J= cost_fun(theta, X, y, s1, s2, s3)
a2= [ones(size(a2,1),1) a2];
However, when I try to minimize cost function for theta below, I get an error "Index exceeds the number of array elements (3)". Error refers to third line of the function file above. I could not understand why the error occurs.
X= [ones(m,1) dataset(:,1) dataset(:,1).^2];
s1= 2; s2= 2; s3= 1;
fun= @(theta)cost_fun(theta, X, y, s1, s2, s3);
theta= fmincon(fun, theta0, A, b);
I would be very glad if you help.