Generating function handles with large numbers of variable coefficients
Afficher commentaires plus anciens
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 commentaires
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
le 23 Mai 2019
Modifié(e) : Matthew Reed
le 23 Mai 2019
Matthew Reed
le 23 Mai 2019
Modifié(e) : Matthew Reed
le 23 Mai 2019
Réponse acceptée
Plus de réponses (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
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!