$0.28

Build a class 'Neuron', which should have this methods

Ask a question+
1

init. Takes as argument list of weights of a neuron —- w=(w1,…,wn) , and a function of activation f (by default f(x)=x ). Saves the weights and a function inside the class.

forward. Takes as argument list x=(x1,…,xN) —- neuron inputs. Returns f(w1x1+…+wnxn) .

backlog. Returns last list x , which have been given to forward as argument.
`# I strongly do not recommend to change any written code here

just add your code and finish class methods

class Neuron:
def __init__(self, w, f = lambda x: x):
    #YOUR CODE HERE

def forward(self, x):
    #YOUR CODE HERE

def backlog(self):
    #YOUR CODE HERE`



import math

w = [0.5, 1., -1., 2.]

neuron = Neuron([0.5, 1., -1., 2.], lambda x: 1. / (1 + math.exp(x)))

x = [1, 2, 3, 4]
print(neuron.forward(x))`
add comment

0 Answer

Your Answer