mirror of
https://github.com/codeplea/genann
synced 2024-11-21 22:11:34 +03:00
Added linear act output delta calculation
This commit is contained in:
parent
29264145be
commit
8853c56155
14
genann.c
14
genann.c
@ -236,9 +236,15 @@ void genann_train(genann const *ann, double const *inputs, double const *desired
|
|||||||
|
|
||||||
|
|
||||||
/* Set output layer deltas. */
|
/* Set output layer deltas. */
|
||||||
for (j = 0; j < ann->outputs; ++j) {
|
if (ann->activation_output == genann_act_linear) {
|
||||||
*d = (*t - *o) * *o * (1.0 - *o);
|
for (j = 0; j < ann->outputs; ++j) {
|
||||||
++o; ++d; ++t;
|
*d++ = *t++ - *o++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (j = 0; j < ann->outputs; ++j) {
|
||||||
|
*d++ = (*t - *o) * *o * (1.0 - *o);
|
||||||
|
++o; ++t;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,7 +295,7 @@ void genann_train(genann const *ann, double const *inputs, double const *desired
|
|||||||
? (ann->inputs + (ann->hidden) * (ann->hidden_layers-1))
|
? (ann->inputs + (ann->hidden) * (ann->hidden_layers-1))
|
||||||
: 0);
|
: 0);
|
||||||
|
|
||||||
/* Set output layer deltas. */
|
/* Set output layer weights. */
|
||||||
for (j = 0; j < ann->outputs; ++j) {
|
for (j = 0; j < ann->outputs; ++j) {
|
||||||
for (k = 0; k < (ann->hidden_layers ? ann->hidden : ann->inputs) + 1; ++k) {
|
for (k = 0; k < (ann->hidden_layers ? ann->hidden : ann->inputs) + 1; ++k) {
|
||||||
if (k == 0) {
|
if (k == 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user