Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
work_dir
cifar-10-batches-py
code/nestml-target
code/__pycache__
202 changes: 102 additions & 100 deletions Fig4.ipynb

Large diffs are not rendered by default.

Binary file modified code/__pycache__/help_funcs.cpython-310.pyc
Binary file not shown.
Binary file modified code/__pycache__/help_funcs.cpython-39.pyc
Binary file not shown.
109 changes: 109 additions & 0 deletions code/contrast_calculator.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import pickle\n",
"\n",
"cifar_dir = \"/storage/ice1/7/8/jyou79/cifar-10-batches-py\"\n",
"cifar_65_dir = \"/storage/ice1/7/8/jyou79/cifar-10-batches-py-65\""
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"def rgb_to_grayscale(row):\n",
" R = row[:1024].reshape(32, 32)\n",
" G = row[1024:2048].reshape(32, 32)\n",
" B = row[2048:].reshape(32, 32)\n",
" grayscale = 0.299 * R + 0.587 * G + 0.114 * B\n",
" return grayscale\n",
" \n",
"with open(f'%s/data_batch_1'%(cifar_dir), 'rb') as f:\n",
" cifar = pickle.load(f, encoding='bytes') \n",
"cifar = np.array([rgb_to_grayscale(row) for row in cifar[b'data']])\n",
"cifar = cifar.astype(np.uint8)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"50.21379848461852\n",
"15.546079322771272\n"
]
}
],
"source": [
"stds = np.std(cifar, axis=(1, 2), keepdims=True)\n",
"avg_std = np.mean(stds)\n",
"std_std = np.std(stds)\n",
"means = np.mean(cifar, axis=(1, 2), keepdims=True)\n",
"print(avg_std)\n",
"print(std_std)\n",
"avg_std = 65"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"65.0\n"
]
}
],
"source": [
"adjusted_cifar = (cifar - means) / stds * avg_std + means\n",
"print(np.std(adjusted_cifar[0]))"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"with open(f'%s/data_batch_1'%(cifar_65_dir), 'wb') as f:\n",
" cifar = pickle.dump(adjusted_cifar, f) "
]
}
],
"metadata": {
"kernelspec": {
"display_name": "nest",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
4 changes: 2 additions & 2 deletions code/custom_model/install_dendritic.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
print(NEST_SIMULATOR_INSTALL_LOCATION)

generate_nest_target(input_path="iaf_cond_exp_dend.nestml",
target_path="/tmp/nestml-target",
target_path="tmp/nestml-target",
module_name="nestml_iaf_module",
suffix="_nestml",
logging_level="ERROR", # try "INFO" for more debug information
logging_level="INFO", # try "INFO" for more debug information
codegen_opts={"nest_path": NEST_SIMULATOR_INSTALL_LOCATION})

nest.Install("nestml_iaf_module")
Loading