plateform stringclasses 1
value | repo_name stringlengths 13 113 | name stringlengths 3 74 | ext stringclasses 1
value | path stringlengths 12 229 | size int64 23 843k | source_encoding stringclasses 9
values | md5 stringlengths 32 32 | text stringlengths 23 843k |
|---|---|---|---|---|---|---|---|---|
github | qihongl/mathCognition_PDP_RL-master | initState.m | .m | mathCognition_PDP_RL-master/[past]/sim10_forcing/initState.m | 1,318 | utf_8 | 022704d7100cbf8f1b1c99719eec193a | % written by professor Jay McClelland
function [ ] = initState( )
global a w h p;
%realState is characterized by the position of a target to touch,
%position of eye, and position of hand
%in a 101-pixel one-d space
%viewedState is the input I have given that my eye and hand are
%at particular positions w.r... |
github | qihongl/mathCognition_PDP_RL-master | plotResults.m | .m | mathCognition_PDP_RL-master/[past]/sim10_forcing/plotResults.m | 544 | utf_8 | da928d22f60607e06a82b5f24fe4b624 | function plotResults(record)
global d;
% initialize the parameters for the plot
d.fh = figure();
d.fh.WindowStyle = 'docked';
d.rax = subplot(3,1,1);
d.hax = subplot(3,1,2);
d.wax = subplot(3,1,3);
% d.dtimes = 2.^(10:10);
% load('record.mat');
for i = 1 : size(record.r{size(record.r,2)}.h,2)
plotRes(i, record);
e... |
github | qihongl/mathCognition_PDP_RL-master | trainAgent.m | .m | mathCognition_PDP_RL-master/[past]/sim10_forcing/trainAgent.m | 949 | utf_8 | 73bb1b6fb81e3c6dcea2d70a456f8d26 | % written by professor Jay McClelland
function [record] = trainAgent(epoch)
%% This function trains the network n trials
% initialize parameters
global p d a;
initParams(epoch);
% initPlot();
% preallocate
record.a = cell(1,epoch);
record.steps = nan(1,epoch);
% record.indices = cell(1,epoch);
% record.com... |
github | qihongl/mathCognition_PDP_RL-master | computeRwd.m | .m | mathCognition_PDP_RL-master/[past]/sim10_forcing/computeRwd.m | 2,444 | utf_8 | 89df389678b58182f953f3a721a2713d | function Rwd = computeRwd()
%% this function controls the reward policy
global w a p;
w.actionCorrect = true;
% if there is remaining items
if targetRemain()
% if a.choice == p.mvRad+1 % not moving
if w.out.handStep == 0
Rwd = p.r.smallNeg;
% if stop too long, also termiante
% w.stopC... |
github | qihongl/mathCognition_PDP_RL-master | Act.m | .m | mathCognition_PDP_RL-master/[past]/sim10_forcing/Act.m | 404 | utf_8 | c8ce5a2f3bcdf3fa4195dafad94f8e76 | % written by professor Jay McClelland
function [ ] = Act( )
% here we act according to the action selected
% by selectAction
global w p;
%% perform the actions
% update the real locations of hand and eye
w.rS.handPos = w.rS.handPos + w.out.handStep;
w.rS.eyePos = w.rS.eyePos + w.out.eyeStep;
w.rS.td = 1; ... |
github | qihongl/mathCognition_PDP_RL-master | runAgent.m | .m | mathCognition_PDP_RL-master/[past]/sim16.5.2_tanh/runAgent.m | 1,493 | utf_8 | 3af998953e263322252c3725d0de8f54 | % written by professor Jay McClelland
function [ results ] = runAgent()
global a w h p mode;
%% initialize the state
initState();
updateState();
computeAnswer(); % compute the true 'answers'
%% training the model once
i = 0;
indices = zeros(1,p.maxIter);
while ~(w.done) && i < p.maxIter
%% choose ... |
github | qihongl/mathCognition_PDP_RL-master | trainOne.m | .m | mathCognition_PDP_RL-master/[past]/sim16.5.2_tanh/trainOne.m | 485 | utf_8 | 084dc3ee4f356418650e99b62da97753 | % just testing, a short cut for running the model
function record = trainOne(epoch, seed)
if nargin == 0
epoch = 100000;
seed = randi(99);
end
%% run the simulation
record = trainAgent(epoch, seed);
%% save the simulation .
saveDirName = getSaveDir();
save([saveDirName '/' 'record'],'record');
save('record','... |
github | qihongl/mathCognition_PDP_RL-master | showWeights.m | .m | mathCognition_PDP_RL-master/[past]/sim16.5.2_tanh/showWeights.m | 773 | utf_8 | 56b009e4997900472132fa009bf09ed3 | function [ ] = showWeights( )
% plot the weights of the model
global p d a;
% wts from visual input to hidden
axes(d.wts_VH)
imagesc(a.wts_VH)
title(d.wts_VH, 'Weights: visual -> hidden', 'fontsize', d.FONTSIZE)
xlabel(d.wts_VH, 'Visual input layer', 'fontsize', d.FONTSIZE)
ylabel(d.wts_VH, 'Hidden layer', 'fontsize',... |
github | qihongl/mathCognition_PDP_RL-master | updateWeights.m | .m | mathCognition_PDP_RL-master/[past]/sim16.5.2_tanh/updateWeights.m | 1,020 | utf_8 | 8c30383942434b99788057665d9104ea | % written by professor Jay McClelland
function [ ] = updateWeights()
% this function controls:
% 1. the reward policy
% 2. the weight update
% 3. activate the "teaching"
global p a w;
%% compute the reward values according to the reward policy
curRwd = computeRwd();
a.aAct_next = a.wts_HA*tanh(a.wts_VH * w.vS.... |
github | qihongl/mathCognition_PDP_RL-master | showState.m | .m | mathCognition_PDP_RL-master/[past]/sim16.5.2_tanh/showState.m | 2,161 | utf_8 | 33d849cf16ea8fb1c5e0f476aa23c64b | % written by professor Jay McClelland
function [ ] = showState( )
global p w d a;
%% plot current and expected rewards over time
axes(d.rwd);
plot(w.rS.time,a.Rwd,'-b*'); hold on;
plot(w.rS.time,a.dfRwd,'-r*');
legend({'current reward', 'discounted future reward'},...
'Location','northwest', 'fontsize',... |
github | qihongl/mathCognition_PDP_RL-master | move.m | .m | mathCognition_PDP_RL-master/[past]/sim16.5.2_tanh/move.m | 403 | utf_8 | a8c158962dd0428e90aff3bada221b17 | % written by professor Jay McClelland
function [ ] = move( )
% here we act according to the action selected by selectAction()
global w;
%% perform the actions
% update the real locations of hand and eye
w.rS.handPos = w.rS.handPos + w.out.handStep;
w.rS.eyePos = w.rS.eyePos + w.out.eyeStep;
w.rS.td = 1; ... |
github | qihongl/mathCognition_PDP_RL-master | initParams.m | .m | mathCognition_PDP_RL-master/[past]/sim16.5.2_tanh/initParams.m | 2,446 | utf_8 | 5b3a34e0bdda1a4445eebb2cc30c3d04 | % written by professor Jay McClelland
function [] = initParams(epoch)
% This program initialize and preallocate the parameters needed for the
% model. This should be executed before the simulations.
global p a
% p.teachingStyle = 4;
% 1 = final reward only
% 2 = intermediate reward
% 3 = final reward only + t... |
github | qihongl/mathCognition_PDP_RL-master | updateState.m | .m | mathCognition_PDP_RL-master/[past]/sim16.5.2_tanh/updateState.m | 1,094 | utf_8 | 131e75aec71899515e25d188601e4b16 | % written by professor Jay McClelland
function [ ] = updateState()
%this function uses the real state to update the internal state
%after Act is called to execute the hand or eye movement action
global w h p a;
%% compute the relative locations
% the relative locations of eye and hand
w.vS.eyePos = 0;
w.vS.... |
github | qihongl/mathCognition_PDP_RL-master | initState.m | .m | mathCognition_PDP_RL-master/[past]/sim16.5.2_tanh/initState.m | 1,696 | utf_8 | 3521837d9f6a9966118d29c2a5374c64 | % written by professor Jay McClelland
function [ ] = initState( )
global a w h p mode;
%realState is characterized by the position of a target to touch,
%position of eye, and position of hand 1-d space
%viewedState is the input I have given that my eye and hand are
%at particular positions w.r.t. the realSt... |
github | qihongl/mathCognition_PDP_RL-master | trainAgent.m | .m | mathCognition_PDP_RL-master/[past]/sim16.5.2_tanh/trainAgent.m | 1,501 | utf_8 | 61e7aeb84f1a92e22f73306d60a6cdcd | %% Trains the network n trials
% written by professor Jay McClelland
function [record] = trainAgent(epoch, seed)
%% initialization
% initialize parameters
global p a w mode;
initParams(epoch);
p.seed = seed;
rng(seed)
% preallocate
record.a = cell(1,epoch);
s.steps = nan(1,epoch);
s.indices = cell(1,epoch... |
github | qihongl/mathCognition_PDP_RL-master | computeRwd.m | .m | mathCognition_PDP_RL-master/[past]/sim16.5.2_tanh/computeRwd.m | 2,501 | utf_8 | 34e581ed0bd67cb9271f5978ee6c956f | function Rwd = computeRwd()
%% this function controls the reward policy
global w p h a;
w.actionCorrect = true;
% if there is remaining items
if targetRemain()
if a.choice == p.mvRange +1 % saying "done"
Rwd = p.r.smallNeg;
w.errors = w.errors + 1;
w.done = true;
elseif a.choice == ... |
github | qihongl/mathCognition_PDP_RL-master | runAgent.m | .m | mathCognition_PDP_RL-master/[past]/sim08_moreSim/runAgent.m | 1,094 | utf_8 | 59ac532a73c596624ee1dca4cdaea300 | % written by professor Jay McClelland
function [ results ] = runAgent()
global a w h p;
% rng(seed)
% w.seed = seed;
%% initialize the state
initState();
updateState();
%% training the model once
i = 0;
teachTrial = 0;
indices = zeros(1,p.maxIter);
while ~(w.done) && i < p.maxIter
%% choose action ... |
github | qihongl/mathCognition_PDP_RL-master | updateWeights.m | .m | mathCognition_PDP_RL-master/[past]/sim08_moreSim/updateWeights.m | 684 | utf_8 | 2a35707770a0830894255d38e3f647ef | % written by professor Jay McClelland
function [ ] = updateWeights()
% this function controls:
% 1. the reward policy
% 2. the weight update
% 3. activate the "teaching"
global a w p;
%% compute the reward values according to the reward policy
Rwd = computeRwd();
%% assign the reward values
a.Rwd = Rwd;
a... |
github | qihongl/mathCognition_PDP_RL-master | selectAction.m | .m | mathCognition_PDP_RL-master/[past]/sim08_moreSim/selectAction.m | 623 | utf_8 | 4df6f701dc4156d0252948d6e1330f09 | % written by professor Jay McClelland
function [] = selectAction( )
% It computes the output, and choose the action probabilistically.
global w a p;
%% compute the output activation
a.act = a.wts * w.vS.visInput';
% bias toward action 0 (don't move)
a.act(p.mvRad + 1) = a.act(p.mvRad + 1) + a.bias;
% choose... |
github | qihongl/mathCognition_PDP_RL-master | showState.m | .m | mathCognition_PDP_RL-master/[past]/sim08_moreSim/showState.m | 1,122 | utf_8 | 7b511266ea2cd400a15d7791420eecf3 | % written by professor Jay McClelland
function [ ] = showState( )
global p w d a;
% plot rewards over time
axes(d.rax);
% if a.Rwd == p.r.smallNeg
% color = 'c';
% elseif a.Rwd == p.r.midNeg || a.Rwd == p.r.bigNeg
% color = 'b';
% elseif a.Rwd == p.r.midPos
% color = 'y';
% elseif a.Rwd == p.r.... |
github | qihongl/mathCognition_PDP_RL-master | initParams.m | .m | mathCognition_PDP_RL-master/[past]/sim08_moreSim/initParams.m | 1,564 | utf_8 | 39b741b3a9845f061eec9d43260906ee | % written by professor Jay McClelland
function [] = initParams(epoch)
% This program initialize and preallocate the parameters needed for the
% model. This should be executed before the simulations.
global p a
%% modeling parameters
p.wf = .15; % noise magnitude
p.lrate = .01; % learning rate
... |
github | qihongl/mathCognition_PDP_RL-master | updateState.m | .m | mathCognition_PDP_RL-master/[past]/sim08_moreSim/updateState.m | 989 | utf_8 | 08ab2fc23581d8e72df1aac03a27c8e7 | % written by professor Jay McClelland
function [ ] = updateState()
%this function uses the real state to update the internal state
%after Act is called to execute the hand or eye movement action
global w a h p;
%% compute the relative locations
% the relative locations of eye and hand
w.vS.eyePos = 0;
w.vS.... |
github | qihongl/mathCognition_PDP_RL-master | initState.m | .m | mathCognition_PDP_RL-master/[past]/sim08_moreSim/initState.m | 1,373 | utf_8 | 419742b9b4788220655842c90a6b0c60 | % written by professor Jay McClelland
function [ ] = initState( )
global a w h p;
%realState is characterized by the position of a target to touch,
%position of eye, and position of hand
%in a 101-pixel one-d space
%viewedState is the input I have given that my eye and hand are
%at particular positions w.r... |
github | qihongl/mathCognition_PDP_RL-master | plotResults.m | .m | mathCognition_PDP_RL-master/[past]/sim08_moreSim/plotResults.m | 544 | utf_8 | da928d22f60607e06a82b5f24fe4b624 | function plotResults(record)
global d;
% initialize the parameters for the plot
d.fh = figure();
d.fh.WindowStyle = 'docked';
d.rax = subplot(3,1,1);
d.hax = subplot(3,1,2);
d.wax = subplot(3,1,3);
% d.dtimes = 2.^(10:10);
% load('record.mat');
for i = 1 : size(record.r{size(record.r,2)}.h,2)
plotRes(i, record);
e... |
github | qihongl/mathCognition_PDP_RL-master | trainAgent.m | .m | mathCognition_PDP_RL-master/[past]/sim08_moreSim/trainAgent.m | 860 | utf_8 | 42dcfb35f8a3150cacec420b8c39c6fb | % written by professor Jay McClelland
function [record] = trainAgent(epoch)
%% This function trains the network n trials
% initialize parameters
global p d a;
initParams(epoch);
initPlot();
% preallocate
record.a = cell(1,epoch);
record.steps = nan(1,epoch);
% record.indices = cell(1,epoch);
% record.compl... |
github | qihongl/mathCognition_PDP_RL-master | computeRwd.m | .m | mathCognition_PDP_RL-master/[past]/sim08_moreSim/computeRwd.m | 2,386 | utf_8 | b103ef29532bb0046561b7c48724c503 | function Rwd = computeRwd()
%% this function controls the reward policy
global w a p;
w.actionCorrect = true;
% if there is remaining items
if targetRemain()
if a.choice == p.mvRad+1 % not moving
Rwd = p.r.smallNeg;
% if stop too long, also termiante
% w.stopCounter = w.stopCounter - 1; ... |
github | qihongl/mathCognition_PDP_RL-master | Act.m | .m | mathCognition_PDP_RL-master/[past]/sim08_moreSim/Act.m | 404 | utf_8 | c8ce5a2f3bcdf3fa4195dafad94f8e76 | % written by professor Jay McClelland
function [ ] = Act( )
% here we act according to the action selected
% by selectAction
global w p;
%% perform the actions
% update the real locations of hand and eye
w.rS.handPos = w.rS.handPos + w.out.handStep;
w.rS.eyePos = w.rS.eyePos + w.out.eyeStep;
w.rS.td = 1; ... |
github | qihongl/mathCognition_PDP_RL-master | runAgent.m | .m | mathCognition_PDP_RL-master/[past]/sim11.1_reorgWts/runAgent.m | 1,273 | utf_8 | 2b39b01046313d8b18b63684ee0d47d1 | % written by professor Jay McClelland
function [ results ] = runAgent()
global a w h p;
% rng(seed)
% w.seed = seed;
%% initialize the state
initState();
updateState();
% compute the true answers
w.answer = computeAnswer(w);
%% training the model once
i = 0;
teachTrial = 0;
indices = zeros(1,p.maxIter)... |
github | qihongl/mathCognition_PDP_RL-master | updateWeights.m | .m | mathCognition_PDP_RL-master/[past]/sim11.1_reorgWts/updateWeights.m | 725 | utf_8 | 8395a7c3715f6bdefec20b92a9de7f13 | % written by professor Jay McClelland
function [ ] = updateWeights()
% this function controls:
% 1. the reward policy
% 2. the weight update
% 3. activate the "teaching"
global a w p;
%% compute the reward values according to the reward policy
Rwd = computeRwd();
%% assign the reward values
a.Rwd = Rwd;
a... |
github | qihongl/mathCognition_PDP_RL-master | testing.m | .m | mathCognition_PDP_RL-master/[past]/sim11.1_reorgWts/testing.m | 191 | utf_8 | c70b6456163b18a198c0e618cc8ebb58 | % just testing, a short cut for running the model
function testing(epoch)
if nargin == 0
epoch = 3000;
end
record = trainAgent(epoch);
save('record','record');
quiz()
checkLearning()
end
|
github | qihongl/mathCognition_PDP_RL-master | showState.m | .m | mathCognition_PDP_RL-master/[past]/sim11.1_reorgWts/showState.m | 1,124 | utf_8 | 4e7261e4b5cdd52471b6caf0185f73e6 | % written by professor Jay McClelland
function [ ] = showState( )
global p w d a;
% plot rewards over time
axes(d.rax);
% if a.Rwd == p.r.smallNeg
% color = 'c';
% elseif a.Rwd == p.r.midNeg || a.Rwd == p.r.bigNeg
% color = 'b';
% elseif a.Rwd == p.r.midPos
% color = 'y';
% elseif a.Rwd == p.r.... |
github | qihongl/mathCognition_PDP_RL-master | initParams.m | .m | mathCognition_PDP_RL-master/[past]/sim11.1_reorgWts/initParams.m | 1,542 | utf_8 | f4ab0a8139012777bb7ad77df300de0b | % written by professor Jay McClelland
function [] = initParams(epoch)
% This program initialize and preallocate the parameters needed for the
% model. This should be executed before the simulations.
global p a
%% modeling parameters
p.wf = .2; % noise magnitude
p.lrate = .01; % learning rate
p... |
github | qihongl/mathCognition_PDP_RL-master | updateState.m | .m | mathCognition_PDP_RL-master/[past]/sim11.1_reorgWts/updateState.m | 943 | utf_8 | 97d8e632275ef769949c3bf59714a88b | % written by professor Jay McClelland
function [ ] = updateState()
%this function uses the real state to update the internal state
%after Act is called to execute the hand or eye movement action
global w h p;
%% compute the relative locations
% the relative locations of eye and hand
w.vS.eyePos = 0;
w.vS.ha... |
github | qihongl/mathCognition_PDP_RL-master | initState.m | .m | mathCognition_PDP_RL-master/[past]/sim11.1_reorgWts/initState.m | 1,347 | utf_8 | 7c71bed65f001b4da4410b16e6b1fd30 | % written by professor Jay McClelland
function [ ] = initState( )
global a w h p;
%realState is characterized by the position of a target to touch,
%position of eye, and position of hand
%in a 101-pixel one-d space
%viewedState is the input I have given that my eye and hand are
%at particular positions w.r... |
github | qihongl/mathCognition_PDP_RL-master | plotResults.m | .m | mathCognition_PDP_RL-master/[past]/sim11.1_reorgWts/plotResults.m | 544 | utf_8 | da928d22f60607e06a82b5f24fe4b624 | function plotResults(record)
global d;
% initialize the parameters for the plot
d.fh = figure();
d.fh.WindowStyle = 'docked';
d.rax = subplot(3,1,1);
d.hax = subplot(3,1,2);
d.wax = subplot(3,1,3);
% d.dtimes = 2.^(10:10);
% load('record.mat');
for i = 1 : size(record.r{size(record.r,2)}.h,2)
plotRes(i, record);
e... |
github | qihongl/mathCognition_PDP_RL-master | trainAgent.m | .m | mathCognition_PDP_RL-master/[past]/sim11.1_reorgWts/trainAgent.m | 1,028 | utf_8 | e56a03d1140da885cbc331dee5e61402 | % written by professor Jay McClelland
function [record] = trainAgent(epoch)
%% This function trains the network n trials
% initialize parameters
global p a w;
initParams(epoch);
% preallocate
record.a = cell(1,epoch);
record.s.steps = nan(1,epoch);
record.s.indices = cell(1,epoch);
record.s.completed = fals... |
github | qihongl/mathCognition_PDP_RL-master | computeRwd.m | .m | mathCognition_PDP_RL-master/[past]/sim11.1_reorgWts/computeRwd.m | 2,382 | utf_8 | 88ee29fb9f5cf88990942fe4f428c87d | function Rwd = computeRwd()
%% this function controls the reward policy
global w p h;
w.actionCorrect = true;
% if there is remaining items
if targetRemain()
if w.out.handStep == 0 % not moving
Rwd = p.r.smallNeg;
% % if stop too long, also termiante
% w.stopCounter = w.stopCounter - 1;... |
github | qihongl/mathCognition_PDP_RL-master | Act.m | .m | mathCognition_PDP_RL-master/[past]/sim11.1_reorgWts/Act.m | 404 | utf_8 | c8ce5a2f3bcdf3fa4195dafad94f8e76 | % written by professor Jay McClelland
function [ ] = Act( )
% here we act according to the action selected
% by selectAction
global w p;
%% perform the actions
% update the real locations of hand and eye
w.rS.handPos = w.rS.handPos + w.out.handStep;
w.rS.eyePos = w.rS.eyePos + w.out.eyeStep;
w.rS.td = 1; ... |
github | qihongl/mathCognition_PDP_RL-master | runAgent.m | .m | mathCognition_PDP_RL-master/[past]/sim17.1_hidden/runAgent.m | 1,376 | utf_8 | 5c6c39d68b7ef942d3454ecd87566f56 | % written by professor Jay McClelland
function [ results ] = runAgent()
global a w h p mode;
%% initialize the state
initState();
updateState();
computeAnswer(); % compute the true 'answers'
%% training the model once
i = 0;
indices = zeros(1,p.maxIter);
while ~(w.done) && i < p.maxIter
%% choose ... |
github | qihongl/mathCognition_PDP_RL-master | trainOne.m | .m | mathCognition_PDP_RL-master/[past]/sim17.1_hidden/trainOne.m | 489 | utf_8 | 480fbd634b40a2e355805264ff3e4ac7 | % just testing, a short cut for running the model
function record = trainOne(epoch, seed)
if nargin == 0
epoch = 5000;
seed = randi(99);
end
%% run the simulation
record = trainAgent(epoch, seed);
%% save the simulation results
saveDirName = getSaveDir();
save([saveDirName '/' 'record'],'record');
save('recor... |
github | qihongl/mathCognition_PDP_RL-master | updateWeights.m | .m | mathCognition_PDP_RL-master/[past]/sim17.1_hidden/updateWeights.m | 967 | utf_8 | ed7a5ab56d2d8800a90a6b72481a87ee | % written by professor Jay McClelland
function [ ] = updateWeights()
% this function controls:
% 1. the reward policy
% 2. the weight update
% 3. activate the "teaching"
global p a w;
%% compute the reward values according to the reward policy
curRwd = computeRwd();
expRwd = max(a.aAct);
%% assign the rewar... |
github | qihongl/mathCognition_PDP_RL-master | showState.m | .m | mathCognition_PDP_RL-master/[past]/sim17.1_hidden/showState.m | 1,317 | utf_8 | 5f98a0c96bcf734cfce4abd1d109c314 | % written by professor Jay McClelland
function [ ] = showState( )
global p w d a;
% plot current and expected rewards over time
axes(d.rwd);
plot(w.rS.time,a.Rwd,'-b*'); hold on;
plot(w.rS.time,a.dfRwd,'-r*');
legend({'current reward', 'discounted future reward'},...
'Location','northwest', 'fontsize', d.F... |
github | qihongl/mathCognition_PDP_RL-master | move.m | .m | mathCognition_PDP_RL-master/[past]/sim17.1_hidden/move.m | 403 | utf_8 | 76f0765b052705d3747442411be8e898 | % written by professor Jay McClelland
function [ ] = move( )
% here we act according to the action selected
% by selectAction
global w;
%% perform the actions
% update the real locations of hand and eye
w.rS.handPos = w.rS.handPos + w.out.handStep;
w.rS.eyePos = w.rS.eyePos + w.out.eyeStep;
w.rS.td = 1; ... |
github | qihongl/mathCognition_PDP_RL-master | initParams.m | .m | mathCognition_PDP_RL-master/[past]/sim17.1_hidden/initParams.m | 2,506 | utf_8 | 168cf03de49a9c938561ac09b8bf235a | % written by professor Jay McClelland
function [] = initParams(epoch)
% This program initialize and preallocate the parameters needed for the
% model. This should be executed before the simulations.
global p a
p.teachingStyle = 1;
% 1 = final reward only
% 2 = intermediate reward
% 3 = final reward only + tea... |
github | qihongl/mathCognition_PDP_RL-master | updateState.m | .m | mathCognition_PDP_RL-master/[past]/sim17.1_hidden/updateState.m | 924 | utf_8 | 84c86d58e1b29b01ec1c1a3fad73c7c1 | % written by professor Jay McClelland
function [ ] = updateState()
%this function uses the real state to update the internal state
%after Act is called to execute the hand or eye movement action
global w h p;
%% compute the relative locations
% the relative locations of eye and hand
w.vS.eyePos = 0;
w.vS.hand... |
github | qihongl/mathCognition_PDP_RL-master | initState.m | .m | mathCognition_PDP_RL-master/[past]/sim17.1_hidden/initState.m | 1,630 | utf_8 | 33299d877a4234e89c16dee856064680 | % written by professor Jay McClelland
function [ ] = initState( )
global a w h p mode;
%realState is characterized by the position of a target to touch,
%position of eye, and position of hand 1-d space
%viewedState is the input I have given that my eye and hand are
%at particular positions w.r.t. the realSt... |
github | qihongl/mathCognition_PDP_RL-master | plotResults.m | .m | mathCognition_PDP_RL-master/[past]/sim17.1_hidden/plotResults.m | 544 | utf_8 | da928d22f60607e06a82b5f24fe4b624 | function plotResults(record)
global d;
% initialize the parameters for the plot
d.fh = figure();
d.fh.WindowStyle = 'docked';
d.rax = subplot(3,1,1);
d.hax = subplot(3,1,2);
d.wax = subplot(3,1,3);
% d.dtimes = 2.^(10:10);
% load('record.mat');
for i = 1 : size(record.r{size(record.r,2)}.h,2)
plotRes(i, record);
e... |
github | qihongl/mathCognition_PDP_RL-master | trainAgent.m | .m | mathCognition_PDP_RL-master/[past]/sim17.1_hidden/trainAgent.m | 1,501 | utf_8 | 61e7aeb84f1a92e22f73306d60a6cdcd | %% Trains the network n trials
% written by professor Jay McClelland
function [record] = trainAgent(epoch, seed)
%% initialization
% initialize parameters
global p a w mode;
initParams(epoch);
p.seed = seed;
rng(seed)
% preallocate
record.a = cell(1,epoch);
s.steps = nan(1,epoch);
s.indices = cell(1,epoch... |
github | qihongl/mathCognition_PDP_RL-master | computeRwd.m | .m | mathCognition_PDP_RL-master/[past]/sim17.1_hidden/computeRwd.m | 2,205 | utf_8 | 8cad5b2bcbe004359ae289b13c3b08d7 | function Rwd = computeRwd()
%% this function controls the reward policy
global w p h a;
w.actionCorrect = true;
% if there is remaining items
if targetRemain()
if w.out.handStep == 0 % not moving
Rwd = p.r.smallNeg;
elseif ~isTouchingObj % touching empty spot
Rwd = p.r.smallNeg;
e... |
github | qihongl/mathCognition_PDP_RL-master | runAgent.m | .m | mathCognition_PDP_RL-master/[past]/sim09_activeEnd/runAgent.m | 1,094 | utf_8 | 6f9893468152612c7d83a5f5516c966e | % written by professor Jay McClelland
function [ results ] = runAgent(seed)
global a w h p;
rng(seed)
w.seed = seed;
%% initialize the state
initState();
updateState();
%% training the model once
i = 0;
teachTrial = 0;
indices = zeros(1,p.maxIter);
while ~(w.done) && i < p.maxIter
%% choose action ... |
github | qihongl/mathCognition_PDP_RL-master | updateWeights.m | .m | mathCognition_PDP_RL-master/[past]/sim09_activeEnd/updateWeights.m | 2,782 | utf_8 | e8873d73e50f2febb3670588fd74df0b | % written by professor Jay McClelland
function [ ] = updateWeights()
% this function controls:
% 1. the reward policy
% 2. the weight update
% 3. activate the "teaching"
global a w p;
if ~w.terminate
%% compute the reward values
w.actionCorrect = true;
% if the model doesn't move (choose the middle action)
... |
github | qihongl/mathCognition_PDP_RL-master | selectAction.m | .m | mathCognition_PDP_RL-master/[past]/sim09_activeEnd/selectAction.m | 890 | utf_8 | cd377539a126a9f64a129108335ca9f4 | % written by professor Jay McClelland
function [] = selectAction( )
% It computes the output, and choose the action probabilistically.
global w a p;
%% compute the output activation
a.act = a.wts * w.vS.visInput';
% bias toward action 0 (don't move)
a.act(p.mvRad + 1) = a.act(p.mvRad + 1) + a.bias;
%% cho... |
github | qihongl/mathCognition_PDP_RL-master | showState.m | .m | mathCognition_PDP_RL-master/[past]/sim09_activeEnd/showState.m | 710 | utf_8 | 39516e279c4d8abde3950cfe0d60e97d | % written by professor Jay McClelland
function [ ] = showState( )
global p w d a;
axes(d.rax);
plot(w.rS.time,a.Rwd,'-*'); hold on;
ylim(d.rax,[-0.1 5.1]); xlim(d.rax,[-0.25,w.rS.time+0.25]);
t = w.rS.time;
% plot the history of eye and hand positions
axes(d.hax);
plot(d.hax,[-p.spRad p.spRad],[t t]); hold... |
github | qihongl/mathCognition_PDP_RL-master | initParams.m | .m | mathCognition_PDP_RL-master/[past]/sim09_activeEnd/initParams.m | 1,457 | utf_8 | 9c264a2dad2c01df15c93fbd2df7c9e2 | % written by professor Jay McClelland
function [] = initParams(epoch)
% This program initialize and preallocate the parameters needed for the
% model. This should be executed before the simulations.
global p a
%% modeling parameters
p.wf = .05; % noise magnitude
p.lrate = .1; % learning rate
p... |
github | qihongl/mathCognition_PDP_RL-master | updateState.m | .m | mathCognition_PDP_RL-master/[past]/sim09_activeEnd/updateState.m | 1,073 | utf_8 | c30f534ef1a20e9b0b58a7b6996550f0 | % written by professor Jay McClelland
function [ ] = updateState()
%this function uses the real state to update the internal state
%after Act is called to execute the hand or eye movement action
global w a h p;
if ~w.terminate
%% compute the relative locations
% the relative locations of eye and hand... |
github | qihongl/mathCognition_PDP_RL-master | initState.m | .m | mathCognition_PDP_RL-master/[past]/sim09_activeEnd/initState.m | 1,388 | utf_8 | 33bb9f30d7d7bb789d4ea752fa38c178 | % written by professor Jay McClelland
function [ ] = initState( )
global a w h p;
%realState is characterized by the position of a target to touch,
%position of eye, and position of hand
%in a 101-pixel one-d space
%viewedState is the input I have given that my eye and hand are
%at particular positions w.r... |
github | qihongl/mathCognition_PDP_RL-master | plotResults.m | .m | mathCognition_PDP_RL-master/[past]/sim09_activeEnd/plotResults.m | 544 | utf_8 | da928d22f60607e06a82b5f24fe4b624 | function plotResults(record)
global d;
% initialize the parameters for the plot
d.fh = figure();
d.fh.WindowStyle = 'docked';
d.rax = subplot(3,1,1);
d.hax = subplot(3,1,2);
d.wax = subplot(3,1,3);
% d.dtimes = 2.^(10:10);
% load('record.mat');
for i = 1 : size(record.r{size(record.r,2)}.h,2)
plotRes(i, record);
e... |
github | qihongl/mathCognition_PDP_RL-master | trainAgent.m | .m | mathCognition_PDP_RL-master/[past]/sim09_activeEnd/trainAgent.m | 633 | utf_8 | 241e4f6edcbb3b8513ccd0a1154481f0 | % written by professor Jay McClelland
function [record] = trainAgent(epoch)
%% This function trains the network n trials
% initialize parameters
global p a;
initParams(epoch);
initPlot();
% preallocate
record.a = cell(1,epoch);
record.steps = nan(1,epoch);
% train the model for n trials
for i = 1:p.runs
... |
github | qihongl/mathCognition_PDP_RL-master | Act.m | .m | mathCognition_PDP_RL-master/[past]/sim09_activeEnd/Act.m | 488 | utf_8 | 9e8a9f26f6c3c2c4c608ce08449f0556 | % written by professor Jay McClelland
function [ ] = Act( )
% here we act according to the action selected
% by selectAction
global w;
%% perform the actions
% update the real locations of hand and eye
if ~w.terminate
w.rS.handPos = w.rS.handPos + w.out.handStep;
w.rS.eyePos = w.rS.eyePos + w.out.eyeS... |
github | qihongl/mathCognition_PDP_RL-master | runAgent.m | .m | mathCognition_PDP_RL-master/[past]/sim11_reorgWts/runAgent.m | 1,236 | utf_8 | 5057c1bc90cf21306c34d2d69a128a54 | % written by professor Jay McClelland
function [ results ] = runAgent()
global a w h p;
% rng(seed)
% w.seed = seed;
%% initialize the state
initState();
updateState();
% compute the true answers
w.answer = computeAnswer(w);
%% training the model once
i = 0;
teachTrial = 0;
indices = zeros(1,p.maxIter)... |
github | qihongl/mathCognition_PDP_RL-master | updateWeights.m | .m | mathCognition_PDP_RL-master/[past]/sim11_reorgWts/updateWeights.m | 684 | utf_8 | 2a35707770a0830894255d38e3f647ef | % written by professor Jay McClelland
function [ ] = updateWeights()
% this function controls:
% 1. the reward policy
% 2. the weight update
% 3. activate the "teaching"
global a w p;
%% compute the reward values according to the reward policy
Rwd = computeRwd();
%% assign the reward values
a.Rwd = Rwd;
a... |
github | qihongl/mathCognition_PDP_RL-master | selectAction.m | .m | mathCognition_PDP_RL-master/[past]/sim11_reorgWts/selectAction.m | 725 | utf_8 | 97771aa99d8de06b91a45b864e56e9df | % written by professor Jay McClelland
function [] = selectAction( )
% It computes the output, and choose the action probabilistically.
global w a p;
%% compute the output activation
a.act = a.wts * w.vS.visInput';
% bias toward action 0 (don't move)
a.act(p.mvRad + 1) = a.act(p.mvRad + 1) + a.bias;
% choose a... |
github | qihongl/mathCognition_PDP_RL-master | testing.m | .m | mathCognition_PDP_RL-master/[past]/sim11_reorgWts/testing.m | 203 | utf_8 | 65dd0a3704cb4144700d979421496313 | % just testing, a short cut for running the model
function testing(epoch)
if nargin == 0
epoch = 5000;
end
record = trainAgent(epoch);
save('record','record');
% checkDevelop()
% quiz(1)
quiz()
end
|
github | qihongl/mathCognition_PDP_RL-master | showState.m | .m | mathCognition_PDP_RL-master/[past]/sim11_reorgWts/showState.m | 868 | utf_8 | 202e013589af7195dff3752ee07b5224 | % written by professor Jay McClelland
function [ ] = showState( )
global p w d a;
% plot rewards over time
axes(d.rax);
plot(w.rS.time,a.Rwd,'-*'); hold on;
ylim(d.rax,[p.r.bigNeg-.5 p.r.bigPos+.5]);
xlim(d.rax,[-0.25,w.rS.time+0.25]);
% plot the history of eye and hand positions
t = w.rS.time;
axes(d.hax... |
github | qihongl/mathCognition_PDP_RL-master | initParams.m | .m | mathCognition_PDP_RL-master/[past]/sim11_reorgWts/initParams.m | 1,532 | utf_8 | dbb63aafb434702f6b19db80962657dd | % written by professor Jay McClelland
function [] = initParams(epoch)
% This program initialize and preallocate the parameters needed for the
% model. This should be executed before the simulations.
global p a
%% modeling parameters
p.wf = .2; % noise magnitude
p.lrate = .01; % learning rate
p... |
github | qihongl/mathCognition_PDP_RL-master | updateState.m | .m | mathCognition_PDP_RL-master/[past]/sim11_reorgWts/updateState.m | 1,051 | utf_8 | 12aaeb27b0041356a1078ac6d89f8170 | % written by professor Jay McClelland
function [ ] = updateState()
%this function uses the real state to update the internal state
%after Act is called to execute the hand or eye movement action
global w a h p;
%% compute the relative locations
% the relative locations of eye and hand
w.vS.eyePos = 0;
w.vS.... |
github | qihongl/mathCognition_PDP_RL-master | initState.m | .m | mathCognition_PDP_RL-master/[past]/sim11_reorgWts/initState.m | 1,304 | utf_8 | cb0b6a32aba20ff19457751d2875696c | % written by professor Jay McClelland
function [ ] = initState( )
global a w h p;
%realState is characterized by the position of a target to touch,
%position of eye, and position of hand
%in a 101-pixel one-d space
%viewedState is the input I have given that my eye and hand are
%at particular positions w.r... |
github | qihongl/mathCognition_PDP_RL-master | plotResults.m | .m | mathCognition_PDP_RL-master/[past]/sim11_reorgWts/plotResults.m | 544 | utf_8 | da928d22f60607e06a82b5f24fe4b624 | function plotResults(record)
global d;
% initialize the parameters for the plot
d.fh = figure();
d.fh.WindowStyle = 'docked';
d.rax = subplot(3,1,1);
d.hax = subplot(3,1,2);
d.wax = subplot(3,1,3);
% d.dtimes = 2.^(10:10);
% load('record.mat');
for i = 1 : size(record.r{size(record.r,2)}.h,2)
plotRes(i, record);
e... |
github | qihongl/mathCognition_PDP_RL-master | trainAgent.m | .m | mathCognition_PDP_RL-master/[past]/sim11_reorgWts/trainAgent.m | 932 | utf_8 | 6d676edbc67de65f982f6b593081d646 | % written by professor Jay McClelland
function [record] = trainAgent(epoch)
%% This function trains the network n trials
% initialize parameters
global p a;
initParams(epoch);
% preallocate
record.a = cell(1,epoch);
record.steps = nan(1,epoch);
% record.indices = cell(1,epoch);
% record.completed = false(1,... |
github | qihongl/mathCognition_PDP_RL-master | computeRwd.m | .m | mathCognition_PDP_RL-master/[past]/sim11_reorgWts/computeRwd.m | 2,090 | utf_8 | 2ec959c5dd9810f59222cd200cb5f256 | function Rwd = computeRwd()
%% this function controls the reward policy
global w p h;
w.actionCorrect = true;
% if there is remaining items
if targetRemain()
if w.out.handStep == 0
Rwd = p.r.smallNeg;
elseif ~isTouchingObj % touching empty spot
Rwd = p.r.smallNeg;
elseif objIsTouched ... |
github | qihongl/mathCognition_PDP_RL-master | Act.m | .m | mathCognition_PDP_RL-master/[past]/sim11_reorgWts/Act.m | 404 | utf_8 | c8ce5a2f3bcdf3fa4195dafad94f8e76 | % written by professor Jay McClelland
function [ ] = Act( )
% here we act according to the action selected
% by selectAction
global w p;
%% perform the actions
% update the real locations of hand and eye
w.rS.handPos = w.rS.handPos + w.out.handStep;
w.rS.eyePos = w.rS.eyePos + w.out.eyeStep;
w.rS.td = 1; ... |
github | qihongl/mathCognition_PDP_RL-master | runAgent.m | .m | mathCognition_PDP_RL-master/[past]/sim17.0_repli/runAgent.m | 1,376 | utf_8 | 5c6c39d68b7ef942d3454ecd87566f56 | % written by professor Jay McClelland
function [ results ] = runAgent()
global a w h p mode;
%% initialize the state
initState();
updateState();
computeAnswer(); % compute the true 'answers'
%% training the model once
i = 0;
indices = zeros(1,p.maxIter);
while ~(w.done) && i < p.maxIter
%% choose ... |
github | qihongl/mathCognition_PDP_RL-master | trainOne.m | .m | mathCognition_PDP_RL-master/[past]/sim17.0_repli/trainOne.m | 421 | utf_8 | be57e64e563cd2648ee09c6eee69a8cb | % just testing, a short cut for running the model
function trainOne(epoch, seed)
if nargin == 0
epoch = 10000;
seed = randi(99);
end
% run the simulation
record = trainAgent(epoch, seed);
% save the simulation results
saveDirName = getSaveDir();
save([saveDirName '/' 'record'],'record');
save('record','record... |
github | qihongl/mathCognition_PDP_RL-master | updateWeights.m | .m | mathCognition_PDP_RL-master/[past]/sim17.0_repli/updateWeights.m | 956 | utf_8 | 511a3e2b1aad83253193395c921bebda | % written by professor Jay McClelland
function [ ] = updateWeights()
% this function controls:
% 1. the reward policy
% 2. the weight update
% 3. activate the "teaching"
global p a w;
%% compute the reward values according to the reward policy
curRwd = computeRwd();
expRwd = max(a.aAct);
%% assign the reward ... |
github | qihongl/mathCognition_PDP_RL-master | showState.m | .m | mathCognition_PDP_RL-master/[past]/sim17.0_repli/showState.m | 815 | utf_8 | a358f4d36bf7fb8c54a9023717bb5169 | % written by professor Jay McClelland
function [ ] = showState( )
global p w d a;
% plot rewards over time
axes(d.rwd);
plot(w.rS.time,a.dfRwd,'-*'); hold on;
ylim(d.rwd,[p.r.midNeg p.r.bigPos]);
xlim(d.rwd,[-0.25,w.rS.time+0.25]);
% plot the history of eye and hand positions
t = w.rS.time;
axes(d.history... |
github | qihongl/mathCognition_PDP_RL-master | move.m | .m | mathCognition_PDP_RL-master/[past]/sim17.0_repli/move.m | 403 | utf_8 | 76f0765b052705d3747442411be8e898 | % written by professor Jay McClelland
function [ ] = move( )
% here we act according to the action selected
% by selectAction
global w;
%% perform the actions
% update the real locations of hand and eye
w.rS.handPos = w.rS.handPos + w.out.handStep;
w.rS.eyePos = w.rS.eyePos + w.out.eyeStep;
w.rS.td = 1; ... |
github | qihongl/mathCognition_PDP_RL-master | initParams.m | .m | mathCognition_PDP_RL-master/[past]/sim17.0_repli/initParams.m | 2,502 | utf_8 | a0e85c40843b03c8dc3cca38d8a59852 | % written by professor Jay McClelland
function [] = initParams(epoch)
% This program initialize and preallocate the parameters needed for the
% model. This should be executed before the simulations.
global p a
p.teachingStyle = 1;
% 1 = final reward only
% 2 = intermediate reward
% 3 = final reward only + tea... |
github | qihongl/mathCognition_PDP_RL-master | updateState.m | .m | mathCognition_PDP_RL-master/[past]/sim17.0_repli/updateState.m | 995 | utf_8 | f8f56ccfe5f39474b48ebeafee2d6aaa | % written by professor Jay McClelland
function [ ] = updateState()
%this function uses the real state to update the internal state
%after Act is called to execute the hand or eye movement action
global w h p;
%% compute the relative locations
% the relative locations of eye and hand
w.vS.eyePos = 0;
w.vS.ha... |
github | qihongl/mathCognition_PDP_RL-master | initState.m | .m | mathCognition_PDP_RL-master/[past]/sim17.0_repli/initState.m | 1,630 | utf_8 | 33299d877a4234e89c16dee856064680 | % written by professor Jay McClelland
function [ ] = initState( )
global a w h p mode;
%realState is characterized by the position of a target to touch,
%position of eye, and position of hand 1-d space
%viewedState is the input I have given that my eye and hand are
%at particular positions w.r.t. the realSt... |
github | qihongl/mathCognition_PDP_RL-master | plotResults.m | .m | mathCognition_PDP_RL-master/[past]/sim17.0_repli/plotResults.m | 544 | utf_8 | da928d22f60607e06a82b5f24fe4b624 | function plotResults(record)
global d;
% initialize the parameters for the plot
d.fh = figure();
d.fh.WindowStyle = 'docked';
d.rax = subplot(3,1,1);
d.hax = subplot(3,1,2);
d.wax = subplot(3,1,3);
% d.dtimes = 2.^(10:10);
% load('record.mat');
for i = 1 : size(record.r{size(record.r,2)}.h,2)
plotRes(i, record);
e... |
github | qihongl/mathCognition_PDP_RL-master | trainAgent.m | .m | mathCognition_PDP_RL-master/[past]/sim17.0_repli/trainAgent.m | 1,501 | utf_8 | 61e7aeb84f1a92e22f73306d60a6cdcd | %% Trains the network n trials
% written by professor Jay McClelland
function [record] = trainAgent(epoch, seed)
%% initialization
% initialize parameters
global p a w mode;
initParams(epoch);
p.seed = seed;
rng(seed)
% preallocate
record.a = cell(1,epoch);
s.steps = nan(1,epoch);
s.indices = cell(1,epoch... |
github | qihongl/mathCognition_PDP_RL-master | computeRwd.m | .m | mathCognition_PDP_RL-master/[past]/sim17.0_repli/computeRwd.m | 2,173 | utf_8 | 0c8b1cffd9b43542da04ee92f5bc4d51 | function Rwd = computeRwd()
%% this function controls the reward policy
global w p h;
w.actionCorrect = true;
% if there is remaining items
if targetRemain()
if w.out.handStep == 0 % not moving
Rwd = p.r.smallNeg;
elseif ~isTouchingObj % touching empty spot
Rwd = p.r.smallNeg;
els... |
github | qihongl/mathCognition_PDP_RL-master | runAgent.m | .m | mathCognition_PDP_RL-master/[past]/sim17.0_repli/old/runAgent.m | 1,365 | utf_8 | 7f5222b4e5989d6fe10199d2aa02dc74 | % written by professor Jay McClelland
function [ results ] = runAgent()
global a w h p mode;
% rng(seed)
% w.seed = seed;
%% initialize the state
initState();
updateState();
computeAnswer(); % compute the true 'answers'
%% training the model once
i = 0;
indices = zeros(1,p.maxIter);
while ~(w.done) &... |
github | qihongl/mathCognition_PDP_RL-master | initParams.m | .m | mathCognition_PDP_RL-master/[past]/sim17.0_repli/old/initParams.m | 1,946 | utf_8 | 7a0424b91aa1b9514a2248fbfac77f93 |
% written by professor Jay McClelland
function [] = initParams(epoch)
% This program initialize and preallocate the parameters needed for the
% model. This should be executed before the simulations.
global p a
%% modeling parameters
p.wf = .1; % noise magnitude
p.lrate = .001; % learning rate... |
github | qihongl/mathCognition_PDP_RL-master | initState.m | .m | mathCognition_PDP_RL-master/[past]/sim17.0_repli/old/initState.m | 1,719 | utf_8 | 8dc549d48ae7d5fd6f3156ca975bd5db | % written by professor Jay McClelland
function [ ] = initState( )
global a w h p mode;
%realState is characterized by the position of a target to touch,
%position of eye, and position of hand 1-d space
%viewedState is the input I have given that my eye and hand are
%at particular positions w.r.t. the realSt... |
github | qihongl/mathCognition_PDP_RL-master | trainAgent.m | .m | mathCognition_PDP_RL-master/[past]/sim17.0_repli/old/trainAgent.m | 1,663 | utf_8 | f8877b1e7a4b128c32d99d394fa6ed05 | %% Trains the network n trials
% written by professor Jay McClelland
function [record] = trainAgent(epoch, seed)
%% initialization
% initialize parameters
rng(seed)
global p a w mode;
initParams(epoch);
% preallocate
record.a = cell(1,epoch);
s.steps = nan(1,epoch);
s.indices = cell(1,epoch);
s.completed ... |
github | qihongl/mathCognition_PDP_RL-master | runAgent.m | .m | mathCognition_PDP_RL-master/[past]/sim18_someSim/runAgent.m | 1,334 | utf_8 | eaee6e61281a57a3801348b1e962cba8 | % written by professor Jay McClelland
function [ results ] = runAgent()
global a w h p mode;
%% initialize the state
initState();
updateState();
computeAnswer(); % compute the true 'answers'
%% training the model once
i = 0;
indices = zeros(1,p.maxIter);
while ~(w.done) && i < p.maxIter
%% choose ... |
github | qihongl/mathCognition_PDP_RL-master | trainOne.m | .m | mathCognition_PDP_RL-master/[past]/sim18_someSim/trainOne.m | 495 | utf_8 | 033062b4bd9760e513c0425fe940ca61 | % just testing, a short cut for running the model
function trainOne(epoch, seed)
if nargin == 0
epoch = 5000;
seed = randi(99);
end
%% run the simulation
record = trainAgent(epoch, seed);
%% save the simulation results
saveDirName = getSaveDir();
save([saveDirName '/' 'record'],'record');
save('record','recor... |
github | qihongl/mathCognition_PDP_RL-master | updateWeights.m | .m | mathCognition_PDP_RL-master/[past]/sim18_someSim/updateWeights.m | 914 | utf_8 | ab794a3d120672442dd06efcb4238df8 | % written by professor Jay McClelland
function [ ] = updateWeights()
% this function controls:
% 1. the reward policy
% 2. the weight update
% 3. activate the "teaching"
global p a w;
%% compute the reward values according to the reward policy
a.curRwd = computeRwd();
expRwd = max(a.aAct);
%% assign the rewar... |
github | qihongl/mathCognition_PDP_RL-master | move.m | .m | mathCognition_PDP_RL-master/[past]/sim18_someSim/move.m | 402 | utf_8 | 9240309e992077ffcf3f10b3cc146514 | % written by professor Jay McClelland
function [ ] = Act( )
% here we act according to the action selected
% by selectAction
global w;
%% perform the actions
% update the real locations of hand and eye
w.rS.handPos = w.rS.handPos + w.out.handStep;
w.rS.eyePos = w.rS.eyePos + w.out.eyeStep;
w.rS.td = 1; %... |
github | qihongl/mathCognition_PDP_RL-master | initParams.m | .m | mathCognition_PDP_RL-master/[past]/sim18_someSim/initParams.m | 2,064 | utf_8 | 8e7f81ace7040e4b08e928b47c7fa04e | % written by professor Jay McClelland
function [] = initParams(epoch, seed)
% This program initialize and preallocate the parameters needed for the
% model. This should be executed before the simulations.
global p a
%% modeling parameters
p.wf = .1; % noise magnitude
p.lrate = .0003; % learnin... |
github | qihongl/mathCognition_PDP_RL-master | updateState.m | .m | mathCognition_PDP_RL-master/[past]/sim18_someSim/updateState.m | 949 | utf_8 | 71fbfd2359d475c11bde119d444d2c38 | % written by professor Jay McClelland
function [ ] = updateState()
%this function uses the real state to update the internal state
%after Act is called to execute the hand or eye movement action
global w h p;
%% compute the relative locations
% the relative locations of eye and hand
w.vS.eyePos = 0;
w.vS.ha... |
github | qihongl/mathCognition_PDP_RL-master | initState.m | .m | mathCognition_PDP_RL-master/[past]/sim18_someSim/initState.m | 1,605 | utf_8 | 679fd01c6e7b69f2931fe250b000c317 | % written by professor Jay McClelland
function [ ] = initState( )
global a w h p mode;
%% initialize the parameters
a.dfRwd = 0;
a.Rwd = 0;
w.rS.time = 0;
w.rS.td = 0;
w.stateNum = -1;
% preallocation - input and activation values for all layers
a.aIn = zeros(p.mvRange,1); % action layer
a.aA... |
github | qihongl/mathCognition_PDP_RL-master | plotResults.m | .m | mathCognition_PDP_RL-master/[past]/sim18_someSim/plotResults.m | 544 | utf_8 | da928d22f60607e06a82b5f24fe4b624 | function plotResults(record)
global d;
% initialize the parameters for the plot
d.fh = figure();
d.fh.WindowStyle = 'docked';
d.rax = subplot(3,1,1);
d.hax = subplot(3,1,2);
d.wax = subplot(3,1,3);
% d.dtimes = 2.^(10:10);
% load('record.mat');
for i = 1 : size(record.r{size(record.r,2)}.h,2)
plotRes(i, record);
e... |
github | qihongl/mathCognition_PDP_RL-master | trainAgent.m | .m | mathCognition_PDP_RL-master/[past]/sim18_someSim/trainAgent.m | 1,667 | utf_8 | 3f6d8f0a7259db88a6a7eece759e6ded | %% Trains the network n trials
% written by professor Jay McClelland
function [record] = trainAgent(epoch, seed)
%% initialization
% initialize parameters
rng(seed)
global p a w mode;
initParams(epoch, seed);
% preallocate
record.a = cell(1,epoch);
s.steps = nan(1,epoch);
s.indices = cell(1,epoch);
s.comp... |
github | qihongl/mathCognition_PDP_RL-master | computeRwd.m | .m | mathCognition_PDP_RL-master/[past]/sim18_someSim/computeRwd.m | 2,610 | utf_8 | 10c26b1fe0767fa60553b9a7741014f2 | function Rwd = computeRwd()
%% this function controls the reward policy
global w p h;
w.actionCorrect = true;
% if there is remaining items
if targetRemain()
if w.out.handStep == 0 % not moving
Rwd = p.r.smallNeg;
% if stop too long, also termiante
% if h(w.stateNum).w.out.handStep == 0... |
github | qihongl/mathCognition_PDP_RL-master | runAgent.m | .m | mathCognition_PDP_RL-master/[past]/sim17.0_repTanh/runAgent.m | 1,376 | utf_8 | 5c6c39d68b7ef942d3454ecd87566f56 | % written by professor Jay McClelland
function [ results ] = runAgent()
global a w h p mode;
%% initialize the state
initState();
updateState();
computeAnswer(); % compute the true 'answers'
%% training the model once
i = 0;
indices = zeros(1,p.maxIter);
while ~(w.done) && i < p.maxIter
%% choose ... |
github | qihongl/mathCognition_PDP_RL-master | trainOne.m | .m | mathCognition_PDP_RL-master/[past]/sim17.0_repTanh/trainOne.m | 421 | utf_8 | be57e64e563cd2648ee09c6eee69a8cb | % just testing, a short cut for running the model
function trainOne(epoch, seed)
if nargin == 0
epoch = 10000;
seed = randi(99);
end
% run the simulation
record = trainAgent(epoch, seed);
% save the simulation results
saveDirName = getSaveDir();
save([saveDirName '/' 'record'],'record');
save('record','record... |
github | qihongl/mathCognition_PDP_RL-master | updateWeights.m | .m | mathCognition_PDP_RL-master/[past]/sim17.0_repTanh/updateWeights.m | 951 | utf_8 | 15e2511284ad165d3646c8455c81da9d | % written by professor Jay McClelland
function [ ] = updateWeights()
% this function controls:
% 1. the reward policy
% 2. the weight update
% 3. activate the "teaching"
global p a w;
%% compute the reward values according to the reward policy
curRwd = computeRwd();
expRwd = max(a.aAct);
%% assign the reward ... |
github | qihongl/mathCognition_PDP_RL-master | showState.m | .m | mathCognition_PDP_RL-master/[past]/sim17.0_repTanh/showState.m | 813 | utf_8 | 435d991aebca9b15acc99a289157ccb7 | % written by professor Jay McClelland
function [ ] = showState( )
global p w d a;
% plot rewards over time
axes(d.rwd);
plot(w.rS.time,a.Rwd,'-*'); hold on;
ylim(d.rwd,[p.r.midNeg p.r.bigPos]);
xlim(d.rwd,[-0.25,w.rS.time+0.25]);
% plot the history of eye and hand positions
t = w.rS.time;
axes(d.history);... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.