-
Notifications
You must be signed in to change notification settings - Fork 0
/
LearnNewExemplarWithNoise.m
63 lines (55 loc) · 2.67 KB
/
LearnNewExemplarWithNoise.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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Core Model, 2022
% Written by Maya Davis
% Concept by Maya Davis and Melissa A. Redford
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [GoalsOverTime, ActivationsOverTime, ...
MResultsOverTime, PResultsOverTime] = LearnNewExemplarWithNoise( ...
StartingSpace, StartingSilhouette, Exemplar, ...
NumberOfIterations, LookBackWindow, LookAheadWindow, Noise)
CurrentExecutionParameters = ExecutionParameters(LookBackWindow, ...
LookAheadWindow);
GoalsOverTime = Goal.empty(NumberOfIterations + 1,0);
ActivationsOverTime = cell(NumberOfIterations + 1,0);
MResultsOverTime = MotorTrajectory.empty(NumberOfIterations + 1,0);
PResultsOverTime = PerceptualTrajectory.empty(NumberOfIterations + 1,0);
CurrentSpace = StartingSpace;
CurrentSilhouette = StartingSilhouette;
CurrentExemplar = Exemplar;
for n = 1:NumberOfIterations + 1
fprintf("Done with iteration%d\n", n);
% Making the current goal from already in-place parameters;
% then finding the results of that
CurrentGoal = Goal(CurrentSpace, CurrentSilhouette, ...
CurrentExemplar);
[AverageJunctureEstimates, CurrentActivations] = ...
CurrentGoal.SimpleMacroEstimates( ...
CurrentExecutionParameters);
% NOISE!
JostledMotor = nan(length( ...
AverageJunctureEstimates(1).MotorPoint.Coordinates), ...
length(AverageJunctureEstimates));
for j = 1:size(JostledMotor, 2)
CurrentMotorCoordinates = AverageJunctureEstimates(j).MotorPoint.Coordinates;
MotorCoordinatesPlusNoise = CurrentMotorCoordinates + ...
Noise * 2 * (rand(size(CurrentMotorCoordinates)) - 0.5);
JostledMotor(:, j) = MotorCoordinatesPlusNoise;
end
if size(JostledMotor, 1) >= 3
MTrajectory = MotorTrajectory(JostledMotor, "zRowIndex", 3);
PTrajectory = MTrajectory.FindPerceptualTrajectory(StartingSpace.SpaceTransformation, "zRowIndex", 3);
else
MTrajectory = MotorTrajectory(JostledMotor);
PTrajectory = MTrajectory.FindPerceptualTrajectory( ...
StartingSpace.SpaceTransformation);
end
% Storing these results in appropriate places
GoalsOverTime(n) = CurrentGoal;
ActivationsOverTime{n} = CurrentActivations;
MResultsOverTime(n) = MTrajectory;
PResultsOverTime(n) = PTrajectory;
% Updating the silhouette for next time (the exemplar and space
% stay the same)
CurrentSilhouette = CurrentSilhouette.ExpandSilhouette(MTrajectory);
end
end