private (Vector diffTanhGate, Vector diffInputGate, Vector diffForgetGate, Vector diffOutputGate) GetDiffForGates(Vector diffForget, Vector diffOutput) { var diffTanhGate = diffForget * InputLayerGateResultI * Tanh.DeriveFunc(TanhLayerGateResultG); var diffInputGate = diffForget * TanhLayerGateResultG * Sigmoid.DeriveFunc(InputLayerGateResultI); var diffForgetGate = diffForget * ForgetFromPreviousLayer * Sigmoid.DeriveFunc(ForgetGateResultF); var diffOutputGate = diffOutput * Tanh.Func(Forget) * Sigmoid.DeriveFunc(OutputLayerGateResultO); return(diffTanhGate, diffInputGate, diffForgetGate, diffOutputGate); }