neulab/docprompting-conala huggingface dataset:
tf.linalg.lu_matrix_inverse Computes the inverse given the LU decomposition(s) of one or more matrices.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.linalg.lu_matrix_inverse  
tf.linalg.lu_matrix_inverse(
    lower_upper, perm, validate_args=False, name=None
)
 This op is conceptually identical to, inv_X = tf.lu_matrix_inverse(*tf.linalg.lu(X))
tf.assert_near(tf.matrix_inverse(X), inv_X)
# ==> True


Note: this function does not verify the implied matrix is actually invertible nor is this condition checked even when validate_args=True.

 


 Args
  lower_upper   lu as returned by tf.linalg.lu, i.e., if matmul(P, matmul(L, U)) = X then lower_upper = L + U - eye.  
  perm   p as returned by tf.linag.lu, i.e., if matmul(P, matmul(L, U)) = X then perm = argmax(P).  
  validate_args   Python bool indicating whether arguments should be checked for correctness. Note: this function does not verify the implied matrix is actually invertible, even when validate_args=True. Default value: False (i.e., don't validate arguments).  
  name   Python str name given to ops managed by this object. Default value: None (i.e., 'lu_matrix_inverse').   
 


 Returns
  inv_x   The matrix_inv, i.e., tf.matrix_inverse(tf.linalg.lu_reconstruct(lu, perm)).    Examples import numpy as np
import tensorflow as tf
import tensorflow_probability as tfp

x = [[[3., 4], [1, 2]],
     [[7., 8], [3, 4]]]
inv_x = tf.linalg.lu_matrix_inverse(*tf.linalg.lu(x))
tf.assert_near(tf.matrix_inverse(x), inv_x)
# ==> True
tf.linalg.lu_reconstruct The reconstruct one or more matrices from their LU decomposition(s).  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.linalg.lu_reconstruct  
tf.linalg.lu_reconstruct(
    lower_upper, perm, validate_args=False, name=None
)

 


 Args
  lower_upper   lu as returned by tf.linalg.lu, i.e., if matmul(P, matmul(L, U)) = X then lower_upper = L + U - eye.  
  perm   p as returned by tf.linag.lu, i.e., if matmul(P, matmul(L, U)) = X then perm = argmax(P).  
  validate_args   Python bool indicating whether arguments should be checked for correctness. Default value: False (i.e., don't validate arguments).  
  name   Python str name given to ops managed by this object. Default value: None (i.e., 'lu_reconstruct').   
 


 Returns
  x   The original input to tf.linalg.lu, i.e., x as in, lu_reconstruct(*tf.linalg.lu(x)).    Examples import numpy as np
import tensorflow as tf
import tensorflow_probability as tfp

x = [[[3., 4], [1, 2]],
     [[7., 8], [3, 4]]]
x_reconstructed = tf.linalg.lu_reconstruct(*tf.linalg.lu(x))
tf.assert_near(x, x_reconstructed)
# ==> True
tf.linalg.lu_solve Solves systems of linear eqns A X = RHS, given LU factorizations.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.linalg.lu_solve  
tf.linalg.lu_solve(
    lower_upper, perm, rhs, validate_args=False, name=None
)
 
Note: this function does not verify the implied matrix is actually invertible nor is this condition checked even when validate_args=True.

 


 Args
  lower_upper   lu as returned by tf.linalg.lu, i.e., if matmul(P, matmul(L, U)) = X then lower_upper = L + U - eye.  
  perm   p as returned by tf.linag.lu, i.e., if matmul(P, matmul(L, U)) = X then perm = argmax(P).  
  rhs   Matrix-shaped float Tensor representing targets for which to solve; A X = RHS. To handle vector cases, use: lu_solve(..., rhs[..., tf.newaxis])[..., 0].  
  validate_args   Python bool indicating whether arguments should be checked for correctness. Note: this function does not verify the implied matrix is actually invertible, even when validate_args=True. Default value: False (i.e., don't validate arguments).  
  name   Python str name given to ops managed by this object. Default value: None (i.e., 'lu_solve').   
 


 Returns
  x   The X in A @ X = RHS.    Examples import numpy as np
import tensorflow as tf
import tensorflow_probability as tfp

x = [[[1., 2],
      [3, 4]],
     [[7, 8],
      [3, 4]]]
inv_x = tf.linalg.lu_solve(*tf.linalg.lu(x), rhs=tf.eye(2))
tf.assert_near(tf.matrix_inverse(x), inv_x)
# ==> True
tf.linalg.matrix_rank     View source on GitHub    Compute the matrix rank of one or more matrices.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.linalg.matrix_rank  
tf.linalg.matrix_rank(
    a, tol=None, validate_args=False, name=None
)

 


 Arguments
  a   (Batch of) float-like matrix-shaped Tensor(s) which are to be pseudo-inverted.  
  tol   Threshold below which the singular value is counted as 'zero'. Default value: None (i.e., eps * max(rows, cols) * max(singular_val)).  
  validate_args   When True, additional assertions might be embedded in the graph. Default value: False (i.e., no graph assertions are added).  
  name   Python str prefixed to ops created by this function. Default value: 'matrix_rank'.   
 


 Returns
  matrix_rank   (Batch of) int32 scalars representing the number of non-zero singular values.
tf.linalg.matrix_transpose     View source on GitHub    Transposes last two dimensions of tensor a.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.linalg.matrix_transpose, tf.compat.v1.linalg.transpose, tf.compat.v1.matrix_transpose  
tf.linalg.matrix_transpose(
    a, name='matrix_transpose', conjugate=False
)
 For example: x = tf.constant([[1, 2, 3], [4, 5, 6]])
tf.linalg.matrix_transpose(x)  # [[1, 4],
                               #  [2, 5],
                               #  [3, 6]]

x = tf.constant([[1 + 1j, 2 + 2j, 3 + 3j],
                 [4 + 4j, 5 + 5j, 6 + 6j]])
tf.linalg.matrix_transpose(x, conjugate=True)  # [[1 - 1j, 4 - 4j],
                                               #  [2 - 2j, 5 - 5j],
                                               #  [3 - 3j, 6 - 6j]]

# Matrix with two batch dimensions.
# x.shape is [1, 2, 3, 4]
# tf.linalg.matrix_transpose(x) is shape [1, 2, 4, 3]
 Note that tf.matmul provides kwargs allowing for transpose of arguments. This is done with minimal cost, and is preferable to using this function. E.g. # Good!  Transpose is taken at minimal additional cost.
tf.matmul(matrix, b, transpose_b=True)

# Inefficient!
tf.matmul(matrix, tf.linalg.matrix_transpose(b))

 


 Args
  a   A Tensor with rank >= 2.  
  name   A name for the operation (optional).  
  conjugate   Optional bool. Setting it to True is mathematically equivalent to tf.math.conj(tf.linalg.matrix_transpose(input)).   
 


 Returns   A transposed batch matrix Tensor.  

 


 Raises
  ValueError   If a is determined statically to have rank < 2.    Numpy Compatibility In numpy transposes are memory-efficient constant time operations as they simply return a new view of the same data with adjusted strides. TensorFlow does not support strides, linalg.matrix_transpose returns a new tensor with the items permuted.
tf.linalg.matvec     View source on GitHub    Multiplies matrix a by vector b, producing a * b.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.linalg.matvec  
tf.linalg.matvec(
    a, b, transpose_a=False, adjoint_a=False, a_is_sparse=False, b_is_sparse=False,
    name=None
)
 The matrix a must, following any transpositions, be a tensor of rank >= 2, with shape(a)[-1] == shape(b)[-1], and shape(a)[:-2] able to broadcast with shape(b)[:-1]. Both a and b must be of the same type. The supported types are: float16, float32, float64, int32, complex64, complex128. Matrix a can be transposed or adjointed (conjugated and transposed) on the fly by setting one of the corresponding flag to True. These are False by default. If one or both of the inputs contain a lot of zeros, a more efficient multiplication algorithm can be used by setting the corresponding a_is_sparse or b_is_sparse flag to True. These are False by default. This optimization is only available for plain matrices/vectors (rank-2/1 tensors) with datatypes bfloat16 or float32. For example: # 2-D tensor `a`
# [[1, 2, 3],
#  [4, 5, 6]]
a = tf.constant([1, 2, 3, 4, 5, 6], shape=[2, 3])

# 1-D tensor `b`
# [7, 9, 11]
b = tf.constant([7, 9, 11], shape=[3])

# `a` * `b`
# [ 58,  64]
c = tf.linalg.matvec(a, b)


# 3-D tensor `a`
# [[[ 1,  2,  3],
#   [ 4,  5,  6]],
#  [[ 7,  8,  9],
#   [10, 11, 12]]]
a = tf.constant(np.arange(1, 13, dtype=np.int32),
                shape=[2, 2, 3])

# 2-D tensor `b`
# [[13, 14, 15],
#  [16, 17, 18]]
b = tf.constant(np.arange(13, 19, dtype=np.int32),
                shape=[2, 3])

# `a` * `b`
# [[ 86, 212],
#  [410, 563]]
c = tf.linalg.matvec(a, b)

 


 Args
  a   Tensor of type float16, float32, float64, int32, complex64, complex128 and rank > 1.  
  b   Tensor with same type as a and compatible dimensions.  
  transpose_a   If True, a is transposed before multiplication.  
  adjoint_a   If True, a is conjugated and transposed before multiplication.  
  a_is_sparse   If True, a is treated as a sparse matrix.  
  b_is_sparse   If True, b is treated as a sparse matrix.  
  name   Name for the operation (optional).   
 


 Returns   A Tensor of the same type as a and b where each inner-most vector is the product of the corresponding matrices in a and vectors in b, e.g. if all transpose or adjoint attributes are False: output[..., i] = sum_k (a[..., i, k] * b[..., k]), for all indices i. 
    Note   This is matrix-vector product, not element-wise product.   
 


 Raises
  ValueError   If transpose_a and adjoint_a are both set to True.
tf.linalg.normalize     View source on GitHub    Normalizes tensor along dimension axis using specified norm.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.linalg.normalize  
tf.linalg.normalize(
    tensor, ord='euclidean', axis=None, name=None
)
 This uses tf.linalg.norm to compute the norm along axis. This function can compute several different vector norms (the 1-norm, the Euclidean or 2-norm, the inf-norm, and in general the p-norm for p > 0) and matrix norms (Frobenius, 1-norm, 2-norm and inf-norm).
 


 Args
  tensor   Tensor of types float32, float64, complex64, complex128  
  ord   Order of the norm. Supported values are 'fro', 'euclidean', 1, 2, np.inf and any positive real number yielding the corresponding p-norm. Default is 'euclidean' which is equivalent to Frobenius norm if tensor is a matrix and equivalent to 2-norm for vectors. Some restrictions apply: a) The Frobenius norm 'fro' is not defined for vectors, b) If axis is a 2-tuple (matrix norm), only 'euclidean', 'fro', 1, 2, np.inf are supported. See the description of axis on how to compute norms for a batch of vectors or matrices stored in a tensor.  
  axis   If axis is None (the default), the input is considered a vector and a single vector norm is computed over the entire set of values in the tensor, i.e. norm(tensor, ord=ord) is equivalent to norm(reshape(tensor, [-1]), ord=ord). If axis is a Python integer, the input is considered a batch of vectors, and axis determines the axis in tensor over which to compute vector norms. If axis is a 2-tuple of Python integers it is considered a batch of matrices and axis determines the axes in tensor over which to compute a matrix norm. Negative indices are supported. Example: If you are passing a tensor that can be either a matrix or a batch of matrices at runtime, pass axis=[-2,-1] instead of axis=None to make sure that matrix norms are computed.  
  name   The name of the op.   
 


 Returns
  normalized   A normalized Tensor with the same shape as tensor.  
  norm   The computed norms with the same shape and dtype tensor but the final axis is 1 instead. Same as running tf.cast(tf.linalg.norm(tensor, ord, axis keepdims=True), tensor.dtype).   
 


 Raises
  ValueError   If ord or axis is invalid.
tf.linalg.pinv     View source on GitHub    Compute the Moore-Penrose pseudo-inverse of one or more matrices.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.linalg.pinv  
tf.linalg.pinv(
    a, rcond=None, validate_args=False, name=None
)
 Calculate the generalized inverse of a matrix using its singular-value decomposition (SVD) and including all large singular values. The pseudo-inverse of a matrix A, is defined as: 'the matrix that 'solves' [the least-squares problem] A @ x = b,' i.e., if x_hat is a solution, then A_pinv is the matrix such that x_hat = A_pinv @ b. It can be shown that if U @ Sigma @ V.T = A is the singular value decomposition of A, then A_pinv = V @ inv(Sigma) U^T. [(Strang, 1980)][1] This function is analogous to numpy.linalg.pinv. It differs only in default value of rcond. In numpy.linalg.pinv, the default rcond is 1e-15. Here the default is 10. * max(num_rows, num_cols) * np.finfo(dtype).eps.
 


 Args
  a   (Batch of) float-like matrix-shaped Tensor(s) which are to be pseudo-inverted.  
  rcond   Tensor of small singular value cutoffs. Singular values smaller (in modulus) than rcond * largest_singular_value (again, in modulus) are set to zero. Must broadcast against tf.shape(a)[:-2]. Default value: 10. * max(num_rows, num_cols) * np.finfo(a.dtype).eps.  
  validate_args   When True, additional assertions might be embedded in the graph. Default value: False (i.e., no graph assertions are added).  
  name   Python str prefixed to ops created by this function. Default value: 'pinv'.   
 


 Returns
  a_pinv   (Batch of) pseudo-inverse of input a. Has same shape as a except rightmost two dimensions are transposed.   
 


 Raises
  TypeError   if input a does not have float-like dtype.  
  ValueError   if input a has fewer than 2 dimensions.    Examples import tensorflow as tf
import tensorflow_probability as tfp

a = tf.constant([[1.,  0.4,  0.5],
                 [0.4, 0.2,  0.25],
                 [0.5, 0.25, 0.35]])
tf.matmul(tf.linalg..pinv(a), a)
# ==> array([[1., 0., 0.],
             [0., 1., 0.],
             [0., 0., 1.]], dtype=float32)

