help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

theta VALUE is coming to NAN..PLS HELP


From: address@hidden
Subject: theta VALUE is coming to NAN..PLS HELP
Date: Sun, 11 Dec 2016 04:36:42 -0800 (PST)

*Pls Check the Below Code :-*
data=load('cricket_chirps_versus_temperature.txt')
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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]