public float[] compete(HiddenLayer hiddenLayer) { NeuronList list = hiddenLayer.getHiddenLayerNeurons(); IEnumerator listEnum = list.GetEnumerator(); float[] x = new float[list.Count]; int i = 0; while (listEnum.MoveNext()) { x[i++] = ((HiddenLayerNeuron)listEnum.Current).getOutput(); } double max = x[0]; int maxIndex = 0; for (int j = x.Length - 1; j > 0; j--) { if (max < x[j]) { maxIndex = j; } max = Math.Max(max, x[j]); } for (int k = 0; k < x.Length; k++) { x[k] = 0; if (k == maxIndex) { x[k] = 1; } } return(x); }
public static NeuronList createNeurons(int[,] w, short LIST_TYPE) { neuronList = new NeuronList(LIST_TYPE); for (int i = 0; i < w.GetLength(0); i++) { Neuron.Synapse[] s = new Neuron.Synapse[w.GetLength(1)]; for (int j = 0; j < w.GetLength(1); j++) { s[j] = new Neuron.Synapse(w[i, j]); } neuronList.Add(new OutputLayerNeuron(s)); } return(neuronList); }
public OutputLayer(int [,] weights) { outputNeurons = NeuronFectory.createNeurons(weights, 2); }
public HiddenLayer(double [,] weights) { hiddenLayerNeurons = NeuronFectory.createNeurons(weights, 1); }