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 | move.m | .m | mathCognition_PDP_RL-master/[past]/sim17.0_repTanh/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_repTanh/initParams.m | 2,505 | utf_8 | 32d27415cfb812e4cb445e13525ea33d | % 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_repTanh/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]/sim17.0_repTanh/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_repTanh/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_repTanh/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_repTanh/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_repTanh/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_repTanh/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_repTanh/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_repTanh/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]/sim13_oneItem/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]/sim13_oneItem/updateWeights.m | 706 | utf_8 | 34e32b42c3369818e549f803eede0c73 | % 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]/sim13_oneItem/testing.m | 262 | utf_8 | b6748cb7251fe1a27c234a5c02b50a39 | % just testing, a short cut for running the model
function testing(epoch)
if nargin == 0
epoch = 2000;
end
record = trainAgent(epoch);
save('record','record');
% eval the performance
quiz()
% checkLearning()
beep % notice me that the program was ended
end
|
github | qihongl/mathCognition_PDP_RL-master | showState.m | .m | mathCognition_PDP_RL-master/[past]/sim13_oneItem/showState.m | 1,140 | utf_8 | 0ba1173387f9afc1979d6af0aad95f2c | % written by professor Jay McClelland
function [ ] = showState( )
global p w d a;
% plot rewards over time
axes(d.rwdAx);
plot(w.rS.time,a.Rwd,'-*'); hold on;
ylim(d.rwdAx,[p.r.bigNeg p.r.bigPos]);
xlim(d.rwdAx,[-0.25,w.rS.time+0.25]);
% plot the history of eye and hand positions
t = w.rS.time;
axes(d.his... |
github | qihongl/mathCognition_PDP_RL-master | initParams.m | .m | mathCognition_PDP_RL-master/[past]/sim13_oneItem/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 | computeRwd2.m | .m | mathCognition_PDP_RL-master/[past]/sim13_oneItem/computeRwd2.m | 1,731 | utf_8 | bb2799e2a46161ad5a12b2658bbcd32f | function rwd = computeRwd2()
%% this function controls the reward policy
global w p h;
w.actionCorrect = true;
if isNext()
w.rS.targRemain(w.rS.handPos == w.rS.targPos) = false;
rwd = p.r.midPos;
if ~targetRemain()
rwd = p.r.midPos;
w.done = true;
end
else
if w.rS.handPos < nextOb... |
github | qihongl/mathCognition_PDP_RL-master | updateState.m | .m | mathCognition_PDP_RL-master/[past]/sim13_oneItem/updateState.m | 1,012 | utf_8 | 7abc65886d29800c1ffcd94e2a26c608 | % 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]/sim13_oneItem/initState.m | 1,263 | utf_8 | f97d0e58e21f33de4d471ff70f35fb69 | % 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 1-d space
%viewedState is the input I have given that my eye and hand are
%at particular positions w.r.t. the realState o... |
github | qihongl/mathCognition_PDP_RL-master | plotResults.m | .m | mathCognition_PDP_RL-master/[past]/sim13_oneItem/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]/sim13_oneItem/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]/sim13_oneItem/computeRwd.m | 2,552 | utf_8 | 4ad71f6a5fa3474ca83851ec7da6f5a2 | 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]/sim13_oneItem/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]/sim06_multiObj/runAgent.m | 338 | utf_8 | 0b33456e17a87aaa0dc4f60fcb804253 | % written by professor Jay McClelland
function [ results ] = runAgent()
global a w h p d;
initState();
updateState();
showState();
i = 0;
while ~(w.done) && i < 100
selectAction();
Act();
updateState();
updateWeights();
showState();
i = i+1;
end
%keyboard;
results.h = h;
res... |
github | qihongl/mathCognition_PDP_RL-master | updateWeights.m | .m | mathCognition_PDP_RL-master/[past]/sim06_multiObj/updateWeights.m | 830 | utf_8 | abe33ad8c85510746a004a1a18f50d60 | % written by professor Jay McClelland
function [ ] = updateWeights( )
global a w p;
%% Assign the reward values
% if the hand is touching a item, and that item is untouched before
if any(w.rS.handPos == w.rS.targPos) && (w.rS.targRemain(w.rS.handPos == w.rS.targPos) == true)
w.rS.targRemain(w.rS.targPos =... |
github | qihongl/mathCognition_PDP_RL-master | selectAction.m | .m | mathCognition_PDP_RL-master/[past]/sim06_multiObj/selectAction.m | 778 | utf_8 | 26808e8e7b2ba2af3c3f796360d7b127 | % written by professor Jay McClelland
function [] = selectAction( )
%UNTITLED2 Summary of this function goes here
% Detailed explanation goes here
global w a p;
%% compute the normalized activation
% a.net = a.wts * w.vS.visInput';
% scnet = p.smgain*a.net;
% a.act = exp(scnet)/sum(exp(scnet));
%% compute ... |
github | qihongl/mathCognition_PDP_RL-master | showState.m | .m | mathCognition_PDP_RL-master/[past]/sim06_multiObj/showState.m | 710 | utf_8 | 868e49a6bc76a8f2db42ea01f6091847 | % 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 1.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 | initParamsEtc.m | .m | mathCognition_PDP_RL-master/[past]/sim06_multiObj/initParamsEtc.m | 1,090 | utf_8 | a568e1e544545c38f0bb7a6664258fb1 | % written by professor Jay McClelland
function [] = initParamsEtc( )
% This program initialize and preallocate the parameters needed for the
% model. This should be executed before the simulations.
global p d a
%% modeling parameters
p.wf = .2; % noise magnitude
p.lrate = .1; % learning rate
... |
github | qihongl/mathCognition_PDP_RL-master | choose.m | .m | mathCognition_PDP_RL-master/[past]/sim06_multiObj/choose.m | 337 | utf_8 | 54e0f53b425d2927e123310d920c7989 | % written by professor Jay McClelland
function [ choice ] = choose(strengths)
%choose one of n alternatives according to it's strength
v = rand; % a number between 0 and 1
nstr = strengths/sum(strengths); %normalize strengths
cstr = cumsum(nstr); %get top edges of bins
choice = find(cstr>v,1); %returns the bin v ... |
github | qihongl/mathCognition_PDP_RL-master | updateState.m | .m | mathCognition_PDP_RL-master/[past]/sim06_multiObj/updateState.m | 1,025 | utf_8 | 17a84148d48a20188df31db95a4f09ab | % 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 d h p;
%% compute the relative locations
% the relative locations of eye and hand
w.vS.eyePos = 0;
w.v... |
github | qihongl/mathCognition_PDP_RL-master | initState.m | .m | mathCognition_PDP_RL-master/[past]/sim06_multiObj/initState.m | 1,438 | utf_8 | 7d557634047b25efd393a78b171c94da | % written by professor Jay McClelland
function [ ] = initState( )
global a w d 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 a... |
github | qihongl/mathCognition_PDP_RL-master | plotResults.m | .m | mathCognition_PDP_RL-master/[past]/sim06_multiObj/plotResults.m | 514 | utf_8 | e59faaaefca2215f05b175901cd86982 | 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.results.h,2)
plotRes(i, record);
end
end
%... |
github | qihongl/mathCognition_PDP_RL-master | trainAgent.m | .m | mathCognition_PDP_RL-master/[past]/sim06_multiObj/trainAgent.m | 534 | utf_8 | 525c0c1fba899c742d0bef583a77a637 | % written by professor Jay McClelland
function [record] = trainAgent( )
global p d a;
initParamsEtc();
run = struct('results',[]);
di = 1;
% textprogressbar('Training: ')
for i = 1:p.runs
% textprogressbar(i)
run.results = runAgent();
a.smgain = a.smgain + p.smirate;
if i == d.dtimes(di)
... |
github | qihongl/mathCognition_PDP_RL-master | Act.m | .m | mathCognition_PDP_RL-master/[past]/sim06_multiObj/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.3_compTeach/runAgent.m | 1,514 | utf_8 | 4fc12b3ebb17803f52dfcdb2c2e78338 | % 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 | trainOne.m | .m | mathCognition_PDP_RL-master/[past]/sim16.3_compTeach/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]/sim16.3_compTeach/updateWeights.m | 764 | utf_8 | 04391ab808a2c6442632b5f50d71b7e8 | % 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.wts*w.vS.visInput');
%% assi... |
github | qihongl/mathCognition_PDP_RL-master | showState.m | .m | mathCognition_PDP_RL-master/[past]/sim16.3_compTeach/showState.m | 1,317 | utf_8 | 177371f3562e9304f1bf71be51424ff1 | % 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]/sim16.3_compTeach/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]/sim16.3_compTeach/initParams.m | 2,791 | utf_8 | 4397013b631ddbd55b44b6296f64f3db | % 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 = 2;
% 1 = final reward only
% 2 = intermediate reward
% 3 = final reward only + t... |
github | qihongl/mathCognition_PDP_RL-master | computeRwd2.m | .m | mathCognition_PDP_RL-master/[past]/sim16.3_compTeach/computeRwd2.m | 1,731 | utf_8 | bb2799e2a46161ad5a12b2658bbcd32f | function rwd = computeRwd2()
%% this function controls the reward policy
global w p h;
w.actionCorrect = true;
if isNext()
w.rS.targRemain(w.rS.handPos == w.rS.targPos) = false;
rwd = p.r.midPos;
if ~targetRemain()
rwd = p.r.midPos;
w.done = true;
end
else
if w.rS.handPos < nextOb... |
github | qihongl/mathCognition_PDP_RL-master | updateState.m | .m | mathCognition_PDP_RL-master/[past]/sim16.3_compTeach/updateState.m | 1,006 | utf_8 | da181c33147e6060360e7907fc3221da | % 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.3_compTeach/initState.m | 1,594 | utf_8 | d62eadf6f64277fd0e0e4533bcc1baf3 | % 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]/sim16.3_compTeach/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]/sim16.3_compTeach/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.3_compTeach/computeRwd.m | 2,255 | utf_8 | ffb5370d99695989298f09793052de31 | 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]/sim16_eRwd/runAgent.m | 1,361 | utf_8 | 33717e64beff2962e254ba9dcbd837c7 | % 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 | trainOne.m | .m | mathCognition_PDP_RL-master/[past]/sim16_eRwd/trainOne.m | 495 | utf_8 | ed9e3cddf6a917bdefbf5acdb18378e7 | % just testing, a short cut for running the model
function trainOne(epoch, seed)
if nargin == 0
epoch = 2000;
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]/sim16_eRwd/updateWeights.m | 764 | utf_8 | 04391ab808a2c6442632b5f50d71b7e8 | % 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.wts*w.vS.visInput');
%% assi... |
github | qihongl/mathCognition_PDP_RL-master | showState.m | .m | mathCognition_PDP_RL-master/[past]/sim16_eRwd/showState.m | 1,317 | utf_8 | 177371f3562e9304f1bf71be51424ff1 | % 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]/sim16_eRwd/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]/sim16_eRwd/initParams.m | 1,800 | utf_8 | 6b7d9e18f07469b0839965095944fbb5 | % 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 = .10; % noise magnitude
p.lrate = .001; % learning rate
... |
github | qihongl/mathCognition_PDP_RL-master | computeRwd2.m | .m | mathCognition_PDP_RL-master/[past]/sim16_eRwd/computeRwd2.m | 1,731 | utf_8 | bb2799e2a46161ad5a12b2658bbcd32f | function rwd = computeRwd2()
%% this function controls the reward policy
global w p h;
w.actionCorrect = true;
if isNext()
w.rS.targRemain(w.rS.handPos == w.rS.targPos) = false;
rwd = p.r.midPos;
if ~targetRemain()
rwd = p.r.midPos;
w.done = true;
end
else
if w.rS.handPos < nextOb... |
github | qihongl/mathCognition_PDP_RL-master | updateState.m | .m | mathCognition_PDP_RL-master/[past]/sim16_eRwd/updateState.m | 951 | utf_8 | 6c3388db9d1faa1711f00bbbdbd2b961 | % 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_eRwd/initState.m | 1,594 | utf_8 | d62eadf6f64277fd0e0e4533bcc1baf3 | % 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]/sim16_eRwd/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]/sim16_eRwd/trainAgent.m | 1,265 | utf_8 | 1a6c887b7a4e1df2e4803d730c1d7301 | %% 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,epo... |
github | qihongl/mathCognition_PDP_RL-master | computeRwd.m | .m | mathCognition_PDP_RL-master/[past]/sim16_eRwd/computeRwd.m | 2,281 | utf_8 | 803655ae19d2afbbfea096bb0ecaf0db | 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 | testing.m | .m | mathCognition_PDP_RL-master/[past]/sim05_vision/testing.m | 230 | utf_8 | 90125129ffa77abfc0d9b59947e48316 | %% run the touching model
function out = testing(numtrials)
if nargin == 0
numtrials = 200;
end
% function [output] = touch(epochs, seed, ...
% doPlotting, showSteps, showProgress)
out = touch(numtrials, 0, 1, 0, 0);
end |
github | qihongl/mathCognition_PDP_RL-master | chooseAction.m | .m | mathCognition_PDP_RL-master/[past]/sim05_vision/chooseAction.m | 417 | utf_8 | dd4387ad163cb58b2b63c9d39144aaa8 | function [action] = chooseAction(w,a)
global p;
% obtain the probability distribution for actions
qval = a.q(w.curs+1,:);
prob = softmax(qval, p.qscale);
% choose action based
action = sample(prob);
end
function [action] = sample(pr)
rv = rand(1); % sample from a unifrom[0,1]
cp = cumsum(pr);
for i = 1:length(... |
github | qihongl/mathCognition_PDP_RL-master | softmax.m | .m | mathCognition_PDP_RL-master/[past]/sim05_vision/softmax.m | 622 | utf_8 | 90f2f58a719facf0fbef333ac0a0b761 | % SOFTMAX assign probabilities to options
% in my case, x is expected to be a vector of q values for a state: Q(s,:)
function [prob] = softmax(x, scale)
% if there is no input scaling factor, just don't scale it
if nargin == 1
scale = 1;
end
% transform when there is negative values
% TODO: this transformation i... |
github | qihongl/mathCognition_PDP_RL-master | main.m | .m | mathCognition_PDP_RL-master/[past]/sim05_vision/main.m | 910 | utf_8 | 298b6ce296ee874902df341b9f55a50a | %% counting simulation
function main(numtrials)
if nargin == 0
numtrials = 200;
end
% set simulation parameters
nSubj = 10;
%% analysis TODO: revise! this procedure is terrible
% averaging the data
temp = zeros(numtrials,1);
for i = 1 : nSubj
fprintf('%.2d: ', i);
out = touch(numtrials, i, 0, false, tr... |
github | qihongl/mathCognition_PDP_RL-master | initState.m | .m | mathCognition_PDP_RL-master/[past]/sim05_vision/initState.m | 1,658 | utf_8 | 3998d16384512709997d433301faa1f7 | % INITSTATE initialize the state parameters, or set up the "world"
% note that all things here are TRIAL SPECIFIC
% originally written by Professor Jay McClelland
function [w] = initState()
global p;
% preallocation
w.curs = 0; % current state
% w.cura = 0; % current action
w.nexts = 0; % next stat... |
github | qihongl/mathCognition_PDP_RL-master | touch.m | .m | mathCognition_PDP_RL-master/[past]/sim05_vision/touch.m | 1,991 | utf_8 | 704598989cc29170cc21e55e45f479d8 | %% a RL based model for counting
function output = touch(epochs, seed, ...
showPlot, showSteps, showProg)
if nargin == 0
epochs = 100; seed = randi(99);
showPlot = 1; showSteps = 0; showProg = 0;
end
rng(seed);
global p
%% initialization
% modeing parameters
setupParameters(epochs);
% preallocate & initi... |
github | qihongl/mathCognition_PDP_RL-master | setupParameters.m | .m | mathCognition_PDP_RL-master/[past]/sim05_vision/setupParameters.m | 837 | utf_8 | af1223fe00e70a19d07cf3fddfeecb26 | %SETUPPARAMETERS returns the parameters for the model
function [] = setupParameters(epochs)
global p;
% number of training epochs
p.trials = epochs;
% modeling parameters
p.gamma = 0.5; % discount factor
p.alpha = 0.2; % learning rate
p.qscale = 3; % softmax scaling factor
% other parameters
p.rang... |
github | qihongl/mathCognition_PDP_RL-master | runAgent.m | .m | mathCognition_PDP_RL-master/[past]/sim16.7_compUnit++/runAgent.m | 1,027 | utf_8 | 369665523f11be816672436c2e0b03af | % 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.7_compUnit++/trainOne.m | 490 | utf_8 | 2f501a1e78c37b040cf20d3e2224057f | % just testing, a short cut for running the model
function record = trainOne(epoch, seed)
if nargin == 0
epoch = 20000;
seed = randi(99);
end
%% run the simulation
record = trainAgent(epoch, seed);
%% save the simulation results
saveDirName = getSaveDir();
save([saveDirName '/' 'record'],'record');
save('reco... |
github | qihongl/mathCognition_PDP_RL-master | showWeights.m | .m | mathCognition_PDP_RL-master/[past]/sim16.7_compUnit++/showWeights.m | 583 | utf_8 | a5170d34eef2535437720fe5e1a446a5 | function [ ] = showWeights( )
% plot the weights of the model
global p d a;
% plot weights around fovea
axes(d.heatWts)
% imagesc(-p.eyeRad:p.eyeRad,-p.mvRad:p.mvRad+1, a.wts)
visualizeWeightsMatrix(a.wts)
title(d.heatWts, 'Weights: visual -> action', 'fontsize', d.FONTSIZE)
xlabel(d.heatWts, 'Visual input layer', 'fon... |
github | qihongl/mathCognition_PDP_RL-master | updateWeights.m | .m | mathCognition_PDP_RL-master/[past]/sim16.7_compUnit++/updateWeights.m | 715 | utf_8 | f68207b9c5645058cd2f2c36e1c92959 | % 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.wts*w.vS.visInput');
if ~w... |
github | qihongl/mathCognition_PDP_RL-master | showState.m | .m | mathCognition_PDP_RL-master/[past]/sim16.7_compUnit++/showState.m | 2,195 | utf_8 | 04a85884cc5f6e7cf26638c607de124f | % 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.7_compUnit++/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.7_compUnit++/initParams.m | 2,293 | utf_8 | 03577f35a53ff9eaf03bafcd7705be53 | % 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 + tea... |
github | qihongl/mathCognition_PDP_RL-master | updateState.m | .m | mathCognition_PDP_RL-master/[past]/sim16.7_compUnit++/updateState.m | 1,084 | utf_8 | 1be1d547bea5f33708312d440733ee19 | % 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.7_compUnit++/initState.m | 1,657 | utf_8 | a53572c2f5a157c6962f42ca42f339fc | % 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.7_compUnit++/trainAgent.m | 1,728 | utf_8 | 6e63cb65769644e2ba3a061c23d5c3d4 | %% 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 = preallocateScores(epoch);
% train the mode... |
github | qihongl/mathCognition_PDP_RL-master | computeRwd.m | .m | mathCognition_PDP_RL-master/[past]/sim16.7_compUnit++/computeRwd.m | 2,382 | utf_8 | ece39cb88c90cfd4bad47960845c3350 | function Rwd = computeRwd()
%% this function controls the reward policy
global w p h a;
% if there is remaining items
if targetRemain()
if a.choice == p.mvRange +1 % saying "done"
Rwd = p.r.smallNeg;
w.stopEarly = true;
w.done = true;
elseif a.choice == p.mvRad +1 % not moving
... |
github | qihongl/mathCognition_PDP_RL-master | runAgent.m | .m | mathCognition_PDP_RL-master/[past]/sim19_numOut/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]/sim19_numOut/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]/sim19_numOut/updateWeights.m | 1,640 | utf_8 | d6a31308753cd7ed48a3334bf02c2a97 | % 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.aCurRwd = computeRwdA();
a.cCurRwd = computeRwdC();
aExpRwd = ma... |
github | qihongl/mathCognition_PDP_RL-master | showState.m | .m | mathCognition_PDP_RL-master/[past]/sim19_numOut/showState.m | 1,358 | utf_8 | ad3ae791f8672eb24a74bf7d79bd62f6 | % written by professor Jay McClelland
function [ ] = showState()
global p w d a;
FONTSIZE = 13;
% plot rewards over time
axes(d.rwd);
plot(w.rS.time, a.aCurRwd,'-b*');
hold on;
plot(w.rS.time, a.cCurRwd,'-r*');
legend({'move', 'number'},'Location','northeast', 'fontsize', FONTSIZE)
ylim(d.rwd,[p.r.bigNeg ... |
github | qihongl/mathCognition_PDP_RL-master | computeRwdA.m | .m | mathCognition_PDP_RL-master/[past]/sim19_numOut/computeRwdA.m | 2,449 | utf_8 | c074f616df54e7e55174e703000cfb78 | function Rwd = computeRwdA()
%% 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;
el... |
github | qihongl/mathCognition_PDP_RL-master | computeRwd4.m | .m | mathCognition_PDP_RL-master/[past]/sim19_numOut/computeRwd4.m | 2,560 | utf_8 | 966ed5029105a600b5676bd3ac02959d | function Rwd = computeRwd4()
%% 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 w.out.countWord == 0
Rwd = 0;
end
elseif ~isTouchingO... |
github | qihongl/mathCognition_PDP_RL-master | move.m | .m | mathCognition_PDP_RL-master/[past]/sim19_numOut/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 | computeRwdC.m | .m | mathCognition_PDP_RL-master/[past]/sim19_numOut/computeRwdC.m | 2,101 | utf_8 | aed802cd1bdf9f8bd3cba80aa47eaa5d | function Rwd = computeRwdC()
%% this function controls the reward policy
global w p h;
w.actionCorrect = true;
% if there is remaining items
if targetRemain()
if w.out.countWord == 0
Rwd = p.r.smallNeg;
elseif w.out.countWord == sum(w.rS.targRemain == 0)
if isNext
Rwd = p.r.... |
github | qihongl/mathCognition_PDP_RL-master | initParams.m | .m | mathCognition_PDP_RL-master/[past]/sim19_numOut/initParams.m | 2,347 | utf_8 | 1e205b38e7328d953db7f548599d1987 | % 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 = .001; % learning... |
github | qihongl/mathCognition_PDP_RL-master | computeRwd2.m | .m | mathCognition_PDP_RL-master/[past]/sim19_numOut/computeRwd2.m | 2,675 | utf_8 | 8c932d0857888fd7cbf6912069616aa7 | function Rwd = computeRwd2()
%% this function controls the reward policy
global w p h a;
w.actionCorrect = true;
if targetRemain()
if w.out.handStep == 0 % not moving
if w.out.countWord == 0
Rwd = p.r.smallNeg;
else
Rwd = p.r.midNeg;
end
elseif ~isTouchingObj... |
github | qihongl/mathCognition_PDP_RL-master | computeRwd3.m | .m | mathCognition_PDP_RL-master/[past]/sim19_numOut/computeRwd3.m | 2,712 | utf_8 | d01e1685ae5830d67662012dd864497d | function Rwd = computeRwd3()
%% 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
if w.out.countWord == 0
Rwd = p.r.smallNeg;
else
Rwd = p.r.midNeg;
e... |
github | qihongl/mathCognition_PDP_RL-master | updateState.m | .m | mathCognition_PDP_RL-master/[past]/sim19_numOut/updateState.m | 927 | utf_8 | 707d595be766b223efae2768dcb4d49e | % 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]/sim19_numOut/initState.m | 1,939 | utf_8 | 0c97f6db4b71a749dbc867f36bcaca55 | % written by professor Jay McClelland
function [ ] = initState( )
global a w h p mode;
%% initialize the parameters
a.aCurRwd = 0;
a.cCurRwd = 0;
a.aDfRwd = 0;
a.nDfRwd = 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,... |
github | qihongl/mathCognition_PDP_RL-master | plotResults.m | .m | mathCognition_PDP_RL-master/[past]/sim19_numOut/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]/sim19_numOut/trainAgent.m | 1,264 | utf_8 | dce9627a5f534fb7b213206ff984d409 | %% 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]/sim19_numOut/computeRwd.m | 2,107 | utf_8 | 868543671fe4450a621c76965cfc17a0 | 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 | counting.m | .m | mathCognition_PDP_RL-master/[past]/demo_simpleStepper/counting.m | 1,422 | utf_8 | 8bc7b31e26115e843efd6113897b0e5f | %% a RL based model for counting
function rundata = counting(seed, doPlotting)
if nargin == 0
seed = 0; doPlotting = true;
end
% initialization
rng(seed);
%% modeing parameters
p = setupParameters();
% preallocate and initilize Q to small values
a.q = .01 + zeros(p.range+1,p.nactions);
h.stepsToReward = zeros(p.tr... |
github | qihongl/mathCognition_PDP_RL-master | chooseAction.m | .m | mathCognition_PDP_RL-master/[past]/demo_simpleStepper/chooseAction.m | 326 | utf_8 | fbad14f81e9f6fabdfbf8f43900635f3 | function [w] = chooseAction(w,p,a)
if w.curs == 0
w.cura = 2; % 0 is the left end point
else
prob = softmax(a.q(w.curs+1,:), p.qscale);
w.cura = sample(prob);
end
end
function [c] = sample(pr)
rv = rand(1);
cp = cumsum(pr);
for i = 1:length(pr)
if rv < cp(i)
c = i;
return;
end
end... |
github | qihongl/mathCognition_PDP_RL-master | softmax.m | .m | mathCognition_PDP_RL-master/[past]/demo_simpleStepper/softmax.m | 514 | utf_8 | e7e4f88031ecc3f0146648ddf1bc9ae1 | % x is expected to be a vector of q values for a state: Q(s,:)
function [prob] = softmax(x, scale)
% if there is no input scaling factor, just don't scale it
if nargin == 1
scale = 1;
end
% transform when there is negative values
%
if any(x < 0)
x = x - min(x);
end
% softmax transformation
prob = (x.^scal... |
github | qihongl/mathCognition_PDP_RL-master | initState.m | .m | mathCognition_PDP_RL-master/[past]/demo_simpleStepper/initState.m | 279 | utf_8 | 82bcf3281acd302e95c6aa565f5348cc | % written by Professor Jay McClelland
function [w] = initState( )
% preallocation
w.nexts = 0; % next state
w.curs = 0; % current state
w.cura = 0; % current action
w.nexta = 0; % next action
w.R = 0; % reward
w.steps = 0; % steps used
end
|
github | qihongl/mathCognition_PDP_RL-master | initState.m | .m | mathCognition_PDP_RL-master/[past]/sim04_vision_drop/initState.m | 1,549 | utf_8 | dfb2f958cc2fb6bd02358c33e0289f39 | % INITSTATE initialize the state parameters, or set up the "world"
% note that all things here are TRIAL SPECIFIC
% originally written by Professor Jay McClelland
function [w] = initState(p)
%% preallocation for general varibles
% w.curs = 0; % current state
% w.cura = 0; % current action
% w.nexts = 0;... |
github | qihongl/mathCognition_PDP_RL-master | touch.m | .m | mathCognition_PDP_RL-master/[past]/sim04_vision_drop/touch.m | 2,055 | utf_8 | 126d10eb50966c8ba2144952a2bad95c | %% a RL based model for touching items
function output = touch(epochs, seed, doPlotting, showSteps, showProgress)
if nargin == 0
epochs = 100; seed = randi(99);
doPlotting = true; showSteps = false; showProgress = false;
end
rng(seed);
%% initialization
% modeing parameters
p = setupParameters(epochs);
% prea... |
github | qihongl/mathCognition_PDP_RL-master | setupParameters.m | .m | mathCognition_PDP_RL-master/[past]/sim04_vision_drop/setupParameters.m | 658 | utf_8 | b865bcf00de66faf5eb3c07055f387fb | %SETUPPARAMETERS returns the parameters for the model
function [p] = setupParameters(epochs)
% number of training epochs
p.trials = epochs;
% modeling parameters
p.gamma = 0.5; % discount factor
p.alpha = 0.2; % learning rate
p.qscale = 3; % softmax scaling factor
% other parameters
p.range = 10; ... |
github | qihongl/mathCognition_PDP_RL-master | chooseHand.m | .m | mathCognition_PDP_RL-master/[past]/sim04_vision_drop/chooseHand.m | 754 | utf_8 | 814c12d59ab5d067f37fa92054c18ded | function [action] = chooseHand(w,p,a)
% obtain the probability distribution for actions
qval = a.q(w.vS.eye + p.visualRadius + 1,:);
prob = softmax(qval, p.qscale);
% choose action based
action = sample(prob) - p.visualRadius - 1;
end
function [prob] = softmax(x, scale)
% transform when there is negative values
if ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.