This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scipy.signal import lti | |
def synthetic_neuron(drive): | |
""" | |
Simulates a mock neuron with a time step of 1ms. | |
Arguments: | |
drive - input to the neuron (expect zero mean; SD=1) | |
Returns: | |
rho - response function (0=non-spike and 1=spike at each time step) | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
from collections import OrderedDict | |
import re | |
import ipdb | |
terms = OrderedDict([ | |
("loss", []), | |
("acc", []), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AltEcho(Network, Reservoir): | |
n_neurons = IntParam('n_neurons', default=None, low=1) | |
dimensions = IntParam('dimensions', default=None, low=1) | |
dt = NumberParam('dt', low=0, low_open=True) | |
recurrent_synapse = SynapseParam('recurrent_synapse') | |
gain = NumberParam('gain', low=0, low_open=True) | |
neuron_type = NeuronTypeParam('neuron_type') | |
def __init__(self, n_neurons, dimensions, recurrent_synapse=0.005, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import nengo | |
model = nengo.Network() | |
tau = 0.1 | |
ENS_SEED = 1 | |
ENS_N_NEURONS = 100 | |
with model: | |
# map from an oscilator to a pattern |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nengo | |
import numpy as np | |
fsp_res = 4 | |
with nengo.Network() as model: | |
def in_func(t, x): | |
idx = int((t * 100) % fsp_res) | |
val = np.ones(fsp_res) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
arr = ["A", "B", "C", "D"] | |
# I want this to cycle every 0.5s | |
# so I should see this list printed twice | |
# with each item printed 5 times | |
idx = 0 | |
arr_len = len(arr) | |
t_len = 0.5 |
We can make this file beautiful and searchable if this error is corrected: It looks like row 5 should actually have 9 columns, instead of 5 in line 4.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8.542434789160060007e-04,-1.350971841367669402e-03,1.550384660972889406e-03,-1.307484519870601028e-03,2.107574646523068668e-04,3.237310053764653507e-03,1.394481474505514240e-01,-1.792572594477088305e-02,-2.111017965516969602e-02 | |
3.533282465411854457e-04,-1.791492879237178287e-04,-1.855709995653045778e-05,-1.743758953232064799e-05,-5.210966224063090816e-04,8.930201575643531564e-03,1.484517136801228286e-02,-5.073399737080908599e-03,-4.473903762570220072e-03 | |
3.489375633978934526e-04,2.451122643889763362e-04,-3.875986947442373572e-04,-1.169205067765441490e-04,-9.721645615909121994e-04,2.279935780598136771e-02,-3.499863181452933167e-03,-8.442464679787089685e-03,-5.066224544366498307e-03 | |
3.980971182798381065e-04,5.015236582029211241e-04,-3.386030423717702469e-04,-1.515841152880205217e-04,-9.852177501969410639e-04,3.279147360274248940e-02,-5.284202821373784088e-03,-1.248557779964556969e-02,-7.195257440400722876e-03 | |
5.126948644180514148e-04,1.014624534055026325e-03,-6.748874637068998008e-04,-3.067420521247723108e-04, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nengo | |
# create a configuration for a threshold of 0.3 | |
thresh_config = nengo.presets.ThresholdingEnsembles(0.3) | |
with nengo.Network() as model: | |
# make a cycling ramp input to show the threshold is working | |
in_node = nengo.Node(lambda t: 2*(t % 1) - 1) | |
# make an ensemble with the thresholding configuration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nengo | |
from nengo import spa | |
D = 32 | |
vocab = spa.Vocabulary(D) | |
vocab.add("CALI", vocab.parse("0.1*WHITE + 0.9*HISPANIC")) | |
vocab.add("KANSAS", vocab.parse("0.7*WHITE + 0.3*HISPANIC")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Iterates through a directory of exported MindMup .mup files and prints the title of each file that matches the given | |
regular expression, as well as the matched node contents. | |
MindMup is a mind mapping tool which represents the Directed Acyclic Graph (DAG) of a mind map as a nested dictionary encoded as JSON. | |
""" | |
import argparse | |
import json | |
from pathlib import Path |