Generate response to images (tower, face, cat)
This script generates Figure 2 for the rivised ms:
Blessing of Dimensionality in Spiking Neural Networks: The by-chance functional learning by Makarov & Lobov
Valeri A. Makarov, vmakarov@ucm.es
May 2025.
Contents
Reset the environment
clear % close all addpath('./MatFunc')
Load images to use them as stimuli
FNms = {'tower.jpg','face.jpeg','cat.JPG'}; % files to read nIm = 20; % Final image size nIm x nIm nStims = length(FNms); x = cell(nStims,1); leg = cell(nStims,1); for k = 1:nStims x{k} = PrepareImage(['./CatTowerFace/' FNms{k}], nIm, [0.001 1]); [~,leg{k}] = fileparts(FNms{k}); end
Generate spike trains from images
Tmax = 1; % time interval for one stimulus [s] Fmax = 1000; % max frequency [Hz] n = nIm^2; % pattern dimension (flatten image) tij = []; % spike events frqs = zeros(n,nStims); % frequencies for each channel and stimulus for k = 1:nStims [aux, frqs(:,k)] = GenerateFrequencyPatterns(x{k}, Tmax, Fmax); aux(:,1) = aux(:,1) + (k-1)*Tmax; tij = [tij; aux]; end
Simulation of the response of neurons to a sequence of stimuli
h = 0.05; % integration step [ms] P.tau = 10; % synaptic time scale [ms] P.gamma = 10; % magnitude of the inhibitory current P.beta = 17; % magnitude of the excitatory current P.mu = 0.05; % scaling const for learning P.eta = 0.4; % relative learning rate % Run simulations rng(1) % for reproducibility v = cell(nStims,1); w = cell(nStims,1); for k = 1:nStims w0 = x{mod(k+1,nStims)+1}+0.5*randn(n,1); % random initial synaptic weights w0 = (w0 - min(w0))/(max(w0)-min(w0)); [~, v{k}, ~, w{k}] = IntegrateIzhikevich(h, nStims*Tmax, tij, w0, P); end
Plot results
figure('color','w','position',[100 100 700 500]) PlotResultsFig2(nStims*Tmax, tij, v, w, frqs/Fmax, leg)
