finish implementation of training method, sgd.