public object Clone() { var clone = Of(InputLayer.ColsCount, OutputLayer.ColsCount, ActivationsFunctions); var cloneWeights = new List <Matrix>(); foreach (var weight in Weights) { var currentWeight = new Matrix(weight.RowsCount, weight.ColsCount); for (var rowI = 0; rowI < currentWeight.RowsCount; rowI++) { for (var colJ = 0; colJ < currentWeight.ColsCount; colJ++) { currentWeight[rowI, colJ] = weight[rowI, colJ]; } } cloneWeights.Add(currentWeight); } var cloneBiases = new List <double>(Biases); clone.Weights = cloneWeights; clone.Biases = cloneBiases; var neuronsInHiddenLayers = HiddenLayers.Select(layer => layer.ColsCount).ToArray(); clone.InitializeHiddenLayers(neuronsInHiddenLayers); return(clone); }
public NeuralNetworkGene GetGenes() { return(new NeuralNetworkGene { InputGene = InputLayer.GetGenes(), HiddenGenes = HiddenLayers.Select(l => l.GetGenes()).ToList(), OutputGene = OutputLayer.GetGenes() }); }
public IPredictorAlgorithmSettings Clone() => new NeuralNetworkSettingsEntity { Device = Device, PredictionType = PredictionType, HiddenLayers = HiddenLayers.Select(hl => hl.Clone()).ToMList(), OutputActivation = OutputActivation, OutputInitializer = OutputInitializer, LossFunction = LossFunction, EvalErrorFunction = EvalErrorFunction, Optimizer = Optimizer, LearningRate = LearningRate, MinibatchSize = MinibatchSize, NumMinibatches = NumMinibatches, BestResultFromLast = BestResultFromLast, SaveProgressEvery = SaveProgressEvery, SaveValidationProgressEvery = SaveValidationProgressEvery, };