I am aware how the yield keyword is used in python to return the generators some thing like this
def example_function():
for i in xrange(1, 10)
yield i
But I have code like this
def feed_forward(self,inputs):
activations = [inputs]
for I in xrange(len(self.weights)):
activation = activations[i].dot(self.weights[i])
activations.append(activation)
return activations
Where the list going to be created is itself required in the iteration inside the function.
How do I rewrite the code to more pythonic code, by using the yield keyword?