Re: How can I make this piece of code even faster?

2013-07-21 Thread Michael Torrie
On 07/21/2013 04:19 AM, pablobarhamal...@gmail.com wrote: > Thank's for all the replies! I've tried some of the imporovements you > suggested (using math.exp() and sum() or math.fsum()). > None of that made the code faster, because they are functions you are calling > lots of times, and function

Re: How can I make this piece of code even faster?

2013-07-21 Thread Stefan Behnel
pablobarhamal...@gmail.com, 21.07.2013 12:48: > El domingo, 21 de julio de 2013 12:31:42 UTC+2, Steven D'Aprano escribió: >> [steve@ando ~]$ python3.3 -m timeit -s "x = 2.357e7" "x**0.5" >> 100 loops, best of 3: 0.319 usec per loop >> [steve@ando ~]$ python3.3 -m timeit -s "x = 2.357e7" -s "fr

Re: How can I make this piece of code even faster?

2013-07-21 Thread Joshua Landau
On 20 July 2013 21:22, wrote: > Ok, I'm working on a predator/prey simulation, which evolve using genetic > algorithms. At the moment, they use a quite simple feed-forward neural > network, which can change size over time. Each brain "tick" is performed by > the following function (inside the

Re: How can I make this piece of code even faster?

2013-07-21 Thread pablobarhamalzas
El domingo, 21 de julio de 2013 12:31:42 UTC+2, Steven D'Aprano escribió: > On Sun, 21 Jul 2013 03:19:24 -0700, pablobarhamalzas wrote: > > > > > Thank's for all the replies! I've tried some of the imporovements you > > > suggested (using math.exp() and sum() or math.fsum()). None of that made

Re: How can I make this piece of code even faster?

2013-07-21 Thread Chris Angelico
On Sun, Jul 21, 2013 at 8:31 PM, Steven D'Aprano wrote: > On Sun, 21 Jul 2013 03:19:24 -0700, pablobarhamalzas wrote: > >> Thank's for all the replies! I've tried some of the imporovements you >> suggested (using math.exp() and sum() or math.fsum()). None of that made >> the code faster, because t

Re: How can I make this piece of code even faster?

2013-07-21 Thread Steven D'Aprano
On Sun, 21 Jul 2013 03:19:24 -0700, pablobarhamalzas wrote: > Thank's for all the replies! I've tried some of the imporovements you > suggested (using math.exp() and sum() or math.fsum()). None of that made > the code faster, because they are functions you are calling lots of > times, and function

Re: How can I make this piece of code even faster?

2013-07-21 Thread pablobarhamalzas
Thank's for all the replies! I've tried some of the imporovements you suggested (using math.exp() and sum() or math.fsum()). None of that made the code faster, because they are functions you are calling lots of times, and function calling is quite time expensive (same as x**(1/2) is faster than

Re: How can I make this piece of code even faster?

2013-07-21 Thread Chris Angelico
On Sun, Jul 21, 2013 at 5:11 PM, Paul Rudin wrote: > Steven D'Aprano writes: > >> On Sat, 20 Jul 2013 13:22:03 -0700, pablobarhamalzas asked: >> >> "How can I make this piece of code even faster?" >> >> - Use a faster computer. >> - Put

Re: How can I make this piece of code even faster?

2013-07-21 Thread Christian Gollwitzer
How about using numpy? Am 20.07.13 22:22, schrieb pablobarhamal...@gmail.com: Ok, I'm working on a predator/prey simulation, which evolve using genetic algorithms. At the moment, they use a quite simple feed-forward neural network, which can change size over time. Each brain "tick" is performe

Re: How can I make this piece of code even faster?

2013-07-21 Thread Paul Rudin
Steven D'Aprano writes: > On Sat, 20 Jul 2013 13:22:03 -0700, pablobarhamalzas asked: > > "How can I make this piece of code even faster?" > > - Use a faster computer. > - Put in more memory. > - If using Unix or Linux, decrease the "nice" priori

Re: How can I make this piece of code even faster?

2013-07-21 Thread Serhiy Storchaka
20.07.13 23:22, pablobarhamal...@gmail.com написав(ла): e = math.e count = -1 for x in range(hidden_num): temp = 0 for y in range(input_num): count += 1 temp += inputs[y] * h_weight[count] hidden[

Re: How can I make this piece of code even faster?

2013-07-21 Thread Peter Otten
pablobarhamal...@gmail.com wrote: > Ok, I'm working on a predator/prey simulation, which evolve using genetic > algorithms. At the moment, they use a quite simple feed-forward neural > network, which can change size over time. Each brain "tick" is performed > by the following function (inside the

Re: How can I make this piece of code even faster?

2013-07-20 Thread Steven D'Aprano
On Sat, 20 Jul 2013 13:22:03 -0700, pablobarhamalzas asked: "How can I make this piece of code even faster?" - Use a faster computer. - Put in more memory. - If using Unix or Linux, decrease the "nice" priority of the process. I mention these because sometimes people forge

Re: How can I make this piece of code even faster?

2013-07-20 Thread Chris Angelico
On Sun, Jul 21, 2013 at 9:24 AM, wrote: > Hi there Chris. > Unfortunately, using iterations was about twice as slow as the original > implementation, so that's not the solution. > Thank's anyway. Fascinating! Well, was worth a try anyhow. But that's a very surprising result. ChrisA -- http://

Re: How can I make this piece of code even faster?

2013-07-20 Thread pablobarhamalzas
Hi there Chris. Unfortunately, using iterations was about twice as slow as the original implementation, so that's not the solution. Thank's anyway. -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I make this piece of code even faster?

2013-07-20 Thread Chris Angelico
On Sun, Jul 21, 2013 at 6:22 AM, wrote: > temp = 0 > for y in range(input_num): > count += 1 > temp += inputs[y] * h_weight[count] > hidden[x] = 1/(1+e**(-temp)) It's a micro-optimization that'll probably have negligible effect,

Re: How can I make this piece of code even faster?

2013-07-20 Thread pablobarhamalzas
Hi there. I'm using python 3, where xrange doesn't exist any more (range is now equivalent). And "temp" doesn't have any fixed discrete values it always takes. I have tried cython but it doesn't seem to work well (maybe using it wrong?). Any other ideas? -- http://mail.python.org/mailman/lis

Re: How can I make this piece of code even faster?

2013-07-20 Thread Roy Smith
In article <6bf4d298-b425-4357-9c1a-192e6e6cd...@googlegroups.com>, pablobarhamal...@gmail.com wrote: > Ok, I'm working on a predator/prey simulation, which evolve using genetic > algorithms. At the moment, they use a quite simple feed-forward neural > network, which can change size over time.

Re: How can I make this piece of code even faster?

2013-07-20 Thread Fabio Zadrozny
On Sat, Jul 20, 2013 at 5:22 PM, wrote: > Ok, I'm working on a predator/prey simulation, which evolve using genetic > algorithms. At the moment, they use a quite simple feed-forward neural > network, which can change size over time. Each brain "tick" is performed by > the following function (insi

How can I make this piece of code even faster?

2013-07-20 Thread pablobarhamalzas
Ok, I'm working on a predator/prey simulation, which evolve using genetic algorithms. At the moment, they use a quite simple feed-forward neural network, which can change size over time. Each brain "tick" is performed by the following function (inside the Brain class): def tick(self):