votes up 1

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

Package:
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.
    # 
😲  Walkingbet is Android app that pays you real bitcoins for a walking. Withdrawable real money bonus is available now, hurry up! 🚶

Ways to fix

votes up 1 votes down

#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)
Jul 01, 2022 dankanddong answer

Add a possible fix

Please authorize to post fix