Question
(Machine Learning) ''' program perceptron with one output ''' import numpy as np class perceptron: def __init__(self, inputs): self.n_data = np.shape(inputs)[1] self.n_out = 1 self.weights
(Machine Learning)
''' program perceptron with one output ''' import numpy as np class perceptron: def __init__(self, inputs): self.n_data = np.shape(inputs)[1] self.n_out = 1 self.weights = np.random.rand(self.n_data + 1, self.n_out) * 0.1 - 0.05 ''' def ptron_train(): for data in range(n_data): # compute w dot x and apply activation. M is the number of features # for OR or XOR, it will be 2 activation[data] = 0 for m in range(M + 1): ''' if __name__ == '__main__': # OR gate data_or = np.array([[0,0,0], [0,1,1], [1,0,1], [1,1,1]]) print(data_or) print(np.shape(data_or)[0]) ptron_or = perceptron(data_or) print(ptron_or.weights)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started