C# Class numl.Supervised.NeuralNetwork.NetworkOps

A network.
Mostra file Open project: sethjuarez/numl

Public Methods

Method Description
AddConnections ( this network, Neuron node, IEnumerable parentNodes, IEnumerable childNodes, double epsilon = double.NaN ) : numl.Supervised.NeuralNetwork.Network

Adds new connections for the specified node for the parent and child nodes.

Constrain ( this network, int layer = -1, bool constrain = true ) : numl.Supervised.NeuralNetwork.Network

Constrains the weights in the specified layer from being updated. This prevents weights in pretrained layers from being updated.

Create ( this network, Descriptor d, Matrix X, Vector y, IFunction activationFunction, IFunction outputFunction = null ) : numl.Supervised.NeuralNetwork.Network

Creates a new deep neural network based on the supplied inputs and layers.

Create ( this network, Descriptor d, Matrix x, Vector y, IFunction activationFunction, IFunction outputFunction = null, double epsilon = double.NaN ) : numl.Supervised.NeuralNetwork.Network

Defaults.

Create ( this network, int inputLayer, int outputLayer, IFunction activationFunction, IFunction outputFunction = null, Func fnNodeInitializer = null, Func fnWeightInitializer = null, double epsilon = double.NaN ) : numl.Supervised.NeuralNetwork.Network

Creates a new fully connected deep neural network based on the supplied size and depth parameters.

GetBiases ( this network, int layer ) : Vector

Gets a bias input vector for the specified layer. Each item is the bias weight on the connecting node in the next layer.

GetWeights ( this network, int layer, bool includeBiases = false ) : Matrix

Gets the weight values as an [i x j] weight matrix. Where i represents the node in the next layer (layer + 1) and j represents the node in the specified layer.

LinkNodes ( this network, IEnumerable nodes, IEnumerable edges ) : numl.Supervised.NeuralNetwork.Network

Links a Network from nodes and edges.

Prune ( this network, bool backwards = true, int layers = 1 ) : numl.Supervised.NeuralNetwork.Network

Prunes the network in the given direction for the specified number of layers.

Reindex ( this network ) : numl.Supervised.NeuralNetwork.Network

Reindexes each node's layer and label in the network, starting from 0 (input layer).

Stack ( this network, bool removeInputs = false, bool removeOutputs = false, bool addBiases = true, bool constrain = true ) : numl.Supervised.NeuralNetwork.Network

Stacks the given networks in order, on top of the current network, to create a fully connected deep neural network.

This is useful in building pretrained multi-layered neural networks, where each layer is partially trained prior to stacking.

Method Details

AddConnections() public static method

Adds new connections for the specified node for the parent and child nodes.
public static AddConnections ( this network, Neuron node, IEnumerable parentNodes, IEnumerable childNodes, double epsilon = double.NaN ) : numl.Supervised.NeuralNetwork.Network
network this Current network.
node Neuron Neuron being added.
parentNodes IEnumerable Parent nodes that this neuron is connected with.
childNodes IEnumerable Child nodes that this neuron is connected to.
epsilon double Weight initialization parameter.
return numl.Supervised.NeuralNetwork.Network

Constrain() public static method

Constrains the weights in the specified layer from being updated. This prevents weights in pretrained layers from being updated.
public static Constrain ( this network, int layer = -1, bool constrain = true ) : numl.Supervised.NeuralNetwork.Network
network this Current network.
layer int The layer of weights to constrain. To prevent all weights from being changed specify the global value of -1.
constrain bool Sets the value to true/false.
return numl.Supervised.NeuralNetwork.Network

Create() public static method

Creates a new deep neural network based on the supplied inputs and layers.
public static Create ( this network, Descriptor d, Matrix X, Vector y, IFunction activationFunction, IFunction outputFunction = null ) : numl.Supervised.NeuralNetwork.Network
network this
d Descriptor Descriptor object.
X Matrix Training examples
y numl.Math.LinearAlgebra.Vector Training labels
activationFunction IFunction Activation Function for each output layer.
outputFunction IFunction Ouput Function for each output layer.
return numl.Supervised.NeuralNetwork.Network

Create() public static method

Defaults.
public static Create ( this network, Descriptor d, Matrix x, Vector y, IFunction activationFunction, IFunction outputFunction = null, double epsilon = double.NaN ) : numl.Supervised.NeuralNetwork.Network
network this
d Descriptor The Descriptor to process.
x Matrix The Vector to process.
y numl.Math.LinearAlgebra.Vector The Vector to process.
activationFunction IFunction The activation.
outputFunction IFunction The ouput function for hidden nodes (Optional).
epsilon double epsilon
return numl.Supervised.NeuralNetwork.Network

Create() public static method

Creates a new fully connected deep neural network based on the supplied size and depth parameters.
public static Create ( this network, int inputLayer, int outputLayer, IFunction activationFunction, IFunction outputFunction = null, Func fnNodeInitializer = null, Func fnWeightInitializer = null, double epsilon = double.NaN ) : numl.Supervised.NeuralNetwork.Network
network this
inputLayer int Neurons in the input layer.
outputLayer int Neurons in the output layer.
activationFunction IFunction Activation function for the hidden and output layers.
outputFunction IFunction (Optional) Output function of the the Nodes in the output layer (overrides the Activation function).
fnNodeInitializer Func (Optional) Function to call for initializing new Nodes - supplying parameters for the layer and node index.
fnWeightInitializer Func (Optional) Function to call for initializing the weights of each connection (including bias nodes). /// Where int1 = Source layer (0 is input layer), int2 = Source Node, int3 = Target node in the next layer.
epsilon double Weight initialization parameter for random weight selection. Weight will be in the range of: -epsilon to +epsilon.
return numl.Supervised.NeuralNetwork.Network

GetBiases() public static method

Gets a bias input vector for the specified layer. Each item is the bias weight on the connecting node in the next layer.
public static GetBiases ( this network, int layer ) : Vector
network this Current network.
layer int Forward layer of biases and their weights. The layer should be between 0 (first hidden layer) and the last hidden layer.
return numl.Math.LinearAlgebra.Vector

GetWeights() public static method

Gets the weight values as an [i x j] weight matrix. Where i represents the node in the next layer (layer + 1) and j represents the node in the specified layer.
public static GetWeights ( this network, int layer, bool includeBiases = false ) : Matrix
network this Current network.
layer int The layer to retrieve weights for. The layer should be between 0 and the last hidden layer.
includeBiases bool Indicates whether bias weights are included in the output.
return Matrix

LinkNodes() public static method

Links a Network from nodes and edges.
public static LinkNodes ( this network, IEnumerable nodes, IEnumerable edges ) : numl.Supervised.NeuralNetwork.Network
network this
nodes IEnumerable An array of nodes in the network
edges IEnumerable An array of edges between the nodes in the network.
return numl.Supervised.NeuralNetwork.Network

Prune() public static method

Prunes the network in the given direction for the specified number of layers.
public static Prune ( this network, bool backwards = true, int layers = 1 ) : numl.Supervised.NeuralNetwork.Network
network this Current network.
backwards bool If true, removes layer by layer in reverse order (i.e. output layer first).
layers int Number of layers to prune from the network.
return numl.Supervised.NeuralNetwork.Network

Reindex() public static method

Reindexes each node's layer and label in the network, starting from 0 (input layer).
public static Reindex ( this network ) : numl.Supervised.NeuralNetwork.Network
network this Network to reindex.
return numl.Supervised.NeuralNetwork.Network

Stack() public static method

Stacks the given networks in order, on top of the current network, to create a fully connected deep neural network.

This is useful in building pretrained multi-layered neural networks, where each layer is partially trained prior to stacking.

public static Stack ( this network, bool removeInputs = false, bool removeOutputs = false, bool addBiases = true, bool constrain = true ) : numl.Supervised.NeuralNetwork.Network
network this Current network.
removeInputs bool If true, the input nodes in additional layers are removed prior to stacking. /// This will link the previous network's output layer with the hidden units of the next layer. ///
removeOutputs bool If true, output nodes in the input and middle layers are removed prior to stacking. /// This will link the previous network's hidden or output layer with the input or hidden units (when is true) in the next layer. ///
addBiases bool If true, missing bias nodes are automatically added within new hidden layers.
constrain bool If true, the weights within each network are constrained leaving the new interconnecting network weights for training.
return numl.Supervised.NeuralNetwork.Network