-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTimeAsMemory.m
490 lines (417 loc) · 22.5 KB
/
TimeAsMemory.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
function [intervals,representations] = TimeAsMemory(inputType, outputType, fixedLocation, ...
memorynoise, networknoise,showcolumnsgraph,...
showMainGraphs,trackdevelopment,showCorrelations, ...
showAttentionEffects)
% example of a neural network implementation of Embodied Memory model of
% time perception.
%
% The basic idea is in a mature system the time interval since an event
% is derived from of how blurry (some aspect of) the memory for
% the perceptual event has become. An immature system calibrates this
% mechanism using the predictable and repeatable signals from physical
% movements. These obey Fitt's law which is a direct analogue of the Scalar
% Property in interval timing.
% In this version, a network is 1st trained to predict the length of an
% interval from 1 distribution. Input is distribution of activations along
% a 1d vector and output is a log-scale counter (aka ATOM representation)
%
% Caspar Addyman 2010
% version 01 - 26 Sep 2010
% version 02 - 16 Dec 2010
% version 03 - 23 Jan 2011 - calibration version
% version 04 - 07 Apr 2012 - version for NCPW
close all;
%input curve types
ANALYTIC_GAUSSIAN = 0;
FADING_GAUSSIAN = 1;
%output curve types
LINEAR_OUTPUT = 1;
LOGLINEAR_OUTPUT = 0;
% Default settings
if nargin < 1, inputType = ANALYTIC_GAUSSIAN; end %what shape is input function
if nargin < 2, outputType = LOGLINEAR_OUTPUT; end %what shape is input function
if nargin < 3, fixedLocation = true; end %is percept centred on input field?
if nargin < 4, memorynoise = false; end %is memory representation noisy
if nargin < 5, networknoise = true; end %internal network noise
if nargin < 6, showcolumnsgraph = true; end %show graph of co
if nargin < 7, showMainGraphs = true; end %show graph of main results
if nargin < 8, trackdevelopment = true; end %make note of weights at intervvals during learning
if nargin < 9, showCorrelations = false; end %plot graph of correlation between modalities over learning
if nargin < 10, showAttentionEffects = false; end
includemodalitytwo = true;
modalitycount = 1 + includemodalitytwo;
nBabies = 20;
NEpochs = 10;
NTrainingItems = 5000;
LearningRate = 0.01;
momentum = 0.005;
OutputLoopSize = 10; %used for finding mean & std of network outputs
minInterval = 0.1; %seconds
maxInterval = 120; %seconds
numIntervals = 60;
%network architecture
inputWidth = 41; %how wide is input vector?
nHidNodes = 10;
outputWidth = 10; %how wide is output vector
%Analytic Gaussian params
memoryWidthUnit = 5;
memoryTimeUnit = 45;
memoryAmplitude = 2;
%Fading Gaussian params
spread_factor = 0.0045;
leakage_factor = 0.0105;
self_excitation = 0.001;
if networknoise
networknoiserate = 0.06;
else
networknoiserate = 0;
end
if memorynoise
%two types
%fixed amounts of noise added to all input nodes
memorynoise_fixed_mean = 0.05;
memorynoise_fixed_sd = 0.02;
%relative noise, sd is proportional to activation
memorynoise_proportional_sd = 0.03; %added to all input nodes
end
%%%%%%%%%%%%%%%%%%% INPUTS %%%%%%%%%%%%%%%%%%%%%%%%
% what type of input (& test) distribution do we have?
%
% we claim that memory is normal distribution that decays analogously to Fitt's law.
% so if width of stdev after K seconds is W, after 2K seconds it will be 2W
% therefore we need to specify a scale for both
%
% percept = setPercepts(inputType, minInterval,maxInterval,numIntervals, ...
% inputWidth,outputWidth,fixedLocation,...
% memoryWidthUnit,memoryTimeUnit,memoryAmplitude,...
% spread_factor,leakage_factor,self_excitation, ...
% lognormalIntervals,useBODYMapRepresentation,useBODYBinaryOut)
modality{1} = setPercepts(inputType,minInterval,maxInterval,numIntervals, ...
inputWidth, outputWidth,fixedLocation, ...
memoryWidthUnit,memoryTimeUnit,memoryAmplitude, ...
spread_factor,leakage_factor,self_excitation, ...
false, outputType, false);
modality{1} = populateInputsOutputs(modality{1});
%for the moment the second modality is very similar to first
modality{2} = setPercepts(inputType,minInterval,maxInterval,numIntervals, ...
inputWidth, outputWidth,fixedLocation, ...
memoryWidthUnit,memoryTimeUnit,memoryAmplitude, ...
spread_factor,leakage_factor,self_excitation, ...
false, outputType, false);
modality{2} = populateInputsOutputs(modality{2});
%%%%%%%%%%%%% EFFECT OF ATTENTION %%%%%%%%%%%%%%%%%%%%%%%%%%%
%another version of the same inputs and outputs but modulated by attention
% do this by applying multiplier to self-excitation
attentionMultiplier = 1.4;
attention{1} = setPercepts(inputType,minInterval,maxInterval,numIntervals, ...
inputWidth, outputWidth,fixedLocation, ...
memoryWidthUnit/ attentionMultiplier,memoryTimeUnit,memoryAmplitude, ...
spread_factor,leakage_factor,self_excitation * attentionMultiplier , ...
false, outputType, false);
attention{1} = populateInputsOutputs(attention{1});
attention{2} = setPercepts(inputType,minInterval,maxInterval,numIntervals, ...
inputWidth, outputWidth,fixedLocation, ...
memoryWidthUnit/attentionMultiplier,memoryTimeUnit,memoryAmplitude, ...
spread_factor,leakage_factor,self_excitation * attentionMultiplier, ...
false, outputType, false);
attention{2} = populateInputsOutputs(attention{1});
%%%%%%%%% SIMULATE N Babies %%%%%%%%%%%%%%%%%%%%%%
% so we can average performance
Baby = cell(nBabies,1);
for babycounter = 1:nBabies
for mod = 1:modalitycount
% sample random intervals in the approriate range (0.1 to 90s).
% perhaps these ought to have a poisson distribution but don't at the moment
% can just randomly sample from the rows of allPossibleIntervals
Baby{babycounter}.Modality{mod}.rows = randi([modality{mod}.numIntervals],NTrainingItems,1);
Baby{babycounter}.Modality{mod}.MemoryInputs = modality{mod}.MemoryCurves(Baby{babycounter}.Modality{mod}.rows, :);
Baby{babycounter}.Modality{mod}.ATOMOutputs = modality{mod}.ATOMOutputs(Baby{babycounter}.Modality{mod}.rows,:);
Baby{babycounter}.Modality{mod}.BODYOutputs = modality{mod}.BODYOutputs(Baby{babycounter}.Modality{mod}.rows,:);
if memorynoise
[R,C] = size(Baby{babycounter}.Modality{mod}.MemoryInputs);
Baby{babycounter}.Modality{mod}.NoisyInputs = Baby{babycounter}.Modality{mod}.MemoryInputs + ...
memorynoise_proportional_sd * Baby{babycounter}.Modality{mod}.MemoryInputs .* randn(R,C);
Baby{babycounter}.Modality{mod}.NoisyInputs = Baby{babycounter}.Modality{mod}.NoisyInputs + ...
memorynoise_fixed_mean + memorynoise_fixed_sd * rand(R,C);
else
Baby{babycounter}.Modality{mod}.NoisyInputs = Baby{babycounter}.Modality{mod}.MemoryInputs;
end
%%%%%%%%%%% the actual network training stage %%%%%%%%%%%%%%%
%%%%%%%%%%% using back prop.
if modality{1}.UseBODYMapRepresentation
[Baby{babycounter}.Modality{mod}.wt1 Baby{babycounter}.Modality{mod}.wt2] = backprop(Baby{babycounter}.Modality{mod}.NoisyInputs,Baby{babycounter}.Modality{mod}.BODYOutputs,nHidNodes,LearningRate,NEpochs,networknoiserate, momentum, 1,trackdevelopment);
else
[Baby{babycounter}.Modality{mod}.wt1 Baby{babycounter}.Modality{mod}.wt2] = backprop(Baby{babycounter}.Modality{mod}.NoisyInputs,Baby{babycounter}.Modality{mod}.ATOMOutputs,nHidNodes,LearningRate,NEpochs,networknoiserate, momentum, 1,trackdevelopment);
end
% %record the final weights
% wt1 = Baby{babycounter}.Modality{mod}.wt1{NEpochs};
% wt2 = Baby{babycounter}.Modality{mod}.wt2{NEpochs};
% save('trainedweights1.mat', 'wt1', 'wt2');
for devstage = 1 :NEpochs
% now get set of representative outputs from our our trained network
% present each of the possible curves and see network prediction
% do this multiple times to get the prediction error (i.e. scalar property)
[R,C] = size(modality{mod}.MemoryCurves);
for k = 1:OutputLoopSize
if memorynoise
%add noise to memory decay curves
modality{mod}.NoisyInputs = modality{mod}.MemoryCurves + ...
memorynoise_proportional_sd * modality{mod}.MemoryCurves .* randn(R,C);
modality{mod}.NoisyInputs = modality{mod}.NoisyInputs + ...
memorynoise_fixed_mean + memorynoise_fixed_sd * rand(R,C);
%same for attention curves
attention{mod}.NoisyInputs = attention{mod}.MemoryCurves + ...
memorynoise_proportional_sd * attention{mod}.MemoryCurves .* randn(R,C);
attention{mod}.NoisyInputs = attention{mod}.NoisyInputs + ...
memorynoise_fixed_mean + memorynoise_fixed_sd * rand(R,C);
else
modality{mod}.NoisyInputs = modality{mod}.MemoryCurves;
attention{mod}.NoisyInputs = attention{mod}.MemoryCurves;
end
%record the network outputs
Baby{babycounter}.Modality{mod}.TrainedOutputs{devstage}{k} = backprop_out(modality{mod}.NoisyInputs,Baby{babycounter}.Modality{mod}.wt1{devstage},Baby{babycounter}.Modality{mod}.wt2{devstage},networknoiserate);
Baby{babycounter}.Modality{mod}.AttentionOutputs{devstage}{k} = backprop_out(attention{mod}.NoisyInputs,Baby{babycounter}.Modality{mod}.wt1{devstage},Baby{babycounter}.Modality{mod}.wt2{devstage},networknoiserate);
%convert network output representation into a time value
if modality{mod}.UseBODYMapRepresentation
Baby{babycounter}.Modality{mod}.TrainedOutTimes{devstage}(k,:) = BODYMapRepresentation(Baby{babycounter}.Modality{mod}.TrainedOutputs{devstage}{k},outputWidth,minInterval, maxInterval,true,modality{mod}.useBODYBinaryOut );
Baby{babycounter}.Modality{mod}.AttentionOutTimes{devstage}(k,:) = BODYMapRepresentation(Baby{babycounter}.Modality{mod}.AttentionOutputs{devstage}{k},outputWidth,minInterval, maxInterval,true,modality{mod}.useBODYBinaryOut );
else
Baby{babycounter}.Modality{mod}.TrainedOutTimes{devstage}(k,:) = ATOMrepresentation(Baby{babycounter}.Modality{mod}.TrainedOutputs{devstage}{k},outputWidth,minInterval, maxInterval,true);
Baby{babycounter}.Modality{mod}.AttentionOutTimes{devstage}(k,:) = ATOMrepresentation(Baby{babycounter}.Modality{mod}.AttentionOutputs{devstage}{k},outputWidth,minInterval, maxInterval,true);
end
end
%calculate mean and stdev for outputs
Baby{babycounter}.Modality{mod}.MeanOutput{devstage} = mean(Baby{babycounter}.Modality{mod}.TrainedOutTimes{devstage}, 1);
Baby{babycounter}.Modality{mod}.StdDevOutput{devstage} = std(Baby{babycounter}.Modality{mod}.TrainedOutTimes{devstage} - ones(OutputLoopSize,1) * modality{mod}.Intervals, 1);
Baby{babycounter}.Modality{mod}.RelScalarErrors{devstage} = Baby{babycounter}.Modality{mod}.StdDevOutput{devstage} ./ Baby{babycounter}.Modality{mod}.MeanOutput{devstage};
Baby{babycounter}.Modality{mod}.AbsScalarErrors{devstage} = Baby{babycounter}.Modality{mod}.StdDevOutput{devstage} ./ modality{mod}.Intervals;
Baby{babycounter}.Modality{mod}.AttentionMeanOutput{devstage} = mean(Baby{babycounter}.Modality{mod}.AttentionOutTimes{devstage}, 1);
Baby{babycounter}.Modality{mod}.AttentionStdDevOutput{devstage} = std(Baby{babycounter}.Modality{mod}.AttentionOutTimes{devstage} - ones(OutputLoopSize,1) * modality{mod}.Intervals, 1);
Baby{babycounter}.Modality{mod}.AttentionRelScalarErrors{devstage} = Baby{babycounter}.Modality{mod}.AttentionStdDevOutput{devstage} ./ Baby{babycounter}.Modality{mod}.AttentionMeanOutput{devstage};
Baby{babycounter}.Modality{mod}.AttentionAbsScalarErrors{devstage} = Baby{babycounter}.Modality{mod}.AttentionStdDevOutput{devstage} ./ modality{mod}.Intervals;
end
end
end
%%%%%%%%%% DISPLAY THE RESULTS %%%%%%%%%%%%%%%%%%%%%%%%%
%
% first get the average baby for each time and each stage of development
% there might be a more elegant way of doing this
% but this way i can understand what i am doing!
for babycounter = 1:nBabies
for ph = 1:modalitycount
for devstage = 1:NEpochs
AllOutTimes{ph}{devstage}(babycounter,:) = Baby{babycounter}.Modality{ph}.TrainedOutTimes{devstage}(1,:);
AllMeanTimes{ph}{devstage}(babycounter,:) = Baby{babycounter}.Modality{ph}.MeanOutput{devstage};
AllMeanErrors{ph}{devstage}(babycounter,:) = Baby{babycounter}.Modality{ph}.StdDevOutput{devstage};
AllRelErrors{ph}{devstage}(babycounter,:) = Baby{babycounter}.Modality{ph}.RelScalarErrors{devstage};
AllAbsErrors{ph}{devstage}(babycounter,:) = Baby{babycounter}.Modality{ph}.AbsScalarErrors{devstage};
%same for attention modulated values
AttnOutTimes{ph}{devstage}(babycounter,:) = Baby{babycounter}.Modality{ph}.AttentionOutTimes{devstage}(1,:);
AttnMeanTimes{ph}{devstage}(babycounter,:) = Baby{babycounter}.Modality{ph}.AttentionMeanOutput{devstage};
AttnMeanErrors{ph}{devstage}(babycounter,:) = Baby{babycounter}.Modality{ph}.AttentionStdDevOutput{devstage};
AttnRelErrors{ph}{devstage}(babycounter,:) = Baby{babycounter}.Modality{ph}.AttentionRelScalarErrors{devstage};
AttnAbsErrors{ph}{devstage}(babycounter,:) = Baby{babycounter}.Modality{ph}.AttentionAbsScalarErrors{devstage};
end
end
end
for devstage = 1:NEpochs
GlobalOutTimes{devstage} = mean(AllOutTimes{1}{devstage},1);
GlobalMeanTimes{devstage} = mean(AllMeanTimes{1}{devstage},1);
GlobalMeanErrors{devstage} = mean(AllMeanErrors{1}{devstage},1);
GlobalRelErrors{devstage} = mean(AllRelErrors{1}{devstage},1);
GlobalAbsErrors{devstage} = mean(AllAbsErrors{1}{devstage},1);
end
if showcolumnsgraph
%graph showing the inputs and outputs for representative set of time
%intervals
fig = figure(1);
babycounter = nBabies; % just show last run
for ph = 1:modalitycount
%First graph things after learning first modality
for t = 1:modality{ph}.numIntervals
set(fig, 'Name', ['Phase' num2str(ph) ' - Input Time t= ' num2str(t)]);
%The guassian distributions input on this phase
subplot(2,2,ph);
axis([0 modality{ph}.inputWidth + 1 0 1.1]);
bar(1:modality{ph}.inputWidth, modality{ph}.MemoryCurves(t,:));
xlim([0 modality{ph}.inputWidth + 1]);
ylim([0 2.2]);
xlabel('Input Columns');
ylabel('Activation');
title(['Input modality {' num2str(ph) '}' ]);
%The guassian distribution that is input.
subplot(2,2,3-ph);
axis([0 modality{2}.inputWidth + 1 0 1.1]);
bar(1:modality{2}.inputWidth, zeros(1, modality{2}.inputWidth) );
xlim([0 modality{2}.inputWidth + 1]);
ylim([0 2.2]);
xlabel('Input Columns');
ylabel('Activation');
title(['Input modality {' num2str(3-ph) '}' ]);
%The output representation from the network
subplot(2,2,3)
axis([0 outputWidth + 1 0 1.1]);
if modality{2}.UseBODYMapRepresentation
bar(1:outputWidth, modality{1}.BODYOutputs(t,:));
else
bar(1:outputWidth, modality{1}.ATOMOutputs(t,:));
end
xlim([0 outputWidth + 1]);
ylim([0 1.1]);
xlabel('Output Columns');
ylabel('Activation');
title('Expected out');
%The output representation from the network
subplot(2,2,4)
axis([0 outputWidth + 1 0 1.1]);
bar(1:outputWidth, Baby{babycounter}.Modality{ph}.TrainedOutputs{NEpochs}{1}(t,:));
xlim([0 outputWidth + 1]);
ylim([0 1.1]);
xlabel('Output Columns');
ylabel('Activation');
title('Network out');
pause(0.2);
end
end
end
if showMainGraphs
%plot final performance with error bars.
figure(2);
for ph= 1:modalitycount
subplot(2,2,(ph-1)*2 +1);
hold on;
axis([0 maxInterval 0 maxInterval * 1.2]);
title(['Modality ' num2str(ph) ' predictions and errors'] );
xlabel('Time Interval /seconds');
ylabel('Prediction /seconds');
xlim([0 maxInterval]);
ylim([0 maxInterval]);
plot(modality{ph}.Intervals, modality{ph}.Intervals);
errorbar(modality{ph}.Intervals, Baby{babycounter}.Modality{ph}.MeanOutput{NEpochs}, 0.5* Baby{babycounter}.Modality{mod}.StdDevOutput{NEpochs});
hold off;
subplot(2,2,(ph-1)*2 +2);
axis([0 maxInterval 0 1.2]);
xlabel('Time Interval /seconds');
ylabel('Prediction /seconds');
xlim([0 maxInterval]);
ylim([0 1.2]);
hold on;
plot(modality{ph}.Intervals, Baby{babycounter}.Modality{ph}.RelScalarErrors{NEpochs}, ':+r');
plot(modality{ph}.Intervals, Baby{babycounter}.Modality{ph}.AbsScalarErrors{NEpochs}, ':*g');
title('Scaled output errors');
hold off;
end
%similar to figure 2 but showing performance over development
if trackdevelopment %check network performance after each Epoch
figure(3);
for ph = 1:modalitycount
subplot(2,2,(ph-1)*2 +1);
axis([0 maxInterval 0 maxInterval * 1.2]);
title(['Modality ' num2str(ph)]);
xlabel('Time Interval /seconds');
ylabel('Prediction /seconds');
xlim([0 maxInterval]);
ylim([0 maxInterval]);
hold on;
plot(modality{ph}.Intervals, modality{ph}.Intervals);
for devstage = 1:NEpochs
plot(modality{ph}.Intervals, Baby{babycounter}.Modality{ph}.MeanOutput{devstage});
end
hold off;
subplot(2,2,(ph-1)*2+2);
axis([0 maxInterval 0 1.2]);
xlabel('Time Interval /seconds');
ylabel('Prediction /seconds');
xlim([0 maxInterval]);
ylim([0 1.2]);
title('Average output Errors');
hold on;
for devstage = 1:NEpochs
plot(modality{ph}.Intervals, Baby{babycounter}.Modality{ph}.AbsScalarErrors{devstage}, ':+g');
end
hold off;
end
end
%results showing subplot 1,1 as a single figure for the paper
figure(5);
hold on;
title('Predictions over development');
axis([0 maxInterval 0 maxInterval * 1.2]);
xlabel('Time Interval / seconds');
ylabel('Prediction / seconds');
xlim([0 maxInterval]);
ylim([0 maxInterval]);
plot(modality{ph}.Intervals, modality{ph}.Intervals);
for devstage = 1:NEpochs
plot(modality{ph}.Intervals, GlobalMeanTimes{devstage});
end
hold off;
%results for modality as single figure for the paper
figure(6);
hold on;
title(['Global mean outputs and errors']);
axis([0 maxInterval 0 maxInterval * 1.2]);
xlabel('Time Interval /seconds');
ylabel('Prediction /seconds');
xlim([0 maxInterval]);
ylim([0 maxInterval]);
line(modality{ph}.Intervals, modality{ph}.Intervals);
errorbar(modality{ph}.Intervals, GlobalMeanTimes{NEpochs}, GlobalMeanErrors{NEpochs});
%errorbar(modality{ph}.Intervals, Baby{babycounter}.Modality{ph}.MeanOutput{NEpochs}, Baby{babycounter}.Modality{mod}.StdDevOutput{NEpochs});
ax1 = gca;
xlimits = get(ax1,'XLim');
ylimits = get(ax1,'YLim');
xinc = (xlimits(2)-xlimits(1))/5;
yinc = (ylimits(2)-ylimits(1))/5;
set(ax1,'XTick',[xlimits(1):xinc:xlimits(2)],...
'YTick',[ylimits(1):yinc:ylimits(2)])
ax2 = axes('Position',get(ax1,'Position'), ...
'XAxisLocation','bottom',...
'YAxisLocation','right',...
'Color','none',...
'XColor','w','YColor','k');
set(ax2,'XTick',[xlimits(1):xinc:xlimits(2)],...
'YTick',[0:0.2:1])
ylabel(ax2, 'Error as proportion of interval');
% set(get(ax2,'Ylabel'),'String','Fast Decay')
xlim(ax2, [0 maxInterval]);
ylim(ax2, [0 1]);
line(modality{ph}.Intervals, GlobalRelErrors{NEpochs}, 'Color', 'r', 'Parent', ax2);
% line(modality{ph}.Intervals, Baby{babycounter}.Modality{ph}.RelScalarErrors{NEpochs}, 'Color', 'r', 'Parent', ax2);
title('');
hold off;
end
%%% plotcorrelations
if showCorrelations
if modalitycount == 2
for n=1:NEpochs
rhomatrix = corrcoef(Baby{babycounter}.Modality{mod}.TrainedOutTimes{n}(1,:)',Baby{babycounter}.Modality{2}.TrainedOutTimes{n}(1,:)');
rho(n) = rhomatrix(1,2);
end
figure(4);
TrainingSteps = NTrainingItems:NTrainingItems:NEpochs*NTrainingItems;
plot(TrainingSteps, rho);
xlabel('Training Items');
ylabel('Correlation');
title('Correlation between modalities over development');
end
end
%%% plot AttentionEffect
if showAttentionEffects
figure(7);
for ph= 1:modalitycount
subplot(2,1,ph);
hold on;
axis([0 maxInterval 0 maxInterval * 1.2]);
xlabel('Time Interval /seconds');
ylabel('Prediction /seconds');
xlim([0 maxInterval]);
ylim([0 maxInterval]);
plot(modality{ph}.Intervals, modality{ph}.Intervals);
errorbar(modality{ph}.Intervals, Baby{babycounter}.Modality{ph}.MeanOutput{NEpochs}, 0.5* Baby{babycounter}.Modality{mod}.StdDevOutput{NEpochs},'+g');
errorbar(modality{ph}.Intervals, Baby{babycounter}.Modality{ph}.AttentionMeanOutput{NEpochs}, 0.5* Baby{babycounter}.Modality{mod}.AttentionStdDevOutput{NEpochs},'*r');
title('Effect of attention');
hold off;
end
end