a = tf.constant([[1.,  0.4,  0.5,  1.],
                 [0.4, 0.2,  0.25, 2.],
                 [0.5, 0.25, 0.35, 3.]])
tf.matmul(tf.linalg..pinv(a), a)
# ==> array([[ 0.76,  0.37,  0.21, -0.02],
             [ 0.37,  0.43, -0.33,  0.02],
             [ 0.21, -0.33,  0.81,  0.01],
             [-0.02,  0.02,  0.01,  1.  ]], dtype=float32)
 References [1]: G. Strang. 'Linear Algebra and Its Applications, 2nd Ed.' Academic Press, Inc., 1980, pp. 139-142.
tf.linalg.qr Computes the QR decompositions of one or more matrices.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.linalg.qr, tf.compat.v1.qr  
tf.linalg.qr(
    input, full_matrices=False, name=None
)
 Computes the QR decomposition of each inner matrix in tensor such that tensor[..., :, :] = q[..., :, :] * r[..., :,:]) Currently, the gradient for the QR decomposition is well-defined only when the first P columns of the inner matrix are linearly independent, where P is the minimum of M and N, the 2 inner-most dimmensions of tensor. # a is a tensor.
# q is a tensor of orthonormal matrices.
# r is a tensor of upper triangular matrices.
q, r = qr(a)
q_full, r_full = qr(a, full_matrices=True)

 


 Args
  input   A Tensor. Must be one of the following types: float64, float32, half, complex64, complex128. A tensor of shape [..., M, N] whose inner-most 2 dimensions form matrices of size [M, N]. Let P be the minimum of M and N.  
  full_matrices   An optional bool. Defaults to False. If true, compute full-sized q and r. If false (the default), compute only the leading P columns of q.  
  name   A name for the operation (optional).   
 


 Returns   A tuple of Tensor objects (q, r).     q   A Tensor. Has the same type as input.  
  r   A Tensor. Has the same type as input.
