/// <summary> /// Construct a BasicPNN network. /// </summary> /// /// <param name="kernel">The kernel to use.</param> /// <param name="outmodel">The output model for this network.</param> /// <param name="inputCount">The number of inputs in this network.</param> /// <param name="outputCount">The number of outputs in this network.</param> public BasicPNN(PNNKernelType kernel, PNNOutputMode outmodel, int inputCount, int outputCount) : base(kernel, outmodel, inputCount, outputCount) { SeparateClass = false; _sigma = new double[inputCount]; }
public void TestClassifyPNN() { PNNOutputMode mode = PNNOutputMode.Classification; BasicPNN network = new BasicPNN(PNNKernelType.Gaussian, mode, 2, 2); IMLDataSet trainingData = new BasicMLDataSet(XOR.XORInput, XOR.XORIdeal); TrainBasicPNN train = new TrainBasicPNN(network, trainingData); train.Iteration(); XOR.VerifyXOR(network, 0.01); }
public BasicPNN create() { PNNOutputMode mode = PNNOutputMode.Regression; BasicPNN network = new BasicPNN(PNNKernelType.Gaussian, mode, 2, 1); BasicMLDataSet trainingSet = new BasicMLDataSet(XOR.XORInput, XOR.XORIdeal); TrainBasicPNN train = new TrainBasicPNN(network, trainingSet); train.Iteration(); XOR.VerifyXOR(network, 0.001); return(network); }
public static string OutputModeToString(PNNOutputMode mode) { switch (mode) { case PNNOutputMode.Unsupervised: return "unsupervised"; case PNNOutputMode.Regression: return "regression"; case PNNOutputMode.Classification: return "classification"; } return null; }
/// <summary> /// Convert output mode to string. /// </summary> /// /// <param name="mode">The output mode.</param> /// <returns>The string.</returns> public static String OutputModeToString(PNNOutputMode mode) { switch (mode) { case PNNOutputMode.Regression: return("regression"); case PNNOutputMode.Unsupervised: return("unsupervised"); case PNNOutputMode.Classification: return("classification"); default: return(null); } }
protected AbstractPNN(PNNKernelType kernel, PNNOutputMode outputMode, int inputCount, int outputCount) { while ((((uint) inputCount) + ((uint) inputCount)) >= 0) { this._kernel = kernel; this._outputMode = outputMode; this._inputCount = inputCount; if (((uint) inputCount) < 0) { goto Label_0020; } this._outputCount = outputCount; this.Trained = false; this.Error = double.MinValue; if (0 == 0) { this._confusion = null; goto Label_006C; } } return; Label_0020: if (((((uint) inputCount) | 0xfffffffe) != 0) && (((uint) inputCount) >= 0)) { if ((((uint) outputCount) & 0) == 0) { return; } goto Label_006C; } Label_0038: if (this._outputMode == PNNOutputMode.Classification) { this._confusion = new int[this._outputCount + 1]; goto Label_0020; } return; Label_006C: this.Exclude = -1; this._deriv = new double[inputCount]; this._deriv2 = new double[inputCount]; goto Label_0038; }
/// <summary> /// Constructor. /// </summary> /// /// <param name="kernel">The kernel type to use.</param> /// <param name="outputMode">The output mode to use.</param> /// <param name="inputCount">The input count.</param> /// <param name="outputCount">The output count.</param> protected AbstractPNN(PNNKernelType kernel, PNNOutputMode outputMode, int inputCount, int outputCount) { _kernel = kernel; _outputMode = outputMode; _inputCount = inputCount; _outputCount = outputCount; Trained = false; Error = -1000; _confusion = null; Exclude = -1; _deriv = new double[inputCount]; _deriv2 = new double[inputCount]; if (_outputMode == PNNOutputMode.Classification) { _confusion = new int[_outputCount + 1]; } }
/// <summary> /// Construct the object. /// </summary> public PNNPattern() { _kernel = PNNKernelType.Gaussian; _outmodel = PNNOutputMode.Regression; }
/// <summary> /// Read an object. /// </summary> public Object Read(Stream mask0) { var ins0 = new EncogReadHelper(mask0); EncogFileSection section; var samples = new BasicMLDataSet(); IDictionary <String, String> networkParams = null; PNNKernelType kernel = default(PNNKernelType) /* was: null */; PNNOutputMode outmodel = default(PNNOutputMode) /* was: null */; int inputCount = 0; int outputCount = 0; double error = 0; double[] sigma = null; while ((section = ins0.ReadNextSection()) != null) { if (section.SectionName.Equals("PNN") && section.SubSectionName.Equals("PARAMS")) { networkParams = section.ParseParams(); } if (section.SectionName.Equals("PNN") && section.SubSectionName.Equals("NETWORK")) { IDictionary <String, String> paras = section.ParseParams(); inputCount = EncogFileSection.ParseInt(paras, PersistConst.InputCount); outputCount = EncogFileSection.ParseInt(paras, PersistConst.OutputCount); kernel = StringToKernel(paras[PersistConst.Kernel]); outmodel = StringToOutputMode(paras[PropertyOutputMode]); error = EncogFileSection .ParseDouble(paras, PersistConst.Error); sigma = section.ParseDoubleArray(paras, PersistConst.Sigma); } if (section.SectionName.Equals("PNN") && section.SubSectionName.Equals("SAMPLES")) { foreach (String line in section.Lines) { IList <String> cols = EncogFileSection .SplitColumns(line); int index = 0; var inputData = new BasicMLData(inputCount); for (int i = 0; i < inputCount; i++) { inputData[i] = CSVFormat.EgFormat.Parse(cols[index++]); } var idealData = new BasicMLData(inputCount); idealData[0] = CSVFormat.EgFormat.Parse(cols[index++]); IMLDataPair pair = new BasicMLDataPair(inputData, idealData); samples.Add(pair); } } } var result = new BasicPNN(kernel, outmodel, inputCount, outputCount); if (networkParams != null) { EngineArray.PutAll(networkParams, result.Properties); } result.Samples = samples; result.Error = error; if (sigma != null) { EngineArray.ArrayCopy(sigma, result.Sigma); } return(result); }