126
126
#Plot results in real time
127
127
if plot_results > 0 and i%plot_results_interval==0:
128
weights_list = net.projection(pre='LGN', post='V1_Simple').values
129
nrows = 5#ceil(sqrt(len(weights_list)))
128
# weights_list is an array of arrayes. The first
129
# dimension reresents the index of the postsynaptic
130
# neuron, and the second the presynaptic. The layers are
132
weights_list = numpy.array(net.projection(pre='LGN', post='V1_Simple').values)
133
ndims = 2 # Number of layers/depth in the LGN
134
fielddim = int(sqrt(int(len(weights_list[0])/ndims))) # This is the visualized image's length/width, or receptive field dimentions. This assumes it is a square, so fielddim=height=width.
135
nneurons = weights_list.shape[0] # The number of postsynaptic neurons
136
nels = 30#nneurons*ndims # The number of images that must be plotted
137
ncols = round(2*sqrt(nels)) # The number of rows of subplots
138
nrows = ceil(nels/ncols) # The number of columns of subplots
130
140
print len(weights_list)
141
# This creats several subplots, each one containing an
142
# image. The image is the weight values of the
143
# feed-forward connections coming into each neuron in the
144
# V1_Simple layer, plotted spatially. Then, it draws it
145
# or writes it to a file.
132
for pn in range(0,nrows*nrows):
133
e = numpy.matrix(weights_list[pn])
134
e = e.reshape((8, 9))
135
ppl.subplot(nrows,nrows,pn+1)
136
ppl.imshow(e, cmap=cm.Greys_r)
147
for nn in range(0,nneurons): # nn = neuron number
149
e = e.reshape((fielddim,fielddim,ndims))
150
for dn in range(0,ndims): # dn = dimension number
152
if nn*ndims+dn > nrows*ncols: break
153
ppl.subplot(nrows,ncols,nn*ndims+dn)
154
ppl.imshow(esub, cmap=cm.Greys_r)
156
if (nn+1)*ndims > nrows*ncols: break
138
157
ppl.text(.05,.95,"Timestep: "+str(i), transform=_figure.transFigure)
139
158
if plot_results % 2 == 1: