0

I am trying to solve the Procrustes problem

min |Y - K* X|

I have implemented SVD and the Procrustes problem in a code that I inherited. I have written 2 versions,

First version:

I am projecting X (e.g. self.__psiNNx) and Y (e.g. self.__psiNNy) onto the leading POD modes to reduce the requirements of the computation

self.__psiNNx and self.__psiNNy have dimensions (54, 1)

Sx, Ux , Vx =tf.linalg.svd(self.__psiNNx, full_matrices=False, compute_uv=True)

# # Project X and Y onto  Principal components
Yproj=tf.matmul(tf.transpose(Ux), self.__psiNNy)
Xproj=tf.matmul(tf.transpose(Ux), self.__psiNNx)

Syx, Uyx, Vyx =tf.linalg.svd(tf.matmul(Yproj, tf.transpose(Xproj)),full_matrices=False, compute_uv=True)

This version works fine!

Second version:

I do not do the projections onto POD modes

Syx , Uyx, Vyx =tf.linalg.svd(tf.matmul(self.__psiNNy, tf.transpose(self.__psiNNx)),full_matrices=True, compute_uv=True)

This version gives me an error:


---------------------------------------------------------------------------
InvalidArgumentError                      Traceback (most recent call last)
~/opt/anaconda3/envs/edmd_DL_new/lib/python3.6/site-packages/tensorflow/python/client/session.py in _do_call(self, fn, *args)
   1333     try:
-> 1334       return fn(*args)
   1335     except errors.OpError as e:

~/opt/anaconda3/envs/edmd_DL_new/lib/python3.6/site-packages/tensorflow/python/client/session.py in _run_fn(feed_dict, fetch_list, target_list, options, run_metadata)
   1318       return self._call_tf_sessionrun(
-> 1319           options, feed_dict, fetch_list, target_list, run_metadata)
   1320 

~/opt/anaconda3/envs/edmd_DL_new/lib/python3.6/site-packages/tensorflow/python/client/session.py in _call_tf_sessionrun(self, options, feed_dict, fetch_list, target_list, run_metadata)
   1406         self._session, options, feed_dict, fetch_list, target_list,
-> 1407         run_metadata)
   1408 

InvalidArgumentError: ConcatOp : Dimensions of inputs should match: shape[0] = [54,1] vs. shape[1] = [100000,3]
     [[{{node Model/concat}} = ConcatV2[N=3, T=DT_DOUBLE, Tidx=DT_INT32, _device="/job:localhost/replica:0/task:0/device:CPU:0"](Model/ones_like, _arg_Placeholder_0_0, Model/Output_projection/add, Model_1/concat/axis)]]

During handling of the above exception, another exception occurred:

InvalidArgumentError                      Traceback (most recent call last)
<ipython-input-217-4dbea9e9e52a> in <module>
     15 # Train model
     16 # Can use bigger batch sizes (e.g. 1000 to 5000) if training on GPU
---> 17 losses = model.train(num_epochs=500, batch_size=5000, log_interval=50, verbose=True, x_data=x_data, y_data=y_data)

I am not sure why the second version is not valid, as I am computing the SVD while the first one works fine

Carlos
  • 15
  • 4

0 Answers0