fix build error in gcc
implement SGD, add some comments, refactoring