svd gradient is not implemented for abs(m - n) > 1 when full_matrices is True
Package:
tensorflow
158813

Exception Class:
NotImplementedError
Raise code
e_adjoint = True
m, n = n, m
u, v = v, u
grad_u, grad_v = grad_v, grad_u
with ops.control_dependencies([grad_s, grad_u, grad_v]):
if full_matrices and abs(m - n) > 1:
raise NotImplementedError(
"svd gradient is not implemented for abs(m - n) > 1 "
"when full_matrices is True")
s_mat = array_ops.matrix_diag(s)
s2 = math_ops.square(s)
# NOTICE: Because of the term involving f, the gradient becomes
# infinite (or NaN in practice) when singular values are not unique.
#
Links to the raise (1)
https://github.com/tensorflow/tensorflow/blob/7acd515ec218b414d5b16e6710268ac03d9f5421/tensorflow/python/ops/linalg_grad.py#L867Ways to fix
#Inefficient but running: use A^T A, AA^T and tf.linalg.eig.
import tensorflow as tf
AAT = tf.matmul(A, tf.transpose(A))
ATA = tf.matmul(tf.transpose(A), A)
_, U = tf.transpose(tf.linalg.eig(AAT))
_, V = tf.linalg.eig(ATA)
Add a possible fix
Please authorize to post fix