New working version. Now I can arbitrarily choose the number of training data I wanna use.