use perceptron for training and testing