(A, name=None)
return tf.matrix_diag_part(S)
Tensorflow svd with gradient.

        Parameters
        ----------
        A : Tensor
            The matrix for which to compute singular values.
        name : string, optional

        Returns
        -------
        s : Tensor
            The singular values of A.
Tensorflow svd with gradient.
Tensorflow svd with gradient .
def _svd(A, name=None):
        """Tensorflow svd with gradient.

        Parameters
        ----------
        A : Tensor
            The matrix for which to compute singular values.
        name : string, optional

        Returns
        -------
        s : Tensor
            The singular values of A.

        """
        S0, U0, V0 = map(tf.stop_gradient,
                         tf.svd(A, full_matrices=True, name=name))
        # A = U * S * V.T
        # S = inv(U) * A * inv(V.T) = U.T * A * V  (orthogonal matrices)
        S = tf.matmul(U0, tf.matmul(A, V0),
                      transpose_a=True)
        return tf.matrix_diag_part(S)
def _svd ( A , name = None ) : S0 , U0 , V0 = map ( tf . stop_gradient , tf . svd ( A , full_matrices = True , name = name ) ) # A = U * S * V.T # S = inv(U) * A * inv(V.T) = U.T * A * V  (orthogonal matrices) S = tf . matmul ( U0 , tf . matmul ( A , V0 ) , transpose_a = True ) return tf . matrix_diag_part ( S )