コード例 #1
0
        public void SaveWeightsAndBiases()
        {
            Directory.CreateDirectory(directoryName + @"\Weights\");
            Directory.CreateDirectory(directoryName + @"\Biases\");

            for (int i = 1; i < noOfLayers; i++)
            {
                string weightsFilePath = directoryName + @"\Weights\" + $"{name}_Weights_{i - 1}_{i}.csv";
                string biasesFilePath  = directoryName + @"\Biases\" + $"{name}_Biases_{i - 1}_{i}.csv";
                CsvHandler.SaveWeights(Connections[i - 1].Weights.Values, weightsFilePath);
                CsvHandler.SaveVector(Connections[i - 1].Biases.Values, biasesFilePath);
            }
        }
コード例 #2
0
 private void SetUpConnections(Connection[] connectionsArray, double learningRate, int activationMethod)
 {
     for (int i = 1; i < noOfLayers; i++)
     {
         var    weights         = new WeightMatrix(MyLayers[i].Values.Length, MyLayers[i - 1].Values.Length);
         var    bias            = new Bias(MyLayers[i].Values.Length);
         string weightsFilePath = directoryName + @"Weights\" + $"{name}_Weights_{i - 1}_{i}.csv";
         string biasesFilePath  = directoryName + @"Biases\" + $"{name}_Biases_{i - 1}_{i}.csv";
         weights.Randomise();
         bias.Randomise();
         if (File.Exists(weightsFilePath))
         {
             weights.Populate(CsvHandler.GetWeights(weightsFilePath));
         }
         if (File.Exists(biasesFilePath))
         {
             bias.Populate(CsvHandler.GetBias(biasesFilePath));
         }
         connectionsArray[i - 1] = new Connection(MyLayers[i - 1], MyLayers[i], weights, bias, learningRate, activationMethod);
     }
 }