chickadee » genann

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

genann-init inputs hidden-layers hidden-neurons outputsprocedure

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.

genann-copy genannprocedure

Return a new copy of genann.

genann-free! genannprocedure

Free the memory used by genann.

genann-train genann inputs desired-outputs learning-rateprocedure

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

genann-run genann inputsprocedure

Runs the feedforward algorithm to calculate the ann's output from f64vector inputs. Returns outputs as an f64vector.

genann-randomize genannprocedure

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

genann-read #!optional portprocedure

Read a genann record from file port port.

genann-write #!optional portprocedure

Write a genann to file port port.

Added procedures

genann-init* inputs hidden-layers hidden-neurons outputsprocedure
make-genann ...procedure

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

genann-copy* genannprocedure

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

genann-inputs genannprocedure
genann-hidden-layers genannprocedure
genann-hidden-neurons genannprocedure
genann-outputs genannprocedure
genann-total-weights genannprocedure

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
genann-weight-set! genann i xprocedure
genann-weight-ref genann iprocedure

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

Contents »