예제 #1
0
 public bool IsSame(NeuralNetworkDTO rhs)
 {
     if (Layers.Length != rhs.Layers.Length)
     {
         return(false);
     }
     for (var i = 0; i < Layers.Length; i++)
     {
         if (Layers[i] != rhs.Layers[i])
         {
             return(false);
         }
     }
     for (var i = 0; i < Species.Length; i++)
     {
         if (Species[i].Fitness != rhs.Species[i].Fitness)
         {
             return(false);
         }
         for (var j = 0; j < Species[i].Weights.Length; j++)
         {
             if (Species[i].Weights[j].IsSame(rhs.Species[i].Weights[j]) == false)
             {
                 return(false);
             }
             if (Species[i].Biases[j].IsSame(rhs.Species[i].Biases[j]) == false)
             {
                 return(false);
             }
         }
     }
     return(true);
 }
예제 #2
0
        public static NeuralNetwork FromDTO(NeuralNetworkDTO dto)
        {
            var species = new Species[dto.Species.Length];

            for (var i = 0; i < species.Length; i++)
            {
                species[i] = Species.FromDTO(dto.Species[i]);
            }
            return(new NeuralNetwork(dto.Layers, species, 0));
        }