NeuralNet

* Neural-network abstraction.

Constructors

this
this()
Undocumented in source.

Members

Functions

add
NeuralNet add(string name_, NeuralLayer layer, Optimizer opt)

Name and add a layer to the net, without wiring it.

add
NeuralNet add(NeuralLayer layer, Optimizer opt)

Add a layer to the net, without wiring it.

add_root
NeuralNet add_root(string name_, InputLayer layer)

Name and add a root to the net.

add_root
NeuralNet add_root(InputLayer root_)

Add a root to the net.

backward_prop
void backward_prop(V[] output_grad)
Undocumented in source. Be warned that the author may not have intended to support it.
check_layer_here
void check_layer_here(string name)
Undocumented in source. Be warned that the author may not have intended to support it.
clear_opt
void clear_opt()

Remove any optimizer defined on layers of the net.

dup
NeuralNet dup(bool topology_only)

Return a copy of the net.

initialize
void initialize(double rand_scale)

Initialize at random all the parameters of the net.

learn
void learn(D data, S delegate(R net_out, ref T ex, ref V[] grad) grad_f, O opt, bool verbose, uint num_cores)

Train neural network on some data, using specified gradient callback and optimizer.

learn
void learn(D data, string loss, O opt, bool verbose, uint num_cores, bool monitor_loss)

Train neural network on a dataset, using a predefined loss.

learn
void learn(D data, float delegate(R net_out, ref T ex, ref V[] grad) grad_f, bool verbose, uint num_cores)

Train neural network on some data, using a gradient callback.

learn
void learn(D data, string loss, bool verbose, uint num_cores)

Train neural network on some data, using a predefined loss.

predict
float[] predict(T v)

Compute the prediction of the net for $(PARAM v). Runs forward-propagation and outputs the predicted vector.

predict
float[] predict(T args)

Compute the prediction of the net when passing the arguments to the root(s) of the net.

reset
void reset()

Reset any internal state variables of the net.

serialize
void serialize(string path)

Dump the neural net (topology and weight values) to the specified path.

share_params
void share_params(NeuralNet net)

Discard local weights and use those of the target net instead. However, the net keeps its own internal state. Useful for hogwild SGD implementation.

stack
NeuralNet stack(NeuralLayer layer, Optimizer opt)

Stack a layer on top of the former leaf of the net.

stack
NeuralNet stack(string name_, NeuralLayer layer, Optimizer opt)

Stack a layer on top of the former leaf of the net.

toString
string toString()
Undocumented in source. Be warned that the author may not have intended to support it.
wire
void wire(string parent, string child, bool with_alloc)

Create a directed edge between parent and child nodes.

wire
void wire(NeuralLayer parent, NeuralLayer child, bool with_alloc)

Create a directed edge between parent and child nodes.

Mixins

__anonymous
mixin opCallNew
Undocumented in source.

Properties

num_params
ulong num_params [@property getter]

Return the total number of learnable parameters in the net.

out_layer
NeuralLayer out_layer [@property getter]

reference to the leaf of the net

output
float[] output [@property getter]

Return a reference to the dense output vector of the leaf of the net.

Static functions

deserialize
NeuralNet deserialize(string path)

Deserialize the neural net from the specified path.

is_upstream_stack
bool is_upstream_stack(NeuralLayer layer)
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

edges
string[][string] edges;

edges of the graph: src -> [dst1, ..., dstk]

layers
NeuralLayer[] layers;

all nodes of the computational graph

layers_map
NeuralLayer[string] layers_map;

map: name --> layer

leaves
NeuralLayer[] leaves;

array of all the leaves

roots
InputLayer[] roots;

array of all the roots

Mixed In Members

From mixin opCallNew

opCall
auto opCall(T args)
Undocumented in source. Be warned that the author may not have intended to support it.

Examples

auto nn = NeuralNet()
    .stack(DenseData(400))
    .stack(Linear(10));
// nn is a network working on 400-dimensions dense vectors and predicting
// a 10-dimensions vector

Meta