Question: use Python. please answer all parts what information do you need? what info do you need? Problem 3) Gradient descent learning in Python: 1) Create

use Python. please answer all parts
use Python. please answer all parts what information do you need? what
what information do you need?
what info do you need?

Problem 3) Gradient descent learning in Python: 1) Create class NeuralNetworko: that creates a single neuron with a linear activation, train it using gradient descent learning. This class should have the following function: i def_init__(self, learning_r): that initializes a 3xl weight vector randomly and initializes the learning rate to learning r. Also, it creates a history variable that saves the weights and the training cost after each epoch (1.c., iteration) ii. def forward propagation(self, inputs): that performs the forward propagation by multiplying the inputs by the neuron weights and then generating the output, iii. def train(self, inputs_train, labels_train, num_train epochs=10): that performs the gradient descent learning rule for num_train epochs times using the inputs and labels. This function also saves the weights and costs at every epoch to the history variable. 2) Use the gradient descent rule to train a single neuron on the datapoints, given below: i. Create an np array of a shape 10x2 that contains the inputs, and another array with a shape 10xl that contains the labels. ii. Add the bias to the inputs array to have a 10x3 shape. iii. Create the network with one neuron using the class NeuralNetwork() with learning rate of 1 then train it using train(inputs, labels, 50) function. input desired label X2 1 0 1 1 1 -1 XI 1 1 0 - 1 0.5 0.7 - 1 - 1 2 -2 1 1 3 2 0 1 0 - 1 - 1 1 h) Plot the given data points with two different markers for each group. i) Use the trained weights at each epoch and plot the classifier lines of every 5 epochs (i.e., 1,5,10,..., 50) to the plot in (e). 1) Use the trained weights and plot the final classifier line to the plot in (c). k) Plot the training cost (i.e. the learning curve) for all the epochs. 1) Repeat step (b) with the learning rates of 0.5 and 0.05. Create a subplot with the learning curves of learning rates 1, 0.5, and 0.05. Add titles. m) What behavior do you observe from the learning curves with the different learning rates? Explain your observations, which leaming rate is more suitable? Explain. Problem 3) Gradient descent learning in Python: 1) Create class NeuralNetworko: that creates a single neuron with a linear activation, train it using gradient descent learning. This class should have the following function: i def_init__(self, learning_r): that initializes a 3xl weight vector randomly and initializes the learning rate to learning r. Also, it creates a history variable that saves the weights and the training cost after each epoch (1.c., iteration) ii. def forward propagation(self, inputs): that performs the forward propagation by multiplying the inputs by the neuron weights and then generating the output, iii. def train(self, inputs_train, labels_train, num_train epochs=10): that performs the gradient descent learning rule for num_train epochs times using the inputs and labels. This function also saves the weights and costs at every epoch to the history variable. 2) Use the gradient descent rule to train a single neuron on the datapoints, given below: i. Create an np array of a shape 10x2 that contains the inputs, and another array with a shape 10xl that contains the labels. ii. Add the bias to the inputs array to have a 10x3 shape. iii. Create the network with one neuron using the class NeuralNetwork() with learning rate of 1 then train it using train(inputs, labels, 50) function. input desired label X2 1 0 1 1 1 -1 XI 1 1 0 - 1 0.5 0.7 - 1 - 1 2 -2 1 1 3 2 0 1 0 - 1 - 1 1 h) Plot the given data points with two different markers for each group. i) Use the trained weights at each epoch and plot the classifier lines of every 5 epochs (i.e., 1,5,10,..., 50) to the plot in (e). 1) Use the trained weights and plot the final classifier line to the plot in (c). k) Plot the training cost (i.e. the learning curve) for all the epochs. 1) Repeat step (b) with the learning rates of 0.5 and 0.05. Create a subplot with the learning curves of learning rates 1, 0.5, and 0.05. Add titles. m) What behavior do you observe from the learning curves with the different learning rates? Explain your observations, which leaming rate is more suitable? Explain

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!