private int[] nR = { 1, 1 }; // neighborhood radius #endregion Fields #region Constructors public KohonenLearning(Kohonen nnet) : base(nnet) { LearningRate = 0.9d; int neuronsNum = this.NeuralNetwork.GetLayerAt(1).NeuronsCount; mapSize = (int)Math.Sqrt(neuronsNum); }
/* * Recupera a estrutura de uma RNA a partir de um arquivo */ public static INeuralNetwork NeuralNetworkStructure(string file) { string json = ReadFile(file); ADReNA_API.Util.ExportImportCommon.CommonStructure stru = JsonConvert.DeserializeObject <ADReNA_API.Util.ExportImportCommon.CommonStructure>(json); INeuralNetwork ann = null; switch (stru.type) { case ExportImportCommon.AnnType.Backpropagation: ann = new Backpropagation(stru.inputLayerSize.Value, stru.outputLayerSize.Value, stru.hiddenLayerSizes); ((Backpropagation)ann).SetErrorRate(stru.error.Value); ((Backpropagation)ann).SetMaxIterationNumber(stru.iterationNumber.Value); ((Backpropagation)ann).SetLearningRate(stru.learningRate.Value); break; case ExportImportCommon.AnnType.Kohonen: ann = new Kohonen(stru.inputLayerSize.Value, stru.competitiveNeuronLength.Value, stru.maximumWeightRange.Value); ((Kohonen)ann).SetIterationNumber(stru.iterationNumber.Value); ((Kohonen)ann).SetLearningRate(stru.learningRate.Value); ((Kohonen)ann).SetNeighborhoodRadius(stru.neighborhoodRadius.Value); break; } return(ann); }
static void Main(string[] args) { Kohonen kohonen = new Kohonen(3, 40, 40); }
/// <summary> /// Creates and returns a new instance of Kohonen network </summary> /// <param name="inputNeuronsCount"> number of input neurons </param> /// <param name="outputNeuronsCount"> number of output neurons </param> /// <returns> instance of Kohonen network </returns> public static Kohonen createKohonen(int inputNeuronsCount, int outputNeuronsCount) { Kohonen nnet = new Kohonen(inputNeuronsCount, outputNeuronsCount); return(nnet); }