/// <summary> /// Create a PSO trainer. /// </summary> /// <param name="method">The method to use.</param> /// <param name="training">The training data to use.</param> /// <param name="argsStr">The arguments to use.</param> /// <returns>The newly created trainer.</returns> public IMLTrain Create(IMLMethod method, IMLDataSet training, String argsStr) { IDictionary<String, String> args = ArchitectureParse.ParseParams(argsStr); ParamsHolder holder = new ParamsHolder(args); int particles = holder.GetInt( MLTrainFactory.PropertyParticles, false, 20); ICalculateScore score = new TrainingSetScore(training); IRandomizer randomizer = new NguyenWidrowRandomizer(); IMLTrain train = new NeuralPSO((BasicNetwork)method, randomizer, score, particles); return train; }
/// <summary> /// Program entry point. /// </summary> /// <param name="app">Holds arguments and other info.</param> public void Execute(IExampleInterface app) { IMLDataSet trainingSet = new BasicMLDataSet(XORInput, XORIdeal); BasicNetwork network = EncogUtility.SimpleFeedForward(2, 2, 0, 1, false); ICalculateScore score = new TrainingSetScore(trainingSet); IRandomizer randomizer = new NguyenWidrowRandomizer(); IMLTrain train = new NeuralPSO(network, randomizer, score, 20); EncogUtility.TrainToError(train, 0.01); network = (BasicNetwork)train.Method; // test the neural network Console.WriteLine("Neural Network Results:"); EncogUtility.Evaluate(network, trainingSet); EncogFramework.Instance.Shutdown(); }
/// <summary> /// Constructor. /// </summary> /// <param name="neuralPSO">the training algorithm</param> /// <param name="particleIndex">the index of the particle in the swarm</param> /// <param name="init">true for an initialisation iteration </param> public NeuralPSOWorker(NeuralPSO neuralPSO, int particleIndex, bool init) { m_neuralPSO = neuralPSO; m_particleIndex = particleIndex; m_init = init; }