Есть цикл
for j in range(epochs):
l0 = X
l1 = nonlin(np.dot(l0, syn0))
l2 = nonlin(np.dot(l1, syn1))
l2_error = y - l2
l2_delta = l2_error * nonlin(l2, deriv=True)
l1_error = l2_delta.dot(syn1.T)
l1_delta = l1_error * nonlin(l1, deriv=True)
syn1 += l1.T.dot(l2_delta)*lr
syn0 += l0.T.dot(l1_delta)*lr
Попробовал распараллелить с помощью map
def learn(syn0, syn1):
l0 = X
l1 = nonlin(np.dot(l0, syn0))
l2 = nonlin(np.dot(l1, syn1))
l2_error = y - l2
l2_delta = l2_error * nonlin(l2, deriv=True)
l1_error = l2_delta.dot(syn1.T)
l1_delta = l1_error * nonlin(l1, deriv=True)
syn1 += l1.T.dot(l2_delta) * lr
syn0 += l0.T.dot(l1_delta) * lr
pool = ThreadPool(4)
results = pool.map(learn(syn0, syn1, lr), epochs)
pool.close()
pool.join()
Но этот код выдает ошибку
Ошибка
File "Python\Python37-32\lib\multiprocessing\pool.py", line 268, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
File "AppData\Local\Programs\Python\Python37-32\lib\multiprocessing\pool.py", line 383, in _map_async
iterable = list(iterable)
TypeError: 'int' object is not iterable
Как мне распараллелить вычисления?