public Vector <double>[] GetFeatures() { var allFeatures = new Vector <double> [NeuronsCount]; for (var i = 0; i < Weights.RowCount; i++) { var norm = Weights.Row(i).L2Norm(); var features = Weights.Row(i).Divide(norm); allFeatures[i] = features; } return(allFeatures); }
public Vector <double> ActivationFunctionPrime(Vector <double> output) { switch (CurrentActivationFunction) { case Network.ActivationFunction.Sigmoid: return(HelperFunctions.SigmoidPrime(output)); case Network.ActivationFunction.Tanh: return(HelperFunctions.TanhPrime(output)); default: throw new ArgumentOutOfRangeException(); } }
/// <summary> /// /// </summary> /// <param name="inputsCount">Number of inputs to each vector</param> /// <param name="outputsCount">Same as neuron count in this layer</param> /// <param name="activationFunction"></param> /// <param name="initialWeightsRange"></param> public HiddenLayer( int inputsCount, int outputsCount, ActivationFunction activationFunction, double initialWeightsRange ) { CurrentActivationFunction = activationFunction; InputsCount = inputsCount; NeuronsCount = outputsCount; InitialWeightsRange = initialWeightsRange; Weights = GetNewWeightsMatrix(false); Biases = GetNewBiasesVector(false); }
/// <summary> /// Takes net as input (this layer output before activation function) /// </summary> /// <param name="output"></param> /// <returns></returns> public Vector <double> GetActivation(Vector <double> output) { return(ActivationFunction(output)); }
public Vector <double> GetNet(Vector <double> inputs) { //(O x I * I x 1) o 0 x 1 = O x 1 return(Weights * inputs + Biases); }
/// <summary> /// /// </summary> /// <param name="inputs">Vector dimensions: I x 1</param> /// <returns></returns> public override Vector <double> Feedforward(Vector <double> inputs) { var output = GetNet(inputs); return(GetActivation(output)); }