Neat-Ex v1.3.0 Ann

A module for storing and (de)serializing ANNs (artificial neural networks).

Summary

Functions

Forms connections between all of an ANN’s input and output neurons with weights generated by weightGenFun. Default is a normal distribution with mean 0 and variance 0.05

Returns the JSON representation of a given ANN

Creates a new ANN from the given JSON

Creates a new ANN from a list of input IDs, a list of output IDs, and an optional list of connections. If connections is not provided, or is nil, then Ann.connectAll/1 will be used to connect the inputs to the outputs. If an ANN with no topology is needed, provide %{} as connections

Creates a large feedForward network with hidden layers. hiddenMatrix is a list where each element represents the number of hidden nodes existing at that layer

Saves a given binary to a given file path. Overwrites data previously exiting in the file

Generates the GraphViz representation of the neural network, then saves it to the given path

Returns a string with a GraphViz representation of a neural network

Functions

breakdown(ann)
connectAll(ann, weightGenFun \\ fn -> :rand.normal(0, 0.05) end)

Forms connections between all of an ANN’s input and output neurons with weights generated by weightGenFun. Default is a normal distribution with mean 0 and variance 0.05.

connectLayers(inputs, outputs, connections \\ %{})
json(ann)

Returns the JSON representation of a given ANN.

new(json)

Creates a new ANN from the given JSON.

new(inputs, outputs, connections \\ nil)

Creates a new ANN from a list of input IDs, a list of output IDs, and an optional list of connections. If connections is not provided, or is nil, then Ann.connectAll/1 will be used to connect the inputs to the outputs. If an ANN with no topology is needed, provide %{} as connections

Example:

iex> Ann.new([0, 1], [2], %{0 => Ann.Connection.new(0, 2, 0.5)}) #connects 0 to 2 with a weight of 0.5 (and an id of 0)
%Ann{connections: %{0 => Ann.Connection.new(0, 2, 0.5)}, input: [0, 1], output: [2]}
newFeedforward(inputs, outputs, hiddenMatrix)

Creates a large feedForward network with hidden layers. hiddenMatrix is a list where each element represents the number of hidden nodes existing at that layer.

saveData(binary, path)

Saves a given binary to a given file path. Overwrites data previously exiting in the file.

saveGZ(ann, path)

Generates the GraphViz representation of the neural network, then saves it to the given path.

saveJson(ann, path)
toGZ(ann)

Returns a string with a GraphViz representation of a neural network.