module Ann_topology: sig
.. end
Neural networks topology: units, layers, and connections.
Type describing the topology of a neural network
type
nn_topology = {
|
layers : (int * int) array ; |
|
conn : (int * int) array ; |
|
inc : int list array ; |
|
outc : int list array ; |
|
bias_units : int list ; |
}
Description of the networks units, layers, and connections.
Read and write networks files
val fprint_list : out_channel -> int list -> unit
fprint_list ch l
prints a list l
of integer on channel ch
val fprint_short_topology : out_channel -> nn_topology -> unit
fprint_short_topology ch nn
prints a short description of network
nn
on channel ch
. Only the layers, connections and bias units are
printed. *
val fprint_network : out_channel -> nn_topology -> unit
fprint_network ch nn
prints the full description of
network nn
on channel ch
.
val save_network : nn_topology -> string -> unit
save_network nn filename
saves the network's topology nn
into
file filename
val read_network : string -> nn_topology
read_network filename
reads a neural network's description
(layers, connections, and bias units) from a file, and returns
the network's topology.
Build a fully connected feed-forward neural network
val fully_connected : int array -> nn_topology
fully_connected raw_layers
builds a fully connected feed-forward
network. raw_layers
describes the number of units in each layer,
without the bias units. The bias units are automatically
inserted by the function, at the beginning of each layer.
Useful functions
val hidden : (int * int) array -> (int * int) option
hidden layers
returns option None
when layers
contains only
one input and one output layer, and Some (u1,u2)
, where u1
and u2
are the first and last hidden units respectively, if there are some
hidden layers. The function raises an exception if the size of layers
is less than 2.
layers
is of the nn.layers
type.
val outlayer : (int * int) array -> int * int
outlayer layers
returns the first and last units of the output layer.
val bias_unit : nn_topology -> int -> bool
bias_units nn u
returns true
is u
is a bias unit of nn
, and
false
otherwise.
val source : nn_topology -> int -> int
source nn k
returns the source unit of connection k
of network nn
.
val dest : nn_topology -> int -> int
dest nn k
returns the destination unit of connection k
of network nn
.
val layer_of : nn_topology -> int -> int
layer_of nn u
returns the number of the layer to which unit u
belongs,
according to the network's descriptin in nn
.