add common interface for layer-wise training and fix some style problem