Discussion:
fann_run ?
Pereira Roger
2008-09-05 12:03:26 UTC
Permalink
I'm trying to understand fann_run function, how does it work but i'm in
trouble!
I don't understand these lines:
"
*neuron_pointers = ann->connections + neuron_it->first_con;

i = num_connections & 3; /* same as modulo 4 */
switch (i)
{
case 3:
neuron_sum += fann_mult(weights[2],
neuron_pointers[2]->value);
case 2:
neuron_sum += fann_mult(weights[1],
neuron_pointers[1]->value);
case 1:
neuron_sum += fann_mult(weights[0],
neuron_pointers[0]->value);
case 0:
break;
}

for(; i != num_connections; i += 4)
{
neuron_sum +=
fann_mult(weights[i], neuron_pointers[i]->value) +
fann_mult(weights[i + 1], neuron_pointers[i +
1]->value) +
fann_mult(weights[i + 2], neuron_pointers[i +
2]->value) +
fann_mult(weights[i + 3], neuron_pointers[i +
3]->value);
}*
"
Why is it necessary to do num_connections modulo 4?
For example if we have 7 connections on the neuron, neuron_sum =
weights[2]* neuron_pointers[2]->value + weights[3]*
neuron_pointers[3]->value + weights[4]* neuron_pointers[4]->value +
weights[5]* neuron_pointers[5]->value + weights[6]*
neuron_pointers[6]->value.
There are 2 connections which are not taking into account (connection 0
and 1, why?).

Best regards,
roger
--
Roger Pereira
Tél: 02.23.23.65.83


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Steffen Nissen
2008-09-06 14:07:45 UTC
Permalink
The code does loop unrolling.

There is no break in the case statements, so a modulo 4 of 7 will give 3 and
all both 2, 1 and 0 will be included in the sum.

Best Regards,
Steffen

--
Steffen Nissen - http://facebook.com/profile.php?id=595485027
FANN Creator and Administrator - http://leenissen.dk/fann/
Post by Pereira Roger
I'm trying to understand fann_run function, how does it work but i'm in
trouble!
"
*neuron_pointers = ann->connections + neuron_it->first_con;
i = num_connections & 3; /* same as modulo 4 */
switch (i)
{
neuron_sum += fann_mult(weights[2],
neuron_pointers[2]->value);
neuron_sum += fann_mult(weights[1],
neuron_pointers[1]->value);
neuron_sum += fann_mult(weights[0],
neuron_pointers[0]->value);
break;
}
for(; i != num_connections; i += 4)
{
neuron_sum +=
fann_mult(weights[i], neuron_pointers[i]->value) +
fann_mult(weights[i + 1], neuron_pointers[i +
1]->value) +
fann_mult(weights[i + 2], neuron_pointers[i +
2]->value) +
fann_mult(weights[i + 3], neuron_pointers[i +
3]->value);
}*
"
Why is it necessary to do num_connections modulo 4?
For example if we have 7 connections on the neuron, neuron_sum =
weights[2]* neuron_pointers[2]->value + weights[3]*
neuron_pointers[3]->value + weights[4]* neuron_pointers[4]->value +
weights[5]* neuron_pointers[5]->value + weights[6]*
neuron_pointers[6]->value.
There are 2 connections which are not taking into account (connection 0
and 1, why?).
Best regards,
roger
--
Roger Pereira
Tél: 02.23.23.65.83
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Fann-general mailing list
https://lists.sourceforge.net/lists/listinfo/fann-general
Continue reading on narkive:
Loading...