help-octave
[Top][All Lists]
Advanced

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

## Re: how to vectorize in the octave

 From: Ed Meyer Subject: Re: how to vectorize in the octave Date: Mon, 12 Nov 2012 11:45:18 -0800

On Mon, Nov 12, 2012 at 11:33 AM, Herier chen wrote:
yes, it is from professor Andrew Ng  the on-line 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 wrote:

On Mon, Nov 12, 2012 at 9:39 AM, Herier chen 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)'(h-y);

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/

_______________________________________________
Help-octave mailing list
address@hidden
https://mailman.cae.wisc.edu/listinfo/help-octave

which exercise is this? (I assume it is from Dr. Ng's ML class)

--
Ed Meyer

You can almost always figure out the correct form by considering the dimensions
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

reply via email to

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