This code takes 60+ secs to execute on my machine. The Java equivalent takes only 0.2 secs!!! Please tell me how to optimise the following code.
begin N = 10000 K = 100 rate = 1e-2 ITERATIONS = 100 # generate y y = rand(N) # generate x x = rand(K, N) # generate w w = zeros(Float64, K) tic() for i=1:ITERATIONS for n=1:N y_hat = 0.0 x_n = x[:,n] for k=1:K y_hat += w[k] * x_n[k] end for k=1:K w[k] += rate * (y[n] - y_hat) * x_n[k] end end end toc() end
