x

%timeit x.flatten()


error = .235
vector = np.asarray([1,2,3,4,5,6,7])
weights = np.asarray([1,2,3,4,5,6,7])


def loop(error, weights, vector):
    l_rate = .1
    correction = l_rate * error
    for idx, item in enumerate(vector):
            weights[idx] += (item * correction)
%timeit loop(error, weights, vector)


error = .235
vector = np.asarray([1,2,3,4,5,6,7])
weights = np.asarray([1,2,3,4,5,6,7])


def loop(error, weights, vector):
    l_rate = .1
    correction = l_rate * error
    y = [x * correction for x in vector]      
    z = map(add, weights, y)
    
%timeit loop(error, weights, vector)


error = .235
vector = np.asarray([1,2,3,4,5,6,7])
weights = np.asarray([1,2,3,4,5,6,7])


def map_loop(error, weights, vector):
    l_rate = .1
    error = .235
    correction = l_rate * error
    corr_matrix = np.multiply(vector, correction)
    weights = map(add, weights, corr_matrix)
    
%timeit map_loop(error, weights, vector)



"""
Explanation: Expit it is!  Now to determine the fastest gradient descent function.
End of explanation
"""


def square(x):
    return x*x

a = [1,2,3,4,5]
b = map(square, a)
c = map(square, b)
d = list(c)
d
f = np.dot(np.fromiter(b, np.float), np.fromiter(c, np.float))
a
f

"""
Explanation: Maybe there is a way to leave weights as a generator object.
Test by leaving it as a map object and updating again
End of explanation
"""


