From the course: Computer Vision on the Raspberry Pi 4

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Classifying irises with a neural network

Classifying irises with a neural network

From the course: Computer Vision on the Raspberry Pi 4

Classifying irises with a neural network

- [Instructor/Educator]To start neural network development. I'll open ('iris.csv') as cvsfile. I'll set reader = csv.reader, which accepts the csvfile. Now I'll iterate through the rows. I want to use the first 140 rows for training and the last ten for testing. If I is less than 140, I'll add the first four values of each row to train features and the last value to train labels And I'll do the same thing for the test data. Now I'll create the neural network by setting net = cv2.ml.ANN_MPL_create{}. To set the network structure, I'll call net.setLayerSizes and provide an array containing the layer sizes, which I'll set to four, five, five, and three. Now I'll set the training method by calling net.setTrainMethod[CV2.ml.ANN_MLP_BACKPROP] I'll set the activation function by calling net.setActivationFunction[cv2.ml.ANN_MLP_SIGMOID_SYM] To train the network, I'll call the train method. This accepts the train features and…

Contents