Generating function handles with large numbers of variable coefficients
Show older comments
I've come across a number of types of optimization process which require a parameter search in a high-dimensional space where the number of coefficients to be fit is based on a dataset.
Example: performing PCA on a set of 4k images. The SVD method does not work because the matrix would be ~8 petabytes.
In this context one normalizes each picture, subtracts their average, and renormalizes these difference images. Those images are eigenvectors. One then maximizes the function
sum(a(n)*I(n)).^2
such that
sum(a(n).^2)=1
This requires a function handle of the type
y = @(b,I) b(1)*I(:,:,1)+b(2)*I(:,:,2)+ .. +b(n)*I(:,:,n);
Along with the function to be minimized,
OLS = @(b) (2-sum(sum((y(b)))).^2); % Minimize this to maximize norm(y(b))
Currently i need to write 'y' out explicitly.
Now the question: is there a way to express this in terms of matrix multiplication without explicitly writing it out?
Thank you,
Matt
4 Comments
So you are trying to find the maximum singular value/vector of the matrix
A=reshape(I,[],n);
but A cannot be stored in RAM? How big is n and what is size(I)?
Matthew Reed
on 23 May 2019
Edited: Matthew Reed
on 23 May 2019
Matthew Reed
on 23 May 2019
Edited: Matthew Reed
on 23 May 2019
Accepted Answer
More Answers (1)
I think this is what you want, but am still not totally sure. The way to calculate a sum of scalar/matrix products without explicitly writing out all n terms (if that's the question) would be,
function y=linearOp(b,I)
[p,q,n]=size(I);
y=reshape(I,[],n)*b(:);
y=reshape(y,p,q);
end
Categories
Find more on Linear Least Squares in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!