コード例 #1
0
 /// <summary>
 /// Constructs layer
 /// </summary>
 /// <param name="neuronCount">Number of neurons in layer</param>
 /// <param name="weightSource">Source of weight values for neurons, either file or random number generator</param>
 public Layer(uint neuronCount, IWeightSource weightSource)
 {
     neurons = new List <Neuron>();
     for (int i = 0; i < neuronCount; i++)
     {
         neurons.Add(new Neuron(weightSource));
     }
 }
コード例 #2
0
ファイル: Perceptron.cs プロジェクト: piotled/BIAI
 /// <summary>
 /// Creates layers
 /// </summary>
 /// <param name="layerElementCountArray">Network format description</param>
 /// <param name="weightSource">Weight source, either file or random number generator</param>
 private void Construct(List <uint> layerElementCountArray, IWeightSource weightSource)
 {
     if (ValidateStructure(layerElementCountArray))
     {
         inputLayer = new List <float>((int)layerElementCountArray[0]);
         layers     = new List <Layer>();
         for (int i = 1; i < layerElementCountArray.Count; i++)
         {
             layers.Add(new Layer(layerElementCountArray[i], weightSource));
         }
         Connect();
     }
     else
     {
         throw new Exception("Invalid network structure");
     }
 }
コード例 #3
0
ファイル: Perceptron.cs プロジェクト: piotled/BIAI
        /// <summary>
        /// Constructs network from file
        /// </summary>
        /// <param name="filePath"></param>
        public Perceptron(string filePath)
        {
            NetworkFileReader reader = null;

            try
            {
                reader = new NetworkFileReader(filePath);
                List <uint>   layerElementCountArray = reader.ReadNetworkStructure();
                IWeightSource weightSource           = reader.GetWeightSource();
                Construct(layerElementCountArray, weightSource);
            }
            catch
            {
                throw;
            }
            finally
            {
                reader?.Close();
            }
        }
コード例 #4
0
 /// <summary>
 /// Constructs neuron
 /// </summary>
 /// <param name="weightSource"></param>
 public Neuron(IWeightSource weightSource)
 {
     weights           = new List <float>();
     this.weightSource = weightSource;
 }