fix the outputgradient bug