/// <summary> /// Constructs a AcyclicNeuralNet with the provided neural net definition parameters. /// </summary> /// <param name="digraph">Network structure definition</param> /// <param name="weightArr">Connection weights array.</param> /// <param name="activationFn">Node activation function.</param> public NeuralNetAcyclic( DirectedGraphAcyclic digraph, double[] weightArr, VecFnSegment <double> activationFn) { // Store refs to network structure data. _srcIdArr = digraph.ConnectionIdArrays._sourceIdArr; _tgtIdArr = digraph.ConnectionIdArrays._targetIdArr; _weightArr = weightArr; _layerInfoArr = digraph.LayerArray; // Store network activation function. _activationFn = activationFn; // Store input/output node counts. _inputCount = digraph.InputCount; _outputCount = digraph.OutputCount; // Create working array for node activation signals. _activationArr = new double[digraph.TotalNodeCount]; // Wrap a sub-range of the _activationArr that holds the activation values for the input nodes. this.InputVector = new VectorSegment <double>(_activationArr, 0, _inputCount); // Wrap the output nodes. Nodes have been sorted by depth within the network therefore the output // nodes can no longer be guaranteed to be in a contiguous segment at a fixed location. As such their // positions are indicated by outputNodeIdxArr, and so we package up this array with the node signal // array to abstract away the indirection described by outputNodeIdxArr. this.OutputVector = new MappingVector <double>(_activationArr, digraph.OutputNodeIdxArr); }
/// <summary> /// Constructs a AcyclicNeuralNet with the provided neural net definition parameters. /// </summary> /// <param name="digraph">Network structure definition</param> /// <param name="activationFn">Node activation function.</param> /// <param name="boundedOutput">Indicates that the output values at the output nodes should be bounded to the interval [0,1]</param> public AcyclicNeuralNet( WeightedAcyclicDirectedGraph <double> digraph, VecFnSegment <double> activationFn, bool boundedOutput) : this(digraph, digraph.WeightArray, activationFn, boundedOutput) { }
/// <summary> /// Constructs a AcyclicNeuralNet with the provided neural net definition parameters. /// </summary> /// <param name="digraph">Network structure definition</param> /// <param name="activationFn">Node activation function.</param> public NeuralNetAcyclic( WeightedDirectedGraphAcyclic <double> digraph, VecFnSegment <double> activationFn) : this(digraph, digraph.WeightArray, activationFn) { }