Skip to content

Instantly share code, notes, and snippets.

View Seanny123's full-sized avatar
💭
>.<

Sean Aubin Seanny123

💭
>.<
View GitHub Profile
@Seanny123
Seanny123 / synth_neuron.py
Created March 22, 2016 20:13
Synthetic Neuron for SYDE552
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)
"""
@Seanny123
Seanny123 / parse.py
Created April 26, 2016 16:56
Simple script for parsing Keras training console output and putting it into a Pandas dataframe
import pandas as pd
import numpy as np
from collections import OrderedDict
import re
import ipdb
terms = OrderedDict([
("loss", []),
("acc", []),
@Seanny123
Seanny123 / alt_echo.py
Created May 6, 2016 23:02
Terry's alternate reservoir computing implementation
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,
@Seanny123
Seanny123 / direct_decode.py
Created May 16, 2016 22:07
Getting decoders for a mapping.
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
@Seanny123
Seanny123 / bar_plot_test.py
Created June 13, 2016 22:25
Bar plot example
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)
@Seanny123
Seanny123 / cycle_arr.py
Created August 23, 2016 14:38
How to cycle through an array
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.
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,
@Seanny123
Seanny123 / threshold_example.py
Created October 15, 2016 00:05
Nengo thresholding neuron ensemble example
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
@Seanny123
Seanny123 / compare_example.py
Created October 15, 2016 00:30
Nengo spa.Compare example
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"))
@Seanny123
Seanny123 / search_mup.py
Last active January 15, 2023 20:17
Go through a bunch of exported MindMup .mup files looking for text
"""
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