Class Parameter
Assembly: NeuralNet.dll
Syntax
Constructors
Parameter(IEnumerable<Matrix<Double>>, IEnumerable<Vector<Double>>)
Creates a new Parameter object that stores the supplied weight matrices and bias vectors.
Declaration
public Parameter(IEnumerable<Matrix<double>> weights, IEnumerable<Vector<double>> biases)
Parameters
Type |
Name |
Description |
IEnumerable<MathNet.Numerics.LinearAlgebra.Matrix<Double>> |
weights |
The weight matrices the new Paramter object will store. A shallow copy of the IEnumerable is created.
|
IEnumerable<MathNet.Numerics.LinearAlgebra.Vector<Double>> |
biases |
The bias vectors the new Parameter object will store. A shallow copy of the IEnumerable is created.
|
Properties
ActiveLayerCount
The number of active (i.e. non-input) layers being simulated. This is equal to the number of weight matrices, which is turn is equal to the number of bias vectors.
Declaration
public int ActiveLayerCount { get; }
Property Value
EntriesCount
The total number of scalar entries in the weight matrices and bias vectors.
Declaration
public int EntriesCount { get; }
Property Value
LayerSizes
The size of each layer, in order of calculation. This is the size of the input, hidden, and output layers.
Declaration
public int[] LayerSizes { get; }
Property Value
Methods
CostGradient(Vector<Double>, Vector<Double>, Activation[], CostFunction)
Each entry in the returned Parameter is the derivative of the cost function with respect to the corresponding entry in the current Parameter.
Declaration
public Parameter CostGradient(Vector<double> input, Vector<double> desiredOutput, Activation[] activators, CostFunction cost)
Parameters
Type |
Name |
Description |
MathNet.Numerics.LinearAlgebra.Vector<Double> |
input |
The input vector.
|
MathNet.Numerics.LinearAlgebra.Vector<Double> |
desiredOutput |
The expected output vector. Is compared to the calculated output vector in cost .
|
Activation[] |
activators |
The activators used in calculating the layers.
|
CostFunction |
cost |
The cost function which compares the calculated output vector to desiredOutput .
|
Returns
DeepCopy()
Returns a new Parameter object with weights and biases that are deep copies of the weights and biases of the current Parameter.
Changes to the current Parameter will not affect the new Parameter.
Declaration
public Parameter DeepCopy()
Returns
GetOutputVector(Vector<Double>, Activation[])
Declaration
public Vector<double> GetOutputVector(Vector<double> input, Activation[] activators)
Parameters
Type |
Name |
Description |
MathNet.Numerics.LinearAlgebra.Vector<Double> |
input |
|
Activation[] |
activators |
|
Returns
Type |
Description |
MathNet.Numerics.LinearAlgebra.Vector<Double> |
|
InPlaceAdd(Parameter)
Adds the weights and biases of other
directly to the weights and biases of the current Parameter.
Updates the currentParameter's weights and biases. Is more memory efficient than invoking +=
.
Declaration
public void InPlaceAdd(Parameter other)
Parameters
Type |
Name |
Description |
Parameter |
other |
The Parameter to be added component-wise. Is unaffected.
|
Exceptions
InPlaceAdd(Double)
Adds scalar
to every weight and bias entry of the current Parameter. Updates the current Parameter's weights and biases. Is more memory efficient than using +=
.
Declaration
public void InPlaceAdd(double scalar)
Parameters
Type |
Name |
Description |
Double |
scalar |
Is added to every weight and bias entry.
|
InPlaceDivide(Parameter)
Divides the weights and biases in the current Parameter by the corresponding weights and biases in other
. Updates the current Parameter's weights and biases. Is more memory efficient than using /=
.
Declaration
public void InPlaceDivide(Parameter other)
Parameters
Type |
Name |
Description |
Parameter |
other |
The Parameter that divides the current Parameter component-wise. Is unaffected by the component-wise division.
|
Exceptions
InPlaceDivide(Double)
Divides every weight and bias entry of the current Parameter by scalar
. Updates the current Parameter's weights and biases. Is more memory efficient than using /=
.
Declaration
public void InPlaceDivide(double scalar)
Parameters
Type |
Name |
Description |
Double |
scalar |
Divides every weight and bias entry.
|
Exceptions
InPlaceMultiply(Parameter)
Multiplies the weights and biases in the current Parameter by the corresponding weights and biases in other
. Updates the current Parameter's weights and biases. Is more memory efficient than using *=
.
Declaration
public void InPlaceMultiply(Parameter other)
Parameters
Type |
Name |
Description |
Parameter |
other |
The Parameter that multiplies the current Parameter component-wise. Is unaffected by the component-wise multiplication.
|
Exceptions
InPlaceMultiply(Double)
Multiplies every weight and bias entry of the current Parameter by scalar
. Updates the current Parameter's weights and biases. Is more memory efficient than using *=
.
Declaration
public void InPlaceMultiply(double scalar)
Parameters
Type |
Name |
Description |
Double |
scalar |
Multiplies every weight and bias entry.
|
InPlacePower(Parameter)
Raises each weight and bias entry in the current Parameter by the power of the corresponding weight / bias entry in in other
.
That is, performs component-wise exponentiation, storing the result in the current Parameter.
Declaration
public void InPlacePower(Parameter power)
Parameters
Exceptions
InPlacePower(Double)
Raises every weight and bias entry of the current Parameter by the exponent power
. Updates the current Parameter's weights and biases.
Declaration
public void InPlacePower(double power)
Parameters
Type |
Name |
Description |
Double |
power |
Exponentiates every weight and bias entry.
|
InPlaceSubtract(Parameter)
Subtracts the weights and biases of other
directly from the weights and biases of the current Parameter. Updates the current Parameter's weights and biases. Is more memory efficient than using -=
.
Declaration
public void InPlaceSubtract(Parameter other)
Parameters
Type |
Name |
Description |
Parameter |
other |
The Parameter to be added component-wise. Is unaffected by the addition.
|
Exceptions
InPlaceSubtract(Double)
Subtracts scalar
from every weight and bias entry of the current Parameter.
Updates the current Parameter's weights and biases. Is more memory efficient than using -=
.
Declaration
public void InPlaceSubtract(double scalar)
Parameters
Type |
Name |
Description |
Double |
scalar |
Is subtracted from every weight and bias entry.
|
IsFinite()
Checks if each entry is finite: i.e. non-infinite and non-NaN.
Declaration
Returns
Pow(Double)
Declaration
public Parameter Pow(double power)
Parameters
Type |
Name |
Description |
Double |
power |
|
Returns
SetWeightsUnivariate(Activation[], IEnumerable<Vector<Double>>, Double, Int32)
Adjusts the weights until the average variance of the output vectors is sufficiently close to 1.
Follows the LSUV algorithm using the current weight matrices instead of random-initialised ones.
Declaration
public void SetWeightsUnivariate(Activation[] activators, IEnumerable<Vector<double>> inputs, double varianceTolerance, int maxIterations)
Parameters
Type |
Name |
Description |
Activation[] |
activators |
The Activations used in calculating layers.
|
IEnumerable<MathNet.Numerics.LinearAlgebra.Vector<Double>> |
inputs |
The input MathNet.Numerics.LinearAlgebra.Vector<T>s which the average variance of the output MathNet.Numerics.LinearAlgebra.Vector<T> is taken from.
|
Double |
varianceTolerance |
The weights stop being adjusted once the average variance of the output vectors is between 1 - varianceTolerance and 1 + varianceTolerance .
|
Int32 |
maxIterations |
The weights are adjusted at most maxIterations times.
|
SquaredNorm()
Returns the sum of the squares of each scalar in the weights and biases.
Declaration
public double SquaredNorm()
Returns
WriteToDirectory(String)
Writes the weight matrices and bias vectors of the current Parameter to individual plain text files in directoryPath
. The weights and biases are written in a human-readable format.
Declaration
public void WriteToDirectory(string directoryPath)
Parameters
Type |
Name |
Description |
String |
directoryPath |
|
Operators
Addition(Parameter, Parameter)
Declaration
public static Parameter operator +(Parameter left, Parameter right)
Parameters
Returns
Addition(Parameter, Double)
Declaration
public static Parameter operator +(Parameter param, double scalar)
Parameters
Returns
Division(Parameter, Parameter)
Declaration
public static Parameter operator /(Parameter left, Parameter right)
Parameters
Returns
Division(Parameter, Double)
Declaration
public static Parameter operator /(Parameter parameter, double scalar)
Parameters
Returns
Multiply(Parameter, Parameter)
Declaration
public static Parameter operator *(Parameter left, Parameter right)
Parameters
Returns
Multiply(Double, Parameter)
Declaration
public static Parameter operator *(double scalar, Parameter parameter)
Parameters
Returns
Subtraction(Parameter, Parameter)
Declaration
public static Parameter operator -(Parameter left, Parameter right)
Parameters
Returns
UnaryNegation(Parameter)
Declaration
public static Parameter operator -(Parameter parameter)
Parameters
Returns