public void LayerRegularizationPenalty(int fromLayer, double[] l) { int fromCount = _network.GetLayerTotalNeuronCount(fromLayer); int toCount = _network.GetLayerNeuronCount(fromLayer + 1); for (int fromNeuron = 0; fromNeuron < fromCount; fromNeuron++) { for (int toNeuron = 0; toNeuron < toCount; toNeuron++) { double w = _network.GetWeight(fromLayer, fromNeuron, toNeuron); l[0] += Math.Abs(w); l[1] += w * w; } } }