tf.linalg.slogdet Computes the sign and the log of the absolute value of the determinant of  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.linalg.slogdet  
tf.linalg.slogdet(
    input, name=None
)
 one or more square matrices. The input is a tensor of shape [N, M, M] whose inner-most 2 dimensions form square matrices. The outputs are two tensors containing the signs and absolute values of the log determinants for all N input submatrices [..., :, :] such that determinant = sign*exp(log_abs_determinant). The log_abs_determinant is computed as det(P)*sum(log(diag(LU))) where LU is the LU decomposition of the input and P is the corresponding permutation matrix.
 


 Args
  input   A Tensor. Must be one of the following types: half, float32, float64, complex64, complex128. Shape is [N, M, M].  
  name   A name for the operation (optional).   
 


 Returns   A tuple of Tensor objects (sign, log_abs_determinant).     sign   A Tensor. Has the same type as input.  
  log_abs_determinant   A Tensor. Has the same type as input.
tf.linalg.solve Solves systems of linear equations.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.linalg.solve, tf.compat.v1.matrix_solve  
tf.linalg.solve(
    matrix, rhs, adjoint=False, name=None
)
 Matrix is a tensor of shape [..., M, M] whose inner-most 2 dimensions form square matrices. Rhs is a tensor of shape [..., M, K]. The output is a tensor shape [..., M, K]. If adjoint is False then each output matrix satisfies matrix[..., :, :] * output[..., :, :] = rhs[..., :, :]. If adjoint is True then each output matrix satisfies adjoint(matrix[..., :, :]) * output[..., :, :] = rhs[..., :, :].
 


 Args
  matrix   A Tensor. Must be one of the following types: float64, float32, half, complex64, complex128. Shape is [..., M, M].  
  rhs   A Tensor. Must have the same type as matrix. Shape is [..., M, K].  
  adjoint   An optional bool. Defaults to False. Boolean indicating whether to solve with matrix or its (block-wise) adjoint.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor. Has the same type as matrix.
