Fix the calculation of gradient factor
Signed-off-by: Xavier Yao <xavieryao@live.cn>