Question: Problem 2) [Python] Perceptron learning in Python: a) Create class NeuralNetwork(): that creates a single neuron, train it, and test it. This class should have

 Problem 2) [Python] Perceptron learning in Python: a) Create class NeuralNetwork():

Problem 2) [Python] Perceptron learning in Python: a) Create class NeuralNetwork(): that creates a single neuron, train it, and test it. This class should have the following function: i. def init (self): that initializes a 31 weight vector randomly and initializes the learning rate to 1. ii. def hard_limiter(self, x ): that performs the hard-limiter activation on the nxl vector x. iii. def forward propagation(self, inputs): that performs the forward propagation by multiplying the inputs by the neuron weights and passing the output through the hard limiter activation function. iv. def train(self, inputs, labels, num train iterations-10): that performs the perceptron leaming rule for num train iterations times using the inputs and labels. v. def pred(self, inputs); classifies the inputs to cither class 0 or 1 by multiplying them by the neuron weights, passing the output through the hard_limiter activation function and thresholding. b) Use the perceptron learning rule to train a single neuron on the data points given in problem 2: i. Create an np array of the shape of 62 that contains the inputs, and another array with the shape of 61 that contains the labels. ii. Add the bias to the input array to have a 63 shape. 2 iii. Create the network with one pereeptron using the elass NeuralNetwork(), then train it using train(imputs, labels, 100) function. c) Plot the given data points with two different markers for each group. d) Using the trained perceptron weight, plot the classifier line in the same plot in (c). e) Using the trained pereeptron, classify the test data samples given in the table below by calling the pred( ) function

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!