Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions genann.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,15 @@ void genann_randomize(genann *ann) {
}
}

void genann_random_tweak(genann *ann, double max) {
int i;
for (i = 0; i < ann->total_weights; ++i) {
/* -max <= r <= max */
double r = (GENANN_RANDOM() - 0.5) * 2 * max;
ann->weight[i] += r;
}
}


void genann_free(genann *ann) {
/* The weight, output, and delta pointers go to the same buffer. */
Expand Down
3 changes: 3 additions & 0 deletions genann.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ genann *genann_read(FILE *in);
/* Sets weights randomly. Called by init. */
void genann_randomize(genann *ann);

/* Modifies the weights randomly, with max as a threshold */
void genann_random_tweak(genann *ann, double max);

/* Returns a new copy of ann. */
genann *genann_copy(genann const *ann);

Expand Down