tf.linalg.sqrtm Computes the matrix square root of one or more square matrices:  View aliases  Main aliases 
tf.matrix_square_root Compat aliases for migration See Migration guide for more details. tf.compat.v1.linalg.sqrtm, tf.compat.v1.matrix_square_root  
tf.linalg.sqrtm(
    input, name=None
)
 matmul(sqrtm(A), sqrtm(A)) = A The input matrix should be invertible. If the input matrix is real, it should have no eigenvalues which are real and negative (pairs of complex conjugate eigenvalues are allowed). The matrix square root is computed by first reducing the matrix to quasi-triangular form with the real Schur decomposition. The square root of the quasi-triangular matrix is then computed directly. Details of the algorithm can be found in: Nicholas J. Higham, "Computing real square roots of a real matrix", Linear Algebra Appl., 1987. The input is a tensor of shape [..., M, M] whose inner-most 2 dimensions form square matrices. The output is a tensor of the same shape as the input containing the matrix square root for all input submatrices [..., :, :].
 


 Args
  input   A Tensor. Must be one of the following types: float64, float32, half, complex64, complex128. Shape is [..., M, M].  
  name   A name for the operation (optional).   
 


 Returns   A Tensor. Has the same type as input.
tf.linalg.svd       View source on GitHub    Computes the singular value decompositions of one or more matrices.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.linalg.svd, tf.compat.v1.svd  
tf.linalg.svd(
    tensor, full_matrices=False, compute_uv=True, name=None
)
 Computes the SVD of each inner matrix in tensor such that tensor[..., :, :] = u[..., :, :] * diag(s[..., :, :]) * transpose(conj(v[..., :, :])) # a is a tensor.
# s is a tensor of singular values.
# u is a tensor of left singular vectors.
# v is a tensor of right singular vectors.
s, u, v = svd(a)
s = svd(a, compute_uv=False)

 


 Args
  tensor   Tensor of shape [..., M, N]. Let P be the minimum of M and N.  
  full_matrices   If true, compute full-sized u and v. If false (the default), compute only the leading P singular vectors. Ignored if compute_uv is False.  
  compute_uv   If True then left and right singular vectors will be computed and returned in u and v, respectively. Otherwise, only the singular values will be computed, which can be significantly faster.  
  name   string, optional name of the operation.   
 


 Returns
  s   Singular values. Shape is [..., P]. The values are sorted in reverse order of magnitude, so s[..., 0] is the largest value, s[..., 1] is the second largest, etc.  
  u   Left singular vectors. If full_matrices is False (default) then shape is [..., M, P]; if full_matrices is True then shape is [..., M, M]. Not returned if compute_uv is False.  
  v   Right singular vectors. If full_matrices is False (default) then shape is [..., N, P]. If full_matrices is True then shape is [..., N, N]. Not returned if compute_uv is False.    Numpy Compatibility Mostly equivalent to numpy.linalg.svd, except that  The order of output arguments here is s, u, v when compute_uv is True, as opposed to u, s, v for numpy.linalg.svd. full_matrices is False by default as opposed to True for numpy.linalg.svd. tf.linalg.svd uses the standard definition of the SVD \(A = U \Sigma V^H\), such that the left singular vectors of a are the columns of u, while the right singular vectors of a are the columns of v. On the other hand, numpy.linalg.svd returns the adjoint \(V^H\) as the third output argument.  import tensorflow as tf
import numpy as np
s, u, v = tf.linalg.svd(a)
tf_a_approx = tf.matmul(u, tf.matmul(tf.linalg.diag(s), v, adjoint_b=True))
u, s, v_adj = np.linalg.svd(a, full_matrices=False)
np_a_approx = np.dot(u, np.dot(np.diag(s), v_adj))
# tf_a_approx and np_a_approx should be numerically close.
tf.linalg.tensor_diag Returns a diagonal tensor with a given diagonal values.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.diag, tf.compat.v1.linalg.tensor_diag  
tf.linalg.tensor_diag(
    diagonal, name=None
)
 Given a diagonal, this operation returns a tensor with the diagonal and everything else padded with zeros. The diagonal is computed as follows: Assume diagonal has dimensions [D1,..., Dk], then the output is a tensor of rank 2k with dimensions [D1,..., Dk, D1,..., Dk] where: output[i1,..., ik, i1,..., ik] = diagonal[i1, ..., ik] and 0 everywhere else. For example: # 'diagonal' is [1, 2, 3, 4]
tf.diag(diagonal) ==> [[1, 0, 0, 0]
                       [0, 2, 0, 0]
                       [0, 0, 3, 0]
                       [0, 0, 0, 4]]

 


 Args
  diagonal   A Tensor. Must be one of the following types: bfloat16, half, float32, float64, int32, int64, complex64, complex128. Rank k tensor where k is at most 1.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor. Has the same type as diagonal.
tf.linalg.tensor_diag_part     View source on GitHub    Returns the diagonal part of the tensor.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.diag_part, tf.compat.v1.linalg.tensor_diag_part  
tf.linalg.tensor_diag_part(
    input, name=None
)
 This operation returns a tensor with the diagonal part of the input. The diagonal part is computed as follows: Assume input has dimensions [D1,..., Dk, D1,..., Dk], then the output is a tensor of rank k with dimensions [D1,..., Dk] where: diagonal[i1,..., ik] = input[i1, ..., ik, i1,..., ik]. For a rank 2 tensor, linalg.diag_part and linalg.tensor_diag_part produce the same result. For rank 3 and higher, linalg.diag_part extracts the diagonal of each inner-most matrix in the tensor. An example where they differ is given below. 
x = [[[[1111,1112],[1121,1122]],
      [[1211,1212],[1221,1222]]],
     [[[2111, 2112], [2121, 2122]],
      [[2211, 2212], [2221, 2222]]]
     ]
tf.linalg.tensor_diag_part(x)
<tf.Tensor: shape=(2, 2), dtype=int32, numpy=
array([[1111, 1212],
       [2121, 2222]], dtype=int32)>
tf.linalg.diag_part(x).shape
TensorShape([2, 2, 2])

 


 Args
  input   A Tensor with rank 2k.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor containing diagonals of input. Has the same type as input, and rank k.