added getgradient method to neural net to check correctness