Modified perceptron train and test