Home > learn_policy > ccl_learnp_pi.m

ccl_learnp_pi

PURPOSE ^

model = ccl_learnp_pi(X,Y,model)

SYNOPSIS ^

function model = ccl_learnp_pi(X,Y,model)

DESCRIPTION ^

 model = ccl_learnp_pi(X,Y,model)

 Learn null space policy using regularised Least square method (parametric model)

 Input:

   X                               Input data
   Y                               Target data
   model                           Parametric model parameters

 Output:

   model                           learnt model parameters

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function model = ccl_learnp_pi(X,Y,model)
0002 % model = ccl_learnp_pi(X,Y,model)
0003 %
0004 % Learn null space policy using regularised Least square method (parametric model)
0005 %
0006 % Input:
0007 %
0008 %   X                               Input data
0009 %   Y                               Target data
0010 %   model                           Parametric model parameters
0011 %
0012 % Output:
0013 %
0014 %   model                           learnt model parameters
0015 
0016 
0017 
0018 
0019 % CCL: A MATLAB library for Constraint Consistent Learning
0020 % Copyright (C) 2007  Matthew Howard
0021 % Contact: matthew.j.howard@kcl.ac.uk
0022 %
0023 % This library is free software; you can redistribute it and/or
0024 % modify it under the terms of the GNU Lesser General Public
0025 % License as published by the Free Software Foundation; either
0026 % version 2.1 of the License, or (at your option) any later version.
0027 %
0028 % This library is distributed in the hope that it will be useful,
0029 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0030 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0031 % Lesser General Public License for more details.
0032 %
0033 % You should have received a copy of the GNU Library General Public
0034 % License along with this library; if not, write to the Free
0035 % Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
0036 
0037 [dimY N] = size(Y);
0038 
0039 % find normalised Y
0040 r = sum(Y.^2,1).^0.5;
0041 YN = Y./repmat(r,dimY,1);
0042 
0043 Phi   = model.phi(X);
0044 dimPhi = size(Phi(:,1),1);
0045 
0046 % construct Jacobian
0047 YPhit = Y*Phi';
0048 g = YPhit(:);
0049 
0050 % construct Hessian
0051 H = zeros(dimY*dimPhi);
0052 for n=1:N
0053 YNPhit = YN(:,n)*Phi(:,n)';
0054 v(:,n) = YNPhit(:);
0055 H = H + v(:,n)*v(:,n)';
0056 end
0057 
0058 % do eigendecomposition for inversion
0059 %[V,D] = eig(H+1e-6*eye(size(H)));
0060 [V,D] = eig(H);
0061 ev = diag(D);
0062 ind = find(ev>1e-6);
0063 V1=V(:,ind);
0064 pinvH1 = V1*diag(ev(ind).^-1)*V1';
0065 model.w=reshape(pinvH1*g,dimY,dimPhi)';
0066

Generated on Mon 01-Jan-2018 15:49:39 by m2html © 2005