
From:  Herier chen 
Subject:  Re: how to vectorize in the octave 
Date:  Mon, 12 Nov 2012 14:52:55 0500 
You can almost always figure out the correct form by considering the dimensionsOn Mon, Nov 12, 2012 at 11:33 AM, Herier chen <address@hidden> wrote:
yes, it is from professor Andrew Ng the online coursesa class about machine learning.I am doing the ex3 now. I started the class a little late.
On Mon, Nov 12, 2012 at 2:27 PM, Ed Meyer <address@hidden> wrote:On Mon, Nov 12, 2012 at 9:39 AM, Herier chen <address@hidden> wrote:
_______________________________________________Hi, all, I am new for the octave, and I want to know how to vectorize the following code, I have tried lots of time ,but failed. would anybody do me a favor to help. thanks.
grad = zeros(size(theta));
m1 = size(grad);
h = sigmoid(X*theta);
for i=1:m1,
grad(i) = (1.0/m)X(:,i)'(hy);
end
and another question about the octave.
what is the difference between "/" and "./" . and how to find these operators definition in the octave help document. I have not find these all kinds of operators in octave.
thanks a lot/
Helpoctave mailing list
address@hidden
https://mailman.cae.wisc.edu/listinfo/helpoctave
which exercise is this? (I assume it is from Dr. Ng's ML class)

Ed Meyer
of the matrices; in this case X is m by n, theta is (n,1), h = sigmoid(X*theta) is (m,1)
so to vectorize the gradient calculation you want something like
grad = X' * (h  y)/m
(n,1) = (n,m) * (m,1)

Ed Meyer
[Prev in Thread]  Current Thread  [Next in Thread] 