Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
508ee78a
Commit
508ee78a
authored
Aug 12, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimise bpnn benchmark
parent
f08c44cd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
2 deletions
+23
-2
Demos/benchmarks/bpnn3.pxd
Demos/benchmarks/bpnn3.pxd
+21
-0
Demos/benchmarks/bpnn3.py
Demos/benchmarks/bpnn3.py
+2
-2
No files found.
Demos/benchmarks/bpnn3.pxd
0 → 100644
View file @
508ee78a
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
=*
)
Demos/benchmarks/bpnn3.py
View file @
508ee78a
...
...
@@ -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
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment