neulab/docprompting-conala huggingface dataset:
tf.linalg.banded_triangular_solve Solve triangular systems of equations with a banded solver. 
tf.linalg.banded_triangular_solve(
    bands, rhs, lower=True, adjoint=False, name=None
)
 bands is a tensor of shape [..., K, M], where K represents the number of bands stored. This corresponds to a batch of M by M matrices, whose K subdiagonals (when lower is True) are stored. This operator broadcasts the batch dimensions of bands and the batch dimensions of rhs. Examples: Storing 2 bands of a 3x3 matrix. Note that first element in the second row is ignored due to the 'LEFT_RIGHT' padding. 
x = [[2., 3., 4.], [1., 2., 3.]]
x2 = [[2., 3., 4.], [10000., 2., 3.]]
y = tf.zeros([3, 3])
z = tf.linalg.set_diag(y, x, align='LEFT_RIGHT', k=(-1, 0))
z
<tf.Tensor: shape=(3, 3), dtype=float32, numpy=
array([[2., 0., 0.],
       [2., 3., 0.],
       [0., 3., 4.]], dtype=float32)>
soln = tf.linalg.banded_triangular_solve(x, tf.ones([3, 1]))
soln
<tf.Tensor: shape=(3, 1), dtype=float32, numpy=
array([[0.5 ],
       [0.  ],
       [0.25]], dtype=float32)>
are_equal = soln == tf.linalg.banded_triangular_solve(x2, tf.ones([3, 1]))
tf.reduce_all(are_equal).numpy()
True
are_equal = soln == tf.linalg.triangular_solve(z, tf.ones([3, 1]))
tf.reduce_all(are_equal).numpy()
True
 Storing 2 superdiagonals of a 4x4 matrix. Because of the 'LEFT_RIGHT' padding the last element of the first row is ignored. 
x = [[2., 3., 4., 5.], [-1., -2., -3., -4.]]
y = tf.zeros([4, 4])
z = tf.linalg.set_diag(y, x, align='LEFT_RIGHT', k=(0, 1))
z
<tf.Tensor: shape=(4, 4), dtype=float32, numpy=
array([[-1.,  2.,  0.,  0.],
       [ 0., -2.,  3.,  0.],
       [ 0.,  0., -3.,  4.],
       [ 0.,  0., -0., -4.]], dtype=float32)>
soln = tf.linalg.banded_triangular_solve(x, tf.ones([4, 1]), lower=False)
soln
<tf.Tensor: shape=(4, 1), dtype=float32, numpy=
array([[-4.       ],
       [-1.5      ],
       [-0.6666667],
       [-0.25     ]], dtype=float32)>
are_equal = (soln == tf.linalg.triangular_solve(
  z, tf.ones([4, 1]), lower=False))
tf.reduce_all(are_equal).numpy()
True

 


 Args
  bands   A Tensor describing the bands of the left hand side, with shape [..., K, M]. The K rows correspond to the diagonal to the K - 1-th diagonal (the diagonal is the top row) when lower is True and otherwise the K - 1-th superdiagonal to the diagonal (the diagonal is the bottom row) when lower is False. The bands are stored with 'LEFT_RIGHT' alignment, where the superdiagonals are padded on the right and subdiagonals are padded on the left. This is the alignment cuSPARSE uses. See tf.linalg.set_diag for more details.  
  rhs   A Tensor of shape [..., M] or [..., M, N] and with the same dtype as diagonals. Note that if the shape of rhs and/or diags isn't known statically, rhs will be treated as a matrix rather than a vector.  
  lower   An optional bool. Defaults to True. Boolean indicating whether bands represents a lower or upper triangular matrix.  
  adjoint   An optional bool. Defaults to False. Boolean indicating whether to solve with the matrix's block-wise adjoint.  
  name   A name to give this Op (optional).   
 


 Returns   A Tensor of shape [..., M] or [..., M, N] containing the solutions.
tf.linalg.band_part Copy a tensor setting everything outside a central band in each innermost matrix to zero.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.linalg.band_part, tf.compat.v1.matrix_band_part  
tf.linalg.band_part(
    input, num_lower, num_upper, name=None
)
 The band part is computed as follows: Assume input has k dimensions [I, J, K, ..., M, N], then the output is a tensor with the same shape where band[i, j, k, ..., m, n] = in_band(m, n) * input[i, j, k, ..., m, n]. The indicator function in_band(m, n) = (num_lower < 0 || (m-n) <= num_lower)) && (num_upper < 0 || (n-m) <= num_upper). For example: # if 'input' is [[ 0,  1,  2, 3]
                 [-1,  0,  1, 2]
                 [-2, -1,  0, 1]
                 [-3, -2, -1, 0]],

tf.matrix_band_part(input, 1, -1) ==> [[ 0,  1,  2, 3]
                                       [-1,  0,  1, 2]
                                       [ 0, -1,  0, 1]
                                       [ 0,  0, -1, 0]],

tf.matrix_band_part(input, 2, 1) ==> [[ 0,  1,  0, 0]
                                      [-1,  0,  1, 0]
                                      [-2, -1,  0, 1]
                                      [ 0, -2, -1, 0]]
 Useful special cases: tf.matrix_band_part(input, 0, -1) ==> Upper triangular part.
tf.matrix_band_part(input, -1, 0) ==> Lower triangular part.
tf.matrix_band_part(input, 0, 0) ==> Diagonal.

 


 Args
  input   A Tensor. Rank k tensor.  
  num_lower   A Tensor. Must be one of the following types: int32, int64. 0-D tensor. Number of subdiagonals to keep. If negative, keep entire lower triangle.  
  num_upper   A Tensor. Must have the same type as num_lower. 0-D tensor. Number of superdiagonals to keep. If negative, keep entire upper triangle.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor. Has the same type as input.
tf.linalg.cholesky Computes the Cholesky decomposition of one or more square matrices.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.cholesky, tf.compat.v1.linalg.cholesky  
tf.linalg.cholesky(
    input, name=None
)
 The input is a tensor of shape [..., M, M] whose inner-most 2 dimensions form square matrices. The input has to be symmetric and positive definite. Only the lower-triangular part of the input will be used for this operation. The upper-triangular part will not be read. The output is a tensor of the same shape as the input containing the Cholesky decompositions for all input submatrices [..., :, :]. 
Note: The gradient computation on GPU is faster for large matrices but not for large batch dimensions when the submatrices are small. In this case it might be faster to use the CPU.

 


 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.cholesky_solve     View source on GitHub    Solves systems of linear eqns A X = RHS, given Cholesky factorizations.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.cholesky_solve, tf.compat.v1.linalg.cholesky_solve  
tf.linalg.cholesky_solve(
    chol, rhs, name=None
)
 Specifically, returns X from A X = RHS, where A = L L^T, L is the chol arg and RHS is the rhs arg. # Solve 10 separate 2x2 linear systems:
A = ... # shape 10 x 2 x 2
RHS = ... # shape 10 x 2 x 1
chol = tf.linalg.cholesky(A)  # shape 10 x 2 x 2
X = tf.linalg.cholesky_solve(chol, RHS)  # shape 10 x 2 x 1
# tf.matmul(A, X) ~ RHS
X[3, :, 0]  # Solution to the linear system A[3, :, :] x = RHS[3, :, 0]

# Solve five linear systems (K = 5) for every member of the length 10 batch.
A = ... # shape 10 x 2 x 2
RHS = ... # shape 10 x 2 x 5
...
X[3, :, 2]  # Solution to the linear system A[3, :, :] x = RHS[3, :, 2]

 


 Args
  chol   A Tensor. Must be float32 or float64, shape is [..., M, M]. Cholesky factorization of A, e.g. chol = tf.linalg.cholesky(A). For that reason, only the lower triangular parts (including the diagonal) of the last two dimensions of chol are used. The strictly upper part is assumed to be zero and not accessed.  
  rhs   A Tensor, same type as chol, shape is [..., M, K].  
  name   A name to give this Op. Defaults to cholesky_solve.   
 


 Returns   Solution to A x = rhs, shape [..., M, K].
tf.linalg.cross Compute the pairwise cross product.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.cross, tf.compat.v1.linalg.cross  
tf.linalg.cross(
    a, b, name=None
)
 a and b must be the same shape; they can either be simple 3-element vectors, or any shape where the innermost dimension is 3. In the latter case, each pair of corresponding 3-element vectors is cross-multiplied independently.
 


 Args
  a   A Tensor. Must be one of the following types: float32, float64, int32, uint8, int16, int8, int64, bfloat16, uint16, half, uint32, uint64. A tensor containing 3-element vectors.  
  b   A Tensor. Must have the same type as a. Another tensor, of same type and shape as a.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor. Has the same type as a.
tf.linalg.det Computes the determinant of one or more square matrices.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.linalg.det, tf.compat.v1.matrix_determinant  
tf.linalg.det(
    input, name=None
)
 The input is a tensor of shape [..., M, M] whose inner-most 2 dimensions form square matrices. The output is a tensor containing the determinants for all input submatrices [..., :, :].
 


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


 Returns   A Tensor. Has the same type as input.
tf.linalg.eig Computes the eigen decomposition of a batch of matrices.  View aliases  Main aliases 
tf.eig  
tf.linalg.eig(
    tensor, name=None
)
 The eigenvalues and eigenvectors for a non-Hermitian matrix in general are complex. The eigenvectors are not guaranteed to be linearly independent. Computes the eigenvalues and right eigenvectors of the innermost N-by-N matrices in tensor such that tensor[...,:,:] * v[..., :,i] = e[..., i] * v[...,:,i], for i=0...N-1.
 


 Args
  tensor   Tensor of shape [..., N, N]. Only the lower triangular part of each inner inner matrix is referenced.  
  name   string, optional name of the operation.   
 


 Returns
  e   Eigenvalues. Shape is [..., N]. Sorted in non-decreasing order.  
  v   Eigenvectors. Shape is [..., N, N]. The columns of the inner most matrices contain eigenvectors of the corresponding matrices in tensor
tf.linalg.eigh     View source on GitHub    Computes the eigen decomposition of a batch of self-adjoint matrices.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.linalg.eigh, tf.compat.v1.self_adjoint_eig  
tf.linalg.eigh(
    tensor, name=None
)
 Computes the eigenvalues and eigenvectors of the innermost N-by-N matrices in tensor such that tensor[...,:,:] * v[..., :,i] = e[..., i] * v[...,:,i], for i=0...N-1.
 


 Args
  tensor   Tensor of shape [..., N, N]. Only the lower triangular part of each inner inner matrix is referenced.  
  name   string, optional name of the operation.   
 


 Returns
  e   Eigenvalues. Shape is [..., N]. Sorted in non-decreasing order.  
  v   Eigenvectors. Shape is [..., N, N]. The columns of the inner most matrices contain eigenvectors of the corresponding matrices in tensor
tf.linalg.eigvals Computes the eigenvalues of one or more matrices.  View aliases  Main aliases 
tf.eigvals  
tf.linalg.eigvals(
    tensor, name=None
)
 
Note: If your program backpropagates through this function, you should replace it with a call to tf.linalg.eig (possibly ignoring the second output) to avoid computing the eigen decomposition twice. This is because the eigenvectors are used to compute the gradient w.r.t. the eigenvalues. See _SelfAdjointEigV2Grad in linalg_grad.py.

 


 Args
  tensor   Tensor of shape [..., N, N].  
  name   string, optional name of the operation.   
 


 Returns
  e   Eigenvalues. Shape is [..., N]. The vector e[..., :] contains the N eigenvalues of tensor[..., :, :].
tf.linalg.eigvalsh     View source on GitHub    Computes the eigenvalues of one or more self-adjoint matrices.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.linalg.eigvalsh, tf.compat.v1.self_adjoint_eigvals  
tf.linalg.eigvalsh(
    tensor, name=None
)
 
Note: If your program backpropagates through this function, you should replace it with a call to tf.linalg.eigh (possibly ignoring the second output) to avoid computing the eigen decomposition twice. This is because the eigenvectors are used to compute the gradient w.r.t. the eigenvalues. See _SelfAdjointEigV2Grad in linalg_grad.py.

 


 Args
  tensor   Tensor of shape [..., N, N].  
  name   string, optional name of the operation.   
 


 Returns
  e   Eigenvalues. Shape is [..., N]. The vector e[..., :] contains the N eigenvalues of tensor[..., :, :].
Module: tf.linalg.experimental Public API for tf.linalg.experimental namespace. Functions conjugate_gradient(...): Conjugate gradient solver.
tf.linalg.experimental.conjugate_gradient   Conjugate gradient solver.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.linalg.experimental.conjugate_gradient  
tf.linalg.experimental.conjugate_gradient(
    operator, rhs, preconditioner=None, x=None, tol=1e-05, max_iter=20,
    name='conjugate_gradient'
)
 Solves a linear system of equations A*x = rhs for self-adjoint, positive definite matrix A and right-hand side vector rhs, using an iterative, matrix-free algorithm where the action of the matrix A is represented by operator. The iteration terminates when either the number of iterations exceeds max_iter or when the residual norm has been reduced to tol times its initial value, i.e. \(||rhs - A x_k|| <= tol ||rhs||\).
 


 Args
  operator   A LinearOperator that is self-adjoint and positive definite.  
  rhs   A possibly batched vector of shape [..., N] containing the right-hand size vector.  
  preconditioner   A LinearOperator that approximates the inverse of A. An efficient preconditioner could dramatically improve the rate of convergence. If preconditioner represents matrix M(M approximates A^{-1}), the algorithm uses preconditioner.apply(x) to estimate A^{-1}x. For this to be useful, the cost of applying M should be much lower than computing A^{-1} directly.  
  x   A possibly batched vector of shape [..., N] containing the initial guess for the solution.  
  tol   A float scalar convergence tolerance.  
  max_iter   An integer giving the maximum number of iterations.  
  name   A name scope for the operation.   
 


 Returns
  output   A namedtuple representing the final state with fields:  i: A scalar int32 Tensor. Number of iterations executed. x: A rank-1 Tensor of shape [..., N] containing the computed solution. r: A rank-1 Tensor of shape [.., M] containing the residual vector. p: A rank-1 Tensor of shape [..., N]. A-conjugate basis vector. gamma: \(r \dot M \dot r\), equivalent to \(||r||_2^2\) when preconditioner=None.
tf.linalg.expm       View source on GitHub    Computes the matrix exponential of one or more square matrices.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.linalg.expm  
tf.linalg.expm(
    input, name=None
)
  $$exp(A) = \sum_{n=0}^\infty A^n/n!$$  The exponential is computed using a combination of the scaling and squaring method and the Pade approximation. Details can be found in: Nicholas J. Higham, "The scaling and squaring method for the matrix exponential revisited," SIAM J. Matrix Anal. Applic., 26:1179-1193, 2005. 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 exponential for all input submatrices [..., :, :].
 


 Args
  input   A Tensor. Must be float16, float32, float64, complex64, or complex128 with shape [..., M, M].  
  name   A name to give this Op (optional).   
 


 Returns   the matrix exponential of the input.  

 


 Raises
  ValueError   An unsupported type is provided as input.    Scipy Compatibility Equivalent to scipy.linalg.expm
tf.linalg.global_norm     View source on GitHub    Computes the global norm of multiple tensors.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.global_norm, tf.compat.v1.linalg.global_norm  
tf.linalg.global_norm(
    t_list, name=None
)
 Given a tuple or list of tensors t_list, this operation returns the global norm of the elements in all tensors in t_list. The global norm is computed as: global_norm = sqrt(sum([l2norm(t)**2 for t in t_list])) Any entries in t_list that are of type None are ignored.
 


 Args
  t_list   A tuple or list of mixed Tensors, IndexedSlices, or None.  
  name   A name for the operation (optional).   
 


 Returns   A 0-D (scalar) Tensor of type float.  

 


 Raises
  TypeError   If t_list is not a sequence.
tf.linalg.inv Computes the inverse of one or more square invertible matrices or their adjoints (conjugate transposes).  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.linalg.inv, tf.compat.v1.matrix_inverse  
tf.linalg.inv(
    input, adjoint=False, name=None
)
 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 inverse for all input submatrices [..., :, :]. The op uses LU decomposition with partial pivoting to compute the inverses. If a matrix is not invertible there is no guarantee what the op does. It may detect the condition and raise an exception or it may simply return a garbage result.
 


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


 Returns   A Tensor. Has the same type as input.
tf.linalg.logdet     View source on GitHub    Computes log of the determinant of a hermitian positive definite matrix.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.linalg.logdet  
tf.linalg.logdet(
    matrix, name=None
)
 # Compute the determinant of a matrix while reducing the chance of over- or
underflow:
A = ... # shape 10 x 10
det = tf.exp(tf.linalg.logdet(A))  # scalar

 


 Args
  matrix   A Tensor. Must be float16, float32, float64, complex64, or complex128 with shape [..., M, M].  
  name   A name to give this Op. Defaults to logdet.   
 


 Returns   The natural log of the determinant of matrix.  
 Numpy Compatibility Equivalent to numpy.linalg.slogdet, although no sign is returned since only hermitian positive definite matrices are supported.
tf.linalg.logm   Computes the matrix logarithm of one or more square matrices:  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.linalg.logm  
tf.linalg.logm(
    input, name=None
)
 \(log(exp(A)) = A\) This op is only defined for complex matrices. If A is positive-definite and real, then casting to a complex matrix, taking the logarithm and casting back to a real matrix will give the correct result. This function computes the matrix logarithm using the Schur-Parlett algorithm. Details of the algorithm can be found in Section 11.6.2 of: Nicholas J. Higham, Functions of Matrices: Theory and Computation, SIAM 2008. ISBN 978-0-898716-46-7. 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 exponential for all input submatrices [..., :, :].
 


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


 Returns   A Tensor. Has the same type as input.
tf.linalg.lstsq       View source on GitHub    Solves one or more linear least-squares problems.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.linalg.lstsq, tf.compat.v1.matrix_solve_ls  
tf.linalg.lstsq(
    matrix, rhs, l2_regularizer=0.0, fast=True, name=None
)
 matrix is a tensor of shape [..., M, N] whose inner-most 2 dimensions form M-by-N matrices. Rhs is a tensor of shape [..., M, K] whose inner-most 2 dimensions form M-by-K matrices. The computed output is a Tensor of shape [..., N, K] whose inner-most 2 dimensions form M-by-K matrices that solve the equations matrix[..., :, :] * output[..., :, :] = rhs[..., :, :] in the least squares sense. Below we will use the following notation for each pair of matrix and right-hand sides in the batch: matrix=\(A \in \Re^{m \times n}\), rhs=\(B \in \Re^{m \times k}\), output=\(X \in \Re^{n \times k}\), l2_regularizer=\(\lambda\). If fast is True, then the solution is computed by solving the normal equations using Cholesky decomposition. Specifically, if \(m \ge n\) then \(X = (A^T A + \lambda I)^{-1} A^T B\), which solves the least-squares problem \(X = \mathrm{argmin}_{Z \in \Re^{n \times k} } ||A Z - B||_F^2 + \lambda ||Z||_F^2\). If \(m \lt n\) then output is computed as \(X = A^T (A A^T + \lambda I)^{-1} B\), which (for \(\lambda = 0\)) is the minimum-norm solution to the under-determined linear system, i.e. \(X = \mathrm{argmin}_{Z \in \Re^{n \times k} } ||Z||_F^2 \), subject to \(A Z = B\). Notice that the fast path is only numerically stable when \(A\) is numerically full rank and has a condition number \(\mathrm{cond}(A) \lt \frac{1}{\sqrt{\epsilon_{mach} } }\) or\(\lambda\) is sufficiently large. If fast is False an algorithm based on the numerically robust complete orthogonal decomposition is used. This computes the minimum-norm least-squares solution, even when \(A\) is rank deficient. This path is typically 6-7 times slower than the fast path. If fast is False then l2_regularizer is ignored.
 


 Args
  matrix   Tensor of shape [..., M, N].  
  rhs   Tensor of shape [..., M, K].  
  l2_regularizer   0-D double Tensor. Ignored if fast=False.  
  fast   bool. Defaults to True.  
  name   string, optional name of the operation.   
 


 Returns
  output   Tensor of shape [..., N, K] whose inner-most 2 dimensions form M-by-K matrices that solve the equations matrix[..., :, :] * output[..., :, :] = rhs[..., :, :] in the least squares sense.   
 


 Raises
  NotImplementedError   linalg.lstsq is currently disabled for complex128 and l2_regularizer != 0 due to poor accuracy.
tf.linalg.lu Computes the LU decomposition of one or more square matrices.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.linalg.lu  
tf.linalg.lu(
    input, output_idx_type=tf.dtypes.int32, name=None
)
 The input is a tensor of shape [..., M, M] whose inner-most 2 dimensions form square matrices. The input has to be invertible. The output consists of two tensors LU and P containing the LU decomposition of all input submatrices [..., :, :]. LU encodes the lower triangular and upper triangular factors. For each input submatrix of shape [M, M], L is a lower triangular matrix of shape [M, M] with unit diagonal whose entries correspond to the strictly lower triangular part of LU. U is a upper triangular matrix of shape [M, M] whose entries correspond to the upper triangular part, including the diagonal, of LU. P represents a permutation matrix encoded as a list of indices each between 0 and M-1, inclusive. If P_mat denotes the permutation matrix corresponding to P, then the L, U and P satisfies P_mat * input = L * U.
 


 Args
  input   A Tensor. Must be one of the following types: float64, float32, half, complex64, complex128. A tensor of shape [..., M, M] whose inner-most 2 dimensions form matrices of size [M, M].  
  output_idx_type   An optional tf.DType from: tf.int32, tf.int64. Defaults to tf.int32.  
  name   A name for the operation (optional).   
 


 Returns   A tuple of Tensor objects (lu, p).     lu   A Tensor. Has the same type as input.  
  p   A Tensor of type output_idx_type.