Commit 508ee78a authored by Stefan Behnel's avatar Stefan Behnel

optimise bpnn benchmark

parent f08c44cd
cimport cython
cdef double rand(double a, double b, random=*)
@cython.locals(i=Py_ssize_t)
cdef list makeMatrix(Py_ssize_t I, Py_ssize_t J, fill=*)
cdef class NN:
cdef Py_ssize_t ni, nh, no
cdef list ai, ah, ao
cdef list wi, wo
cdef list ci, co
@cython.locals(i=Py_ssize_t, j=Py_ssize_t, k=Py_ssize_t)
cpdef update(self, list inputs)
@cython.locals(i=Py_ssize_t, j=Py_ssize_t, k=Py_ssize_t, change=double)
cpdef double backPropagate(self, list targets, double N, M)
@cython.locals(i=Py_ssize_t, p=list, error=double)
cpdef train(self, list patterns, Py_ssize_t iterations=*, double N=*, M=*)
......@@ -15,8 +15,8 @@ import util
random.seed(0)
# calculate a random number where: a <= rand < b
def rand(a, b):
return (b-a)*random.random() + a
def rand(a, b, random=random.random):
return (b-a)*random() + a
# Make a matrix (we could use NumPy to speed this up)
def makeMatrix(I, J, fill=0.0):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment