Pereira Roger
2008-09-05 12:03:26 UTC
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=/
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=/