/// <summary> /// Compute fuction for a continuous input feeding. /// Processes given input values and computes (predicts) the output. /// </summary> /// <param name="inputVector">Input values</param> /// <returns>Computed output values</returns> public double[] Compute(double[] inputVector) { if (_settings.NeuralPreprocessorConfig.InputConfig.FeedingType == CommonEnums.InputFeedingType.Patterned) { throw new Exception("This version of Compute function is not useable for patterned input feeding."); } if (RL == null) { throw new Exception("Readout layer is not trained."); } //Compute and return output return(RL.Compute(NP.Preprocess(inputVector))); }
/// <summary> /// Compute function for a patterned input feeding. /// Processes given input pattern and computes the output. /// </summary> /// <param name="inputPattern">Input pattern</param> /// <returns>Computed output values</returns> public double[] Compute(List <double[]> inputPattern) { if (_settings.NeuralPreprocessorConfig.InputConfig.FeedingType == NeuralPreprocessor.InputFeedingType.Continuous) { throw new Exception("This version of Compute function is not useable for continuous input feeding."); } if (RL == null) { throw new Exception("Readout layer is not trained."); } //Compute and return output return(RL.Compute(NP.Preprocess(inputPattern))); }
/// <summary> /// Preprocesses the data and computes the readout layer. /// </summary> /// <param name="inputVector">The input vector.</param> /// <param name="readoutData">The detailed data computed by the readout layer.</param> /// <returns>The computed output values in the natural form.</returns> public double[] Compute(double[] inputVector, out ReadoutLayer.ReadoutData readoutData) { if (!RL.Trained) { throw new InvalidOperationException($"Readout layer is not trained."); } if (NP == null) { //Neural preprocessor is bypassed return(RL.Compute(inputVector, out readoutData)); } else { //Compute and return output return(RL.Compute(NP.Preprocess(inputVector), out readoutData)); } }
/// <summary> /// Verifies the state machine's accuracy. /// </summary> /// <remarks> /// Evaluates the computed data against the ideal data. /// </remarks> /// <param name="verificationData">The verification data bundle.</param> /// <returns>The verification results.</returns> public VerificationResults Verify(VectorBundle verificationData) { VerificationResults verificationResults = new VerificationResults(Config.ReadoutLayerCfg); for (int sampleIdx = 0; sampleIdx < verificationData.InputVectorCollection.Count; sampleIdx++) { double[] predictors; if (NP == null) { //Neural preprocessor is bypassed predictors = verificationData.InputVectorCollection[sampleIdx]; } else { //Neural preprocessing predictors = NP.Preprocess(verificationData.InputVectorCollection[sampleIdx]); } double[] outputVector = RL.Compute(predictors, out ReadoutLayer.ReadoutData readoutData); verificationResults.Update(predictors, readoutData, verificationData.OutputVectorCollection[sampleIdx]); VerificationProgressChanged?.Invoke(verificationData.InputVectorCollection.Count, sampleIdx + 1); } return(verificationResults); }