Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
arbor
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
arbor-sim
arbor
Commits
5a766b1f
Unverified
Commit
5a766b1f
authored
Mar 11, 2022
by
Thorsten Hater
Committed by
GitHub
Mar 11, 2022
Browse files
Options
Downloads
Patches
Plain Diff
Make brunel.py setup faster. (#1854)
* Make brunel.py setup faster. * Use one generator for both populations.
parent
11198bb9
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/example/brunel.py
+12
-11
12 additions, 11 deletions
python/example/brunel.py
with
12 additions
and
11 deletions
python/example/brunel.py
+
12
−
11
View file @
5a766b1f
#!/usr/bin/env python3
#!/usr/bin/env python3
import
arbor
import
arbor
import
numpy
,
argparse
import
argparse
import
numpy
as
np
from
numpy.random
import
RandomState
'''
'''
A Brunel network consists of nexc excitatory LIF neurons and ninh inhibitory LIF neurons.
A Brunel network consists of nexc excitatory LIF neurons and ninh inhibitory LIF neurons.
...
@@ -20,14 +22,12 @@ Call with parameters, for example:
...
@@ -20,14 +22,12 @@ Call with parameters, for example:
# Samples m unique values in interval [start, end) - gid.
# Samples m unique values in interval [start, end) - gid.
# We exclude gid because we don't want self-loops.
# We exclude gid because we don't want self-loops.
def
sample_subset
(
gid
,
start
,
end
,
m
):
def
sample_subset
(
gen
,
gid
,
start
,
end
,
m
):
gen
=
numpy
.
random
.
RandomState
(
gid
+
42
)
idx
=
np
.
arange
(
start
,
end
)
s
=
set
()
if
start
<=
gid
<
end
:
while
len
(
s
)
<
m
:
idx
=
np
.
delete
(
idx
,
gid
-
start
)
val
=
gen
.
randint
(
low
=
start
,
high
=
end
)
gen
.
shuffle
(
idx
)
if
val
!=
gid
:
return
idx
[:
m
]
s
.
add
(
val
)
return
s
class
brunel_recipe
(
arbor
.
recipe
):
class
brunel_recipe
(
arbor
.
recipe
):
def
__init__
(
self
,
nexc
,
ninh
,
next
,
in_degree_prop
,
weight
,
delay
,
rel_inh_strength
,
poiss_lambda
,
seed
=
42
):
def
__init__
(
self
,
nexc
,
ninh
,
next
,
in_degree_prop
,
weight
,
delay
,
rel_inh_strength
,
poiss_lambda
,
seed
=
42
):
...
@@ -61,12 +61,13 @@ class brunel_recipe (arbor.recipe):
...
@@ -61,12 +61,13 @@ class brunel_recipe (arbor.recipe):
return
arbor
.
cell_kind
.
lif
return
arbor
.
cell_kind
.
lif
def
connections_on
(
self
,
gid
):
def
connections_on
(
self
,
gid
):
gen
=
RandomState
(
gid
+
self
.
seed_
)
connections
=
[]
connections
=
[]
# Add incoming excitatory connections.
# Add incoming excitatory connections.
for
i
in
sample_subset
(
gid
,
0
,
self
.
ncells_exc_
,
self
.
in_degree_exc_
):
for
i
in
sample_subset
(
gen
,
gid
,
0
,
self
.
ncells_exc_
,
self
.
in_degree_exc_
):
connections
.
append
(
arbor
.
connection
((
i
,
"
src
"
),
"
tgt
"
,
self
.
weight_exc_
,
self
.
delay_
))
connections
.
append
(
arbor
.
connection
((
i
,
"
src
"
),
"
tgt
"
,
self
.
weight_exc_
,
self
.
delay_
))
# Add incoming inhibitory connections.
# Add incoming inhibitory connections.
for
i
in
sample_subset
(
gid
,
self
.
ncells_exc_
,
self
.
ncells_exc_
+
self
.
ncells_inh_
,
self
.
in_degree_inh_
):
for
i
in
sample_subset
(
gen
,
gid
,
self
.
ncells_exc_
,
self
.
ncells_exc_
+
self
.
ncells_inh_
,
self
.
in_degree_inh_
):
connections
.
append
(
arbor
.
connection
((
i
,
"
src
"
),
"
tgt
"
,
self
.
weight_inh_
,
self
.
delay_
))
connections
.
append
(
arbor
.
connection
((
i
,
"
src
"
),
"
tgt
"
,
self
.
weight_inh_
,
self
.
delay_
))
return
connections
return
connections
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment