I am trying to convert a Matlab code which uses a "Orthogonal Procrustes problem" to a python code (via tensorflow 1.14)
Maltab code:
[Ux,~,~] = svd(X,0); Ux = Ux(:,1:r);
Yproj = Ux'*Y; Xproj = Ux'*X; % Project X and Y onto principal components
[Uyx, ~, Vyx] = svd(Yproj*Xproj',0);
Aproj = Uyx*Vyx';
A = @(x) Ux*(Aproj*(Ux'*x));
Python code :
Ux, _, _ =randomized_svd(tf.transpose(X, n_components=r)
# Project X and Y onto Principal components
Yproj=tf.matmul(tf.transpose(Ux), Y)
Xproj=tf.matmul(tf.transpose(Ux), X)
Uyx, _, Vyx =randomized_svd(tf.matmul(Yproj, tf.transpose(Xproj)))
Aproj = tf.matmul(Uyx, tf.transpose(Vyx))
Is this conversion correct? It is given me some problems when I run it. I hope that you can help me