public Vec Backpropagate() { if (NextLayer == null) { throw new NotSupportedException("Cannot backpropagate errors on output layer"); } if (PreviousLayer == null) { throw new NotSupportedException("Cannot backpropagate errors on input layer"); } if (NextLayer.Errors == null) { throw new InvalidOperationException("Cannot backpropagate when next layer's errors are null"); } if (ZValues == null) { throw new InvalidOperationException("Cannot backpropagate before forward propagation"); } var primeOfZs = Activator.ActivatePrime(ZValues); _errors = NextLayer.Weights.TransposeThisAndMultiply(NextLayer.Errors).PointwiseMultiply(primeOfZs); return(_errors); }