summaryrefslogtreecommitdiff
path: root/octave
diff options
context:
space:
mode:
authorJan Huwald <jh@sotun.de>2012-05-07 20:01:51 (GMT)
committerJan Huwald <jh@sotun.de>2012-05-07 20:01:51 (GMT)
commit420d2ef464d4a741028e132e662d5626806a41f5 (patch)
tree1aca6eb512e4ed0fb5f3c10c528cb998b6ffd695 /octave
Initial commitHEADmaster
Diffstat (limited to 'octave')
-rwxr-xr-xoctave/random_topo.octave71
1 files changed, 71 insertions, 0 deletions
diff --git a/octave/random_topo.octave b/octave/random_topo.octave
new file mode 100755
index 0000000..48a207f
--- /dev/null
+++ b/octave/random_topo.octave
@@ -0,0 +1,71 @@
+#!/usr/bin/octave --norc
+%% config
+% TODO: read these values from external definition
+num_neurons = 1000;
+connection_density = 0.1;
+inhibitory_fraction = 0.2;
+
+min_weight = 0;
+max_weight = 0.004;
+% implicit: fee = 1;
+fie = - 0.9; % orig: - 1;
+fei = 15 / 20;
+fii = 0;
+
+min_delay = 0.001; % hae? -> >= 0.1 ms
+max_delay = 0.005; % hae? -> < 2 ms
+
+max_fan_out = 126;
+fan_out = max_fan_out + 1;
+fan_out_miss = false;
+
+% fix seed
+% TODO: allow passing seed as param
+% TODO: change PRNG to MT
+rand("seed", str2num(argv(){1}));
+
+%% init weights
+while fan_out > max_fan_out,
+ if fan_out_miss,
+ fprintf(1,"generation failed: max fan out was %d, limit is %d\n", int32(fan_out), int32(max_fan_out));
+ end;
+ fan_out_miss = true;
+
+ % init with rand in [0.1]
+ weights = min_weight + (max_weight - min_weight) * rand(num_neurons);
+ weights = weights .* (rand(num_neurons) < connection_density);
+
+ l = num_neurons - inhibitory_fraction * num_neurons + 1;
+ h = num_neurons;
+
+ % make incoming and outgoing weight of each inhibitory neuron proportional
+ weights(1:(l-1), l:h) = weights(l:h, 1:(l-1))';
+
+ % scaling weights for inhibitory connections
+ weights(l:h, 1:(l-1)) = fie * weights(l:h, 1:(l-1));
+ weights(l:h, l:h) = fii * weights(l:h, l:h);
+ weights(1:(l-1), l:h) = fei * weights(1:(l-1), l:h);
+
+ % count fan_out
+ fan_out = max(sum(weights ~= 0, 2));
+end
+
+%% init delays
+delay = min_delay + (max_delay - min_delay) * rand(num_neurons);
+
+%% make inhibitory delays shorter
+delay(1:(l-1), l:h) = 0.1 * delay(1:(l-1), l:h);
+delay(l:h, 1:(l-1)) = 0.1 * delay(l:h, 1:(l-1));
+
+%% output
+format long E
+
+% topology config
+[ a, b ] = find(weights ~= 0);
+index = find(weights ~= 0);
+res = [ a, b, delay(index), weights(index) ];
+for i=1:length(res),
+ fprintf(2,"%d %d %e %e\n", int32(res(i,1))-1, int32(res(i,2))-1, res(i,3), res(i,4));
+end
+
+fprintf(1,"generation succesfull: %d synapses have been created, max fan out was %d (limit is %d)\n", int32(length(res)), int32(fan_out), int32(max_fan_out));
contact: Jan Huwald // Impressum