You are looking at historical revision 37766 of this page. It may differ significantly from its current revision.

Genann

Introduction

Genann is an chicken egg that provides bindings to the genann ANSI C neural network library. The C library is written only in standard C, the egg is written only in 'standard' Chicken 5 (what comes included with C5, no eggs).

Genann API

[procedure] (genann-init inputs hidden-layers hidden-neurons outputs)

Creates and returns a genann record. Each argument is an integer specifying how many of that the genann should have. hidden-neurons is the number of hidden neurons per hidden layer.

[procedure] (genann-copy genann)

Return a new copy of genann.

[procedure] (genann-free! genann)

Free the memory used by genann.

[procedure] (genann-train genann inputs desired-outputs learning-rate)

Does a single backpropagation update on genann, where inputs and outputs are f64vectors and learning-rate is a flonum.

[procedure] (genann-run genann inputs)

Runs the feedforward algorithm to calculate the ann's output from f64vector inputs.

[procedure] (genann-randomize genann)

Sets the weights in genann randomly. This is called by genann-init.

[procedure] (genann-read #!optional port)

Read a genann record from file port port.

[procedure] (genann-write #!optional port)

Write a genann to file port port.

Added procedures

[procedure] (make-genann inputs hidden-layers hidden-neurons outputs)

Like genann-init, but sets genann-free! as a finalizer to the returned genann so it can be properly garbage collected.

[procedure] (genann-inputs genann)
[procedure] (genann-hidden-layers genann)
[procedure] (genann-hidden-neurons genann)
[procedure] (genann-outputs genann)
[procedure] (genann-total-weights genann)

Returns number of inputs, hidden layers, hidden neurons per layer, and outputs, respectively, in genann. These are more or less equivalent to the following in C:

// genann is created with genann_init
genann->inputs
genann->hidden_layers
genann->hidden
genann->outputs
genann->total_weights
[procedure] (genann-weight-set! genann i x)
[procedure] (genann-weight-ref genann i)

Set or get the ith weight of genann, with the former being a setter for the latter, so you can used set! with genann-weight-ref. Useful for training with random search, as in example2.scm.

Examples

Training using backpropagation Training using random search Loading a saved ANN Training on the IRIS dataset using backpropagation