Skip to content

Commit

Permalink
Updated example notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
hakonsbm committed Sep 26, 2022
1 parent 3a3776d commit 33b6584
Showing 1 changed file with 29 additions and 135 deletions.
164 changes: 29 additions & 135 deletions pynest/examples/Connection_semantics_prototype_examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@
"\n",
"## What is currently implemented\n",
"\n",
"- A PyNEST interface with several projection classes, implemented in a submodule `nest.projections`.\n",
"- A PyNEST interface with several projection classes, implemented in the top level of `nest`.\n",
"- `nest.Connect()` now only works with projection objects.\n",
"- Projections work with both normal connections, and spatially structured connections involving for example distance based probabilities or masks.\n",
"- Classes for some of the synapse models, in the submodule `nest.synapsemodels`. The synapse object created can be used as the synapse specification when creating projections.\n",
"- Classes for all synapse models, in the submodule `nest.synapsemodels`. The synapse object created can be used as the synapse specification when creating projections.\n",
"- Synapse objects can be combined with `CollocatedSynapses`, and used instead of a single synapse model object when creating a projection.\n",
"- Basic C++ implementation for connection, without any processing of the projections before connecting."
"- Basic C++ implementation for connection, without any processing of the projections before connecting.\n",
"\n",
"## Remaining work and next steps\n",
"\n",
"- Documentation\n",
"- Smarter C++ implementation"
]
},
{
Expand All @@ -38,7 +44,7 @@
"source": [
"## Projection object\n",
"\n",
"Introducing the Projection object, representing projection between two populations with a certain rule. The projection object is added to a buffer with `projections.Connect()`, and held until calling `projections.BuildNetwork()`.\n",
"Introducing the Projection object, representing projection between two populations with a certain rule. The projection object is added to a buffer with `Connect()`, and held until calling `BuildNetwork()`.\n",
"\n",
"### `OneToOne`"
]
Expand Down Expand Up @@ -145,9 +151,7 @@
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -200,16 +204,13 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### `PairwiseBernoulli`\n",
"Projections can store synapse specifications."
"### `PairwiseBernoulli`"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -302,12 +303,12 @@
"metadata": {},
"source": [
"## Multiple projections\n",
"Multiple Projections can be added to the buffer before connecting by calling `projections.Connect()` multiple times."
"Multiple Projections can be added to the buffer before connecting, by calling `Connect()` multiple times."
]
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 7,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -375,7 +376,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 8,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -435,121 +436,19 @@
"print(conns)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Using `ConnectImmediately()`\n",
"Using `projections.ConnectImmediately()` will immediately construct the connections of a Projection."
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" source target synapse model weight delay \n",
"-------- -------- --------------- -------- -------\n",
" 1 1 static_synapse 1.000 1.000\n",
" 2 2 static_synapse 1.000 1.000\n",
" 3 3 static_synapse 1.000 1.000\n",
" 4 4 static_synapse 1.000 1.000\n",
" 5 5 static_synapse 1.000 1.000\n"
]
}
],
"source": [
"nest.ResetKernel()\n",
"\n",
"n = nest.Create('iaf_psc_alpha', 5)\n",
"nest.ConnectImmediately(nest.OneToOne(source=n, target=n))\n",
"\n",
"conns = nest.GetConnections()\n",
"print(conns)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Or for all Projections in a list."
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" source target synapse model weight delay \n",
"-------- -------- --------------- -------- -------\n",
" 1 4 static_synapse 1.000 1.000\n",
" 1 4 static_synapse 1.000 1.000\n",
" 1 5 static_synapse 1.000 1.000\n",
" 1 3 static_synapse 1.000 1.000\n",
" 1 2 static_synapse 1.000 1.000\n",
" 1 5 static_synapse 1.000 1.000\n",
" 2 3 static_synapse 1.000 1.000\n",
" 2 5 static_synapse 1.000 1.000\n",
" 2 4 static_synapse 1.000 1.000\n",
" 3 5 static_synapse 1.000 1.000\n",
" 3 2 static_synapse 1.000 1.000\n",
" 3 3 static_synapse 1.000 1.000\n",
" 3 5 static_synapse 1.000 1.000\n",
" 3 5 static_synapse 1.000 1.000\n",
" 3 1 static_synapse 1.000 1.000\n",
" 3 1 static_synapse 1.000 1.000\n",
" 3 3 static_synapse 1.000 1.000\n",
" 4 2 static_synapse 1.000 1.000\n",
" 4 2 static_synapse 1.000 1.000\n",
" 4 3 static_synapse 1.000 1.000\n",
" 4 4 static_synapse 1.000 1.000\n",
" 4 4 static_synapse 1.000 1.000\n",
" 4 4 static_synapse 1.000 1.000\n",
" 4 3 static_synapse 1.000 1.000\n",
" 4 2 static_synapse 1.000 1.000\n",
" 5 2 static_synapse 1.000 1.000\n",
" 5 1 static_synapse 1.000 1.000\n",
" 5 1 static_synapse 1.000 1.000\n",
" 5 1 static_synapse 1.000 1.000\n",
" 5 1 static_synapse 1.000 1.000\n"
]
}
],
"source": [
"nest.ResetKernel()\n",
"\n",
"N = 5\n",
"IN_A = 2\n",
"IN_B = 4\n",
"n = nest.Create('iaf_psc_alpha', N)\n",
"\n",
"projections = [nest.FixedIndegree(source=n, target=n, indegree=IN_A),\n",
" nest.FixedIndegree(source=n, target=n, indegree=IN_B)]\n",
"nest.ConnectImmediately(projections)\n",
"\n",
"conns = nest.GetConnections()\n",
"print(conns)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Synapse model object\n",
"We introduce synapse model objects, which hold information previously passed as a `dict` to `syn_spec`.\n",
"\n",
"### `static_synapse`"
]
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 9,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -590,7 +489,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 10,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -641,7 +540,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 11,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -700,12 +599,13 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Using `CollocatedSynapses` in projections"
"### Using `CollocatedSynapses` in projections\n",
"Projections support passing a `CollocatedSynapses` object as `syn_spec`. With `CollocatedSynapses`, connections with different synapse parameters can be created between the same nodes."
]
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 12,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -749,12 +649,13 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Spatial connections"
"### Spatial connections\n",
"Projections for spatial connections are created the same way as regular connections."
]
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 13,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -815,7 +716,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 14,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -866,13 +767,6 @@
"conns = nest.GetConnections()\n",
"print(conns)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -891,7 +785,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.2"
"version": "3.9.12"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 33b6584

Please sign in to comment.