Skip to content

Instantly share code, notes, and snippets.

@neworderofjamie
neworderofjamie / sub_row_estimation.ipynb
Created November 2, 2016 15:33
Estimation of how a row of synapses will be split into delay sub-rows
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@neworderofjamie
neworderofjamie / sub_row_memory_estimation.ipynb
Created November 4, 2016 13:21
maximum_matrix_size_estimate
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#include "definitionsInternal.h"
#include "supportCode.h"
extern "C" __global__ void preNeuronResetKernel() {
unsigned int id = 32 * blockIdx.x + threadIdx.x;
if(id == 0) {
dd_glbSpkCntE[0] = 0;
}
else if(id == 1) {
dd_glbSpkCntI[0] = 0;
#include <fstream>
#include <string>
#include <thread>
#include <vector>
void write(unsigned int thread)
{
std::ofstream stream("test_" + std::to_string(thread) + ".txt");
stream << "test" << std::endl;
stream << "thread" << std::endl;
@neworderofjamie
neworderofjamie / spiking_toeplitz
Created August 9, 2021 14:50
Spike propagation through Toeplitz matrix
{
"cells": [
{
"cell_type": "code",
"execution_count": 167,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
@neworderofjamie
neworderofjamie / spiking_toeplitz.ipynb
Last active October 28, 2021 11:38
Spike propagation through Toeplitz matrix
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import os, pathlib
import tensorflow as tf
from tensorflow.keras import (models, layers, datasets, callbacks, optimizers,
initializers, regularizers)
from tensorflow.keras.utils import CustomObjectScope
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from glob import glob
import numpy as np
# Learning rate schedule
@neworderofjamie
neworderofjamie / izhikevich.cu
Created March 7, 2022 15:28
Sample GeNN-like CUDA code for simulating Izhikevich neurons
// C++ includes
#include <algorithm>
#include <fstream>
// ------------------------------------------------------------------------
// Helper macro for error-checking CUDA calls
#define CHECK_CUDA_ERRORS(call) {\
cudaError_t error = call;\
if (error != cudaSuccess) {\
throw std::runtime_error(__FILE__": " + std::to_string(__LINE__) + ": cuda error " + std::to_string(error) + ": " + cudaGetErrorString(error));\
import numpy as np
import matplotlib.pyplot as plt
spikes = np.loadtxt("spikes.csv", delimiter=",")
voltages = np.loadtxt("voltages.csv", delimiter=",")
fig, axes = plt.subplots(5, sharex=True)
for i in range(4):
axes[i].plot(voltages[:,0], voltages[:,i+1])
import numpy as np
from os import path
from ml_genn import InputLayer, Layer, SequentialModel
from ml_genn.compilers import Compiler
from ml_genn.neurons import IntegrateFire, IntegrateFireInput
from ml_genn.connectivity import Dense
# Load weights
weights = []