[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: theta VALUE is coming to NAN..PLS HELP
From: |
Nicholas Jankowski |
Subject: |
Re: theta VALUE is coming to NAN..PLS HELP |
Date: |
Sun, 11 Dec 2016 12:04:32 -0500 |
On Dec 11, 2016 10:01 AM, "address@hidden" <address@hidden> wrote:
>
> *Pls Check the Below Code :-*
> data="">
> x=data(:,1); % X would have 100 col and 1 row
> y=data(:,2); % y would have 100 col and 1 row
>
> figure;
> plot(x,y,'bx','MarkerSize',10);
> xlabel('(y) Weight -->','fontsize',14);
> ylabel('(x) mpg -->','fontsize',14);
> hold on;
>
> lenght=size(x)
> m=lenght(1,1)
>
> alpha = 0.1; % Learning rate
> num_of_iterations = 2000; % Iterations
>
> theta=zeros(2,1); %using the zeros() function.
>
> x=[ones(m,1),x];
>
> % gradient decent
> for i=1:num_of_iterations
>
> h_of_x=(x*theta)-y;
>
> theta(1)=theta(1)-(alpha/m)*h_of_x'*x(:,1);
> theta(2)=theta(2)-(alpha/m)*h_of_x'*x(:,2);
>
>
> end
>
>
> fprintf('θ0 = %f θ1 = %f \n', theta(1), theta(2));
>
> hold on;
>
>
> After Running this Code theta VALUE is coming to NAN..PLS HELP....
>
>
>
>
>
> --
> View this message in context: http://octave.1599824.n4.nabble.com/theta-VALUE-is-coming-to-NAN-PLS-HELP-tp4680999.html
> Sent from the Octave - General mailing list archive at Nabble.com.
>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/help-octave
Check the values of the things in your theta equation. One must have a NAN value. For one, length not lenght. There may be other issues.