-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Haskell wrappers for Core Tensorflow Ops. -- -- Code generated signatures for the Ops in libtensorflow_c. @package tensorflow-core-ops @version 0.1.0.0 module TensorFlow.GenOps.Core -- | Receives the named tensor from send_device on recv_device. -- -- _HostRecv requires its input on host memory whereas _Recv requires its -- input on device memory. _HostRecv :: (TensorType tensor_type) => Int64 -> Tensor Value tensor_type -- | Receives the named tensor from send_device on recv_device. _Recv :: (TensorType tensor_type) => Int64 -> Tensor Value tensor_type -- | Sends the named tensor from send_device to recv_device. _Send :: (TensorType t) => Int64 -> Tensor v1 t -> ControlNode -- | A graph node which represents an argument to a function. _Arg :: (TensorType t) => Int64 -> Tensor Value t -- | Update '*var' according to the RMSProp algorithm. -- -- Note that in dense implement of this algorithm, ms and mom will update -- even if the grad is zero, but in this sparse implement, ms and mom -- will not update in iterations the grad is zero. -- -- mean_square = decay * mean_square + (1-decay) * gradient ** 2 Delta = -- learning_rate * gradient / sqrt(mean_square + epsilon) -- -- ms <- rho * ms_{t-1} + (1-rho) * grad * grad mom <- momentum * -- mom_{t-1} + lr * grad / sqrt(ms + epsilon) var <- var - mom sparseApplyRMSProp :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t, TensorType tindices, OneOf '[Int32, Int64] tindices) => Tensor v1 t -> Tensor v2 t -> Tensor v3 t -> Tensor v4 t -> Tensor v5 t -> Tensor v6 t -> Tensor v7 t -> Tensor v8 t -> Tensor v9 tindices -> Tensor Value t -- | Update '*var' according to the Adam algorithm. -- -- lr_t <- learning_rate * sqrt(1 - beta2^t) / (1 - beta1^t) m_t <- -- beta1 * m_{t-1} + (1 - beta1) * g_t v_t <- beta2 * v_{t-1} + (1 - -- beta2) * g_t * g_t variable <- variable - lr_t * m_t / (sqrt(v_t) + -- epsilon) applyAdam :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor v3 t -> Tensor v4 t -> Tensor v5 t -> Tensor v6 t -> Tensor v7 t -> Tensor v8 t -> Tensor v9 t -> Tensor v10 t -> Tensor Value t -- | Update relevant entries in '*var' and '*accum' according to the -- momentum scheme. -- -- Set use_nesterov = True if you want to use Nesterov momentum. -- -- That is for rows we have grad for, we update var and accum as follows: -- -- accum = accum * momentum + grad var -= lr * accum sparseApplyMomentum :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t, TensorType tindices, OneOf '[Int32, Int64] tindices) => Tensor v1 t -> Tensor v2 t -> Tensor v3 t -> Tensor v4 t -> Tensor v5 tindices -> Tensor v6 t -> Tensor Value t -- | Update '*var' according to the momentum scheme. Set use_nesterov = -- True if you -- -- want to use Nesterov momentum. -- -- accum = accum * momentum + grad var -= lr * accum applyMomentum :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor v3 t -> Tensor v4 t -> Tensor v5 t -> Tensor Value t -- | Update '*var' according to the Ftrl-proximal scheme. -- -- accum_new = accum + grad * grad linear += grad + -- (accum_new^(-lr_power) - accum^(-lr_power)) / lr * var quadratic = 1.0 -- / (accum_new^(lr_power) * lr) + 2 * l2 var = (sign(linear) * l1 - -- linear) / quadratic if |linear| > l1 else 0.0 accum = accum_new applyFtrl :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor v3 t -> Tensor v4 t -> Tensor v5 t -> Tensor v6 t -> Tensor v7 t -> Tensor v8 t -> Tensor Value t -- | Update entries in '*var' and '*accum' according to the proximal -- adagrad scheme. sparseApplyAdagradDA :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t, TensorType tindices, OneOf '[Int32, Int64] tindices) => Tensor v1 t -> Tensor v2 t -> Tensor v3 t -> Tensor v4 t -> Tensor v5 tindices -> Tensor v6 t -> Tensor v7 t -> Tensor v8 t -> Tensor v9 Int64 -> Tensor Value t -- | Update relevant entries in '*var' and '*accum' according to the -- adagrad scheme. -- -- That is for rows we have grad for, we update var and accum as follows: -- accum += grad * grad var -= lr * grad * (1 / sqrt(accum)) sparseApplyAdagrad :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t, TensorType tindices, OneOf '[Int32, Int64] tindices) => Tensor v1 t -> Tensor v2 t -> Tensor v3 t -> Tensor v4 t -> Tensor v5 tindices -> Tensor Value t -- | Update '*var' and '*accum' according to FOBOS with Adagrad learning -- rate. -- -- accum += grad * grad prox_v = var - lr * grad * (1 / sqrt(accum)) var -- = sign(prox_v)/(1+lr*l2) * max{|prox_v|-lr*l1,0} applyProximalAdagrad :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor v3 t -> Tensor v4 t -> Tensor v5 t -> Tensor v6 t -> Tensor Value t -- | Update '*var' according to the adagrad scheme. -- -- accum += grad * grad var -= lr * grad * (1 / sqrt(accum)) applyAdagrad :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor v3 t -> Tensor v4 t -> Tensor Value t -- | Update '*var' according to the adadelta scheme. -- -- accum = rho() * accum + (1 - rho()) * grad.square(); update = -- (update_accum + epsilon).sqrt() * (accum + epsilon()).rsqrt() * grad; -- update_accum = rho() * update_accum + (1 - rho()) * update.square(); -- var -= update; applyAdadelta :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor v3 t -> Tensor v4 t -> Tensor v5 t -> Tensor v6 t -> Tensor v7 t -> Tensor Value t -- | Sparse update '*var' as FOBOS algorithm with fixed learning rate. -- -- That is for rows we have grad for, we update var as follows: prox_v = -- var - alpha * grad var = sign(prox_v)/(1+alpha*l2) * -- max{|prox_v|-alpha*l1,0} sparseApplyProximalGradientDescent :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t, TensorType tindices, OneOf '[Int32, Int64] tindices) => Tensor v1 t -> Tensor v2 t -> Tensor v3 t -> Tensor v4 t -> Tensor v5 t -> Tensor v6 tindices -> Tensor Value t -- | Update '*var' as FOBOS algorithm with fixed learning rate. -- -- prox_v = var - alpha * delta var = sign(prox_v)/(1+alpha*l2) * -- max{|prox_v|-alpha*l1,0} applyProximalGradientDescent :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor v3 t -> Tensor v4 t -> Tensor v5 t -> Tensor Value t -- | Encode strings into web-safe base64 format. -- -- Refer to the following article for more information on base64 format: -- en.wikipedia.orgwikiBase64. Base64 strings may have padding -- with '=' at the end so that the encoded has length multiple of 4. See -- Padding section of the link above. -- -- Web-safe means that the encoder uses - and _ instead of + and /. encodeBase64 :: Tensor v1 ByteString -> Tensor Value ByteString -- | Split elements of input based on delimiter into a -- SparseTensor. -- -- Let N be the size of source (typically N will be the batch size). -- Split each element of input based on delimiter and -- return a SparseTensor containing the splitted tokens. Empty -- tokens are ignored. -- -- delimiter can be empty or a single character. If -- delimiter is an empty string, each element of input -- is split into individual 1 character strings. -- -- For example: N = 2, input[0] is 'hello world' and input[1] is 'a b c', -- then the output will be -- -- indices = [0, 0; 0, 1; 1, 0; 1, 1; 1, 2] shape = [2, 3] values = -- [hello, world, a, b, c] stringSplit :: Tensor v1 ByteString -> Tensor v2 ByteString -> (Tensor Value Int64, Tensor Value ByteString, Tensor Value Int64) -- | Joins the strings in the given list of string tensors into one tensor; -- -- with the given separator (default is an empty separator). stringJoin :: [Tensor v1 ByteString] -> Tensor Value ByteString -- | Converts each entry in the given tensor to strings. Supports many -- numeric -- -- types and boolean. asString :: (TensorType t, OneOf '[Complex Float, Bool, Int32, Int64, Int8, Double, Float] t) => Tensor v1 t -> Tensor Value ByteString -- | Converts each string in the input Tensor to its hash mod by a number -- of buckets. -- -- The hash function is deterministic on the content of the string within -- the process. The hash function is a keyed hash function, where -- attribute key defines the key of the hash function. -- key is an array of 2 elements. -- -- A strong hash is important when inputs may be malicious, e.g. URLs -- with additional components. Adversaries could try to make their inputs -- hash to the same bucket for a denial-of-service attack or to skew the -- results. A strong hash prevents this by making it dificult, if not -- infeasible, to compute inputs that hash to the same bucket. This comes -- at a cost of roughly 4x higher compute time than -- tf.string_to_hash_bucket_fast. stringToHashBucketStrong :: Int64 -> Tensor v1 ByteString -> Tensor Value Int64 -- | Multiplies sparse updates into a variable reference. -- -- This operation computes -- -- # Scalar indices ref[indices, ...] *= updates[...] -- -- # Vector indices (for each i) ref[indices[i], ...] *= updates[i, ...] -- -- # High rank indices (for each i, ..., j) ref[indices[i, ..., j], ...] -- *= updates[i, ..., j, ...] -- -- This operation outputs ref after the update is done. This -- makes it easier to chain operations that need to use the reset value. -- -- Duplicate entries are handled correctly: if multiple indices -- reference the same location, their contributions multiply. -- -- Requires `updates.shape = indices.shape + ref.shape[1:]`. scatterMul :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t, TensorType tindices, OneOf '[Int32, Int64] tindices) => Tensor v1 t -> Tensor v2 tindices -> Tensor v3 t -> Tensor Value t -- | Joins a string Tensor across the given dimensions. -- -- Computes the string join across dimensions in the given string Tensor -- of shape `[d_0, d_1, ..., d_n-1]`. Returns a new Tensor created by -- joining the input strings with the given separator (default: empty -- string). Negative indices are counted backwards from the end, with -- `-1` being equivalent to `n - 1`. Passing an empty -- reduction_indices joins all strings in linear index order and -- outputs a scalar string. -- -- For example: -- -- ``` # tensor a is [["a", "b"], ["c", "d"]] tf.reduce_join(a, -- 0) ==> ["ac", "bd"] tf.reduce_join(a, 1) ==> ["ab", "cd"] -- tf.reduce_join(a, -2) = tf.reduce_join(a, 0) ==> ["ac", "bd"] -- tf.reduce_join(a, -1) = tf.reduce_join(a, 1) ==> ["ab", "cd"] -- tf.reduce_join(a, 0, keep_dims=True) ==> [["ac", "bd"]] -- tf.reduce_join(a, 1, keep_dims=True) ==> [["ab"], ["cd"]] -- tf.reduce_join(a, 0, separator=".") ==> ["a.c", "b.d"] -- tf.reduce_join(a, [0, 1]) ==> ["acbd"] tf.reduce_join(a, [1, 0]) -- ==> ["abcd"] tf.reduce_join(a, []) ==> ["abcd"] ``` reduceJoin :: Tensor v1 ByteString -> Tensor v2 Int32 -> Tensor Value ByteString -- | Subtracts sparse updates to a variable reference. -- -- # Scalar indices ref[indices, ...] -= updates[...] -- -- # Vector indices (for each i) ref[indices[i], ...] -= updates[i, ...] -- -- # High rank indices (for each i, ..., j) ref[indices[i, ..., j], ...] -- -= updates[i, ..., j, ...] -- -- This operation outputs ref after the update is done. This -- makes it easier to chain operations that need to use the reset value. -- -- Duplicate entries are handled correctly: if multiple indices -- reference the same location, their (negated) contributions add. -- -- Requires `updates.shape = indices.shape + ref.shape[1:]`. -- -- style="width:70%; margin:auto; margin-bottom:10px; -- margin-top:20px;" style="width:100%" -- src="../../images/ScatterSub.png" alt /div scatterSub :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t, TensorType tindices, OneOf '[Int32, Int64] tindices) => Tensor v1 t -> Tensor v2 tindices -> Tensor v3 t -> Tensor Value t -- | Adds sparse updates to a variable reference. -- -- This operation computes -- -- # Scalar indices ref[indices, ...] += updates[...] -- -- # Vector indices (for each i) ref[indices[i], ...] += updates[i, ...] -- -- # High rank indices (for each i, ..., j) ref[indices[i, ..., j], ...] -- += updates[i, ..., j, ...] -- -- This operation outputs ref after the update is done. This -- makes it easier to chain operations that need to use the reset value. -- -- Duplicate entries are handled correctly: if multiple indices -- reference the same location, their contributions add. -- -- Requires `updates.shape = indices.shape + ref.shape[1:]`. -- -- style="width:70%; margin:auto; margin-bottom:10px; -- margin-top:20px;" style="width:100%" -- src="../../images/ScatterAdd.png" alt /div scatterAdd :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t, TensorType tindices, OneOf '[Int32, Int64] tindices) => Tensor v1 t -> Tensor v2 tindices -> Tensor v3 t -> Tensor Value t -- | Applies sparse updates to a variable reference. -- -- This operation computes -- -- # Scalar indices ref[indices, ...] = updates[...] -- -- # Vector indices (for each i) ref[indices[i], ...] = updates[i, ...] -- -- # High rank indices (for each i, ..., j) ref[indices[i, ..., j], ...] -- = updates[i, ..., j, ...] -- -- This operation outputs ref after the update is done. This -- makes it easier to chain operations that need to use the reset value. -- -- If values in ref is to be updated more than once, because -- there are duplicate entires in indices, the order at which -- the updates happen for each value is undefined. -- -- Requires `updates.shape = indices.shape + ref.shape[1:]`. -- -- style="width:70%; margin:auto; margin-bottom:10px; -- margin-top:20px;" style="width:100%" -- src="../../images/ScatterUpdate.png" alt /div scatterUpdate :: (TensorType t, TensorType tindices, OneOf '[Int32, Int64] tindices) => Tensor v1 t -> Tensor v2 tindices -> Tensor v3 t -> Tensor Value t -- | Update ref by subtracting value from it. -- -- This operation outputs "ref" after the update is done. This makes it -- easier to chain operations that need to use the reset value. assignSub :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Update ref by adding value to it. -- -- This operation outputs "ref" after the update is done. This makes it -- easier to chain operations that need to use the reset value. assignAdd :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Computes gradients for SparseSegmentMean. -- -- Returns tensor "output" with same shape as grad, except for dimension -- 0 whose value is output_dim0. sparseSegmentMeanGrad :: (TensorType t, OneOf '[Double, Float] t, TensorType tidx, OneOf '[Int32, Int64] tidx) => Tensor v1 t -> Tensor v2 tidx -> Tensor v3 Int32 -> Tensor v4 Int32 -> Tensor Value t -- | Applies softmax to a batched N-D SparseTensor. -- -- The inputs represent an N-D SparseTensor with logical shape `[..., B, -- C]` (where `N >= 2`), and with indices sorted in the canonical -- lexicographic order. -- -- This op is equivalent to applying the normal `tf.nn.softmax()` to each -- innermost logical submatrix with shape `[B, C]`, but with the catch -- that *the implicitly zero elements do not participate*. Specifically, -- the algorithm is equivalent to the following: -- --
    --
  1. Applies `tf.nn.softmax()` to a densified view of each innermost -- submatrix with shape `[B, C]`, along the size-C dimension;
  2. --
  3. Masks out the original implicitly-zero locations;
  4. --
  5. Renormalizes the remaining elements.
  6. --
-- -- Hence, the SparseTensor result has exactly the same non-zero -- indices and shape. sparseSoftmax :: (TensorType t, OneOf '[Double, Float] t) => Tensor v1 Int64 -> Tensor v2 t -> Tensor v3 Int64 -> Tensor Value t -- | Solves systems of linear equations. -- -- 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[..., :, :]`. matrixSolve :: (TensorType t, OneOf '[Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Computes the eigen decomposition of one or more square self-adjoint -- matrices. -- -- Computes the eigenvalues and (optionally) eigenvectors of each inner -- matrix in input such that `input[..., :, :] = v[..., :, :] * -- diag(e[..., :])`. -- -- ```prettyprint # a is a tensor. # e is a tensor of eigenvalues. # v is -- a tensor of eigenvectors. e, v = self_adjoint_eig(a) e = -- self_adjoint_eig(a, compute_v=False) ``` selfAdjointEigV2 :: (TensorType t, OneOf '[Double, Float] t) => Tensor v1 t -> (Tensor Value t, Tensor Value t) -- | Computes the Eigen Decomposition of a batch of square self-adjoint -- matrices. -- -- The input is a tensor of shape `[..., M, M]` whose inner-most 2 -- dimensions form square matrices, with the same constraints as the -- single matrix SelfAdjointEig. -- -- The result is a [..., M+1, M] matrix with [..., 0,:] containing the -- eigenvalues, and subsequent [...,1:, :] containing the eigenvectors. selfAdjointEig :: (TensorType t, OneOf '[Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Update '*var' by subtracting alpha * delta from it. applyGradientDescent :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor v3 t -> Tensor Value t -- | Push an element onto the stack. stackPush :: (TensorType t) => Tensor v1 ByteString -> Tensor v2 t -> Tensor Value t -- | Computes the Cholesky decomposition of one or more square matrices. -- -- The input is a tensor of shape `[..., M, M]` whose inner-most 2 -- dimensions form square matrices, with the same constraints as the -- single matrix Cholesky decomposition above. The output is a tensor of -- the same shape as the input containing the Cholesky decompositions for -- all input submatrices `[..., :, :]`. cholesky :: (TensorType t, OneOf '[Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Interleave the values from the `data` tensors into a single tensor. -- -- Builds a merged tensor such that -- -- merged[indices[m][i, ..., j], ...] = data[m][i, ..., j, ...] -- -- For example, if each `indices[m]` is scalar or vector, we have -- -- # Scalar indices merged[indices[m], ...] = data[m][...] -- -- # Vector indices merged[indices[m][i], ...] = data[m][i, ...] -- -- Each `data[i].shape` must start with the corresponding -- `indices[i].shape`, and the rest of `data[i].shape` must be constant -- w.r.t. i. That is, we must have `data[i].shape = -- indices[i].shape + constant`. In terms of this constant, the -- output shape is -- -- merged.shape = [max(indices)] + constant -- -- Values are merged in order, so if an index appears in both -- `indices[m][i]` and `indices[n][j]` for `(m,i) < (n,j)` the slice -- `data[n][j]` will appear in the merged result. -- -- For example: -- -- indices[0] = 6 indices[1] = [4, 1] indices[2] = [[5, 2], [0, 3]] -- data[0] = [61, 62] data[1] = [[41, 42], [11, 12]] data[2] = [[[51, -- 52], [21, 22]], [[1, 2], [31, 32]]] merged = [[1, 2], [11, 12], [21, -- 22], [31, 32], [41, 42], [51, 52], [61, 62]] -- -- style="width:70%; margin:auto; margin-bottom:10px; -- margin-top:20px;" style="width:100%" -- src="../../images/DynamicStitch.png" alt /div dynamicStitch :: (TensorType t) => [Tensor v1 Int32] -> [Tensor v2 t] -> Tensor Value t -- | Returns the number of work units this Reader has finished processing. readerNumWorkUnitsCompleted :: Tensor v1 ByteString -> Tensor Value Int64 -- | Returns the next record (key, value pair) produced by a Reader. -- -- Will dequeue from the input queue if necessary (e.g. when the Reader -- needs to start reading from a new file since it has finished with the -- previous file). readerRead :: Tensor v1 ByteString -> Tensor v2 ByteString -> (Tensor Value ByteString, Tensor Value ByteString) -- | Compute the 2-dimensional discrete Fourier Transform over the -- inner-most -- -- 2 dimensions of input. fFT2D :: Tensor v1 (Complex Float) -> Tensor Value (Complex Float) -- | A Reader that outputs fixed-length records from a file. fixedLengthRecordReader :: Int64 -> Tensor Value ByteString -- | A placeholder op for a value that will be fed into the computation. -- -- N.B. This operation will fail with an error if it is executed. It is -- intended as a way to represent a value that will always be fed, and to -- provide attrs that enable the fed value to be checked at runtime. placeholder :: (TensorType dtype) => Tensor Value dtype -- | Outputs a Summary protocol buffer with scalar values. -- -- The input tags and values must have the same shape. -- The generated summary has a summary value for each tag-value pair in -- tags and values. scalarSummary :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 ByteString -> Tensor v2 t -> Tensor Value ByteString -- | Computes softmax activations. -- -- For each batch i and class j we have -- -- softmax[i, j] = exp(logits[i, j]) / sum_j(exp(logits[i, j])) softmax :: (TensorType t, OneOf '[Word16, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Generate a sharded filename. The filename is printf formatted as -- -- %s-%05d-of-%05d, basename, shard, num_shards. shardedFilename :: Tensor v1 ByteString -> Tensor v2 Int32 -> Tensor v3 Int32 -> Tensor Value ByteString -- | Sends the named tensor from send_device to recv_device. -- -- _HostSend requires its input on host memory whereas _Send requires its -- input on device memory. _HostSend :: (TensorType t) => Int64 -> Tensor v1 t -> ControlNode -- | Computes the gradient of the sigmoid of x wrt its input. -- -- Specifically, `grad = dy * y * (1 - y)`, where `y = sigmoid(x)`, and -- dy is the corresponding input gradient. sigmoidGrad :: (TensorType t, OneOf '[Complex Double, Complex Float, Word16, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Greedily selects a subset of bounding boxes in descending order of -- score, -- -- pruning away boxes that have high intersection-over-union (IOU) -- overlap with previously selected boxes. Bounding boxes are supplied as -- [y1, x1, y2, x2], where (y1, x1) and (y2, x2) are the coordinates of -- any diagonal pair of box corners and the coordinates can be provided -- as normalized (i.e., lying in the interval [0, 1]) or absolute. Note -- that this algorithm is agnostic to where the origin is in the -- coordinate system. Note that this algorithm is invariant to orthogonal -- transformations and translations of the coordinate system; thus -- translating or reflections of the coordinate system result in the same -- boxes being selected by the algorithm. -- -- The output of this operation is a set of integers indexing into the -- input collection of bounding boxes representing the selected boxes. -- The bounding box coordinates corresponding to the selected indices can -- then be obtained using the tf.gather operation. For example: -- -- selected_indices = tf.image.non_max_suppression( boxes, scores, -- max_output_size, iou_threshold) selected_boxes = tf.gather(boxes, -- selected_indices) nonMaxSuppression :: Tensor v1 Float -> Tensor v2 Float -> Tensor v3 Int32 -> Tensor Value Int32 -- | A Reader that outputs the queued work as both the key and value. -- -- To use, enqueue strings in a Queue. ReaderRead will take the front -- work string and output (work, work). identityReader :: Tensor Value ByteString -- | Extracts a glimpse from the input tensor. -- -- Returns a set of windows called glimpses extracted at location -- offsets from the input tensor. If the windows only partially -- overlaps the inputs, the non overlapping areas will be filled with -- random noise. -- -- The result is a 4-D tensor of shape `[batch_size, glimpse_height, -- glimpse_width, channels]`. The channels and batch dimensions are the -- same as that of the input tensor. The height and width of the output -- windows are specified in the size parameter. -- -- The argument normalized and centered controls how -- the windows are built: -- -- extractGlimpse :: Tensor v1 Float -> Tensor v2 Int32 -> Tensor v3 Float -> Tensor Value Float -- | Computes the gradients of 3-D convolution with respect to the input. conv3DBackpropInput :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor v3 t -> Tensor Value t -- | Solves one or more linear least-squares problems. -- -- matrix is a tensor of shape `[..., M, N]` whose inner-most 2 -- dimensions form matrices of size `[M, N]`. Rhs is a tensor of shape -- `[..., M, K]`. The output is a tensor shape `[..., N, K]` where each -- output matrix solves each of the equations matrix[..., :, :] * -- output[..., :, :] = rhs[..., :, :] in the least squares sense. -- -- 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. matrixSolveLs :: (TensorType t, OneOf '[Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor v3 Double -> Tensor Value t -- | Converts one or more images from RGB to HSV. -- -- Outputs a tensor of the same shape as the images tensor, -- containing the HSV value of the pixels. The output is only well -- defined if the value in images are in `[0,1]`. -- -- `output[..., 0]` contains hue, `output[..., 1]` contains saturation, -- and `output[..., 2]` contains value. All HSV values are in `[0,1]`. A -- hue of 0 corresponds to pure red, hue 13 is pure green, and 23 -- is pure blue. rGBToHSV :: (TensorType t, OneOf '[Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Decode the first frame of a GIF-encoded image to a uint8 tensor. -- -- GIF with frame or transparency compression are not supported convert -- animated GIF from compressed to uncompressed by: -- -- convert $src.gif -coalesce $dst.gif decodeGif :: Tensor v1 ByteString -> Tensor Value Word8 -- | Deprecated. Disallowed in GraphDef version >= 2. adjustContrast :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 Float -> Tensor v3 Float -> Tensor v4 Float -> Tensor Value Float -- | DepthToSpace for tensors of type T. -- -- Rearranges data from depth into blocks of spatial data. This is the -- reverse transformation of SpaceToDepth. More specifically, this op -- outputs a copy of the input tensor where values from the -- depth dimension are moved in spatial blocks to the -- height and width dimensions. The attr -- block_size indicates the input block size and how the data is -- moved. -- -- -- -- That is, assuming the input is in the shape: `[batch, height, width, -- depth]`, the shape of the output will be: `[batch, height*block_size, -- width*block_size, depth/(block_size*block_size)]` -- -- This operation requires that the input tensor be of rank 4, and that -- block_size be >=1 and that `block_size * block_size` be a -- divisor of the input depth. -- -- This operation is useful for resizing the activations between -- convolutions (but keeping all data), e.g. instead of pooling. It is -- also useful for training purely convolutional models. -- -- For example, given this input of shape `[1, 1, 1, 4]`, and a block -- size of 2: -- -- ```prettyprint x = [[[[1, 2, 3, 4]]]] -- -- ``` -- -- This operation will output a tensor of shape `[1, 2, 2, 1]`: -- -- ```prettyprint [[[[1], [2]], [[3], [4]]]] ``` -- -- Here, the input has a batch of 1 and each batch element has shape `[1, -- 1, 4]`, the corresponding output will have 2x2 elements and will have -- a depth of 1 channel (1 = `4 / (block_size * block_size)`). The output -- element shape is `[2, 2, 1]`. -- -- For an input tensor with larger depth, here of shape `[1, 1, 1, 12]`, -- e.g. -- -- ```prettyprint x = [[[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]]] ``` -- -- This operation, for block size of 2, will return the following tensor -- of shape `[1, 2, 2, 3]` -- -- ```prettyprint [[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]] -- -- ``` -- -- Similarly, for the following input of shape `[1 2 2 4]`, and a block -- size of 2: -- -- ```prettyprint x = [[[[1, 2, 3, 4], [5, 6, 7, 8]], [[9, 10, 11, 12], -- [13, 14, 15, 16]]]] ``` -- -- the operator will return the following tensor of shape `[1 4 4 1]`: -- -- ```prettyprint x = [[ [1], [2], [5], [6]], [ [3], [4], [7], [8]], [ -- [9], [10], [13], [14]], [ [11], [12], [15], [16]]] -- -- ``` depthToSpace :: (TensorType t) => Int64 -> Tensor v1 t -> Tensor Value t batchMatrixSolve :: (TensorType t, OneOf '[Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Computes the complementary error function of x element-wise. erfc :: (TensorType t, OneOf '[Word16, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Computes the gradient of bilinear interpolation. resizeBilinearGrad :: (TensorType t, OneOf '[Word16, Double, Float] t) => Tensor v1 Float -> Tensor v2 t -> Tensor Value t -- | Output a fact about factorials. fact :: Tensor Value ByteString -- | Delete the tensor specified by its handle in the session. deleteSessionTensor :: Tensor v1 ByteString -> ControlNode -- | Returns the truth value of x OR y element-wise. -- -- logicalOr :: Tensor v1 Bool -> Tensor v2 Bool -> Tensor Value Bool -- | Get the value of the tensor specified by its handle. getSessionTensor :: (TensorType dtype) => Tensor v1 ByteString -> Tensor Value dtype batchMatrixInverse :: (TensorType t, OneOf '[Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Generate a glob pattern matching all sharded file names. shardedFilespec :: Tensor v1 ByteString -> Tensor v2 Int32 -> Tensor Value ByteString -- | Decode web-safe base64-encoded strings. -- -- Input may or may not have padding at the end. See EncodeBase64 for -- padding. Web-safe means that input must use - and _ instead of + and -- /. decodeBase64 :: Tensor v1 ByteString -> Tensor Value ByteString -- | Store the input tensor in the state of the current session. getSessionHandle :: (TensorType t) => Tensor v1 t -> Tensor Value ByteString -- | Table initializer that takes two tensors for keys and values -- respectively. initializeTable :: (TensorType tkey, TensorType tval) => Tensor v1 ByteString -> Tensor v2 tkey -> Tensor v3 tval -> ControlNode -- | Computes tan of x element-wise. tan :: (TensorType t, OneOf '[Complex Double, Complex Float, Int32, Int64, Word16, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Computes hyperbolic tangent of x element-wise. tanh :: (TensorType t, OneOf '[Complex Double, Complex Float, Word16, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Update '*var' according to the proximal adagrad scheme. applyAdagradDA :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor v3 t -> Tensor v4 t -> Tensor v5 t -> Tensor v6 t -> Tensor v7 t -> Tensor v8 Int64 -> Tensor Value t -- | Converts each string in the input Tensor to its hash mod by a number -- of buckets. -- -- The hash function is deterministic on the content of the string within -- the process. -- -- Note that the hash function may change from time to time. This -- functionality will be deprecated and it's recommended to use -- `tf.string_to_hash_bucket_fast()` or -- `tf.string_to_hash_bucket_strong()`. stringToHashBucket :: Int64 -> Tensor v1 ByteString -> Tensor Value Int64 -- | Computes gradients for the exponential linear (Elu) operation. eluGrad :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Computes gradient of the FractionalAvgPool function. -- -- Unlike FractionalMaxPoolGrad, we don't need to find arg_max for -- FractionalAvgPoolGrad, we just need to evenly back-propagate each -- element of out_backprop to those indices that form the same pooling -- cell. Therefore, we just need to know the shape of original input -- tensor, instead of the whole tensor. fractionalAvgPoolGrad :: (TensorType t, OneOf '[Int32, Int64, Double, Float] t) => Tensor v1 Int64 -> Tensor v2 t -> Tensor v3 Int64 -> Tensor v4 Int64 -> Tensor Value t -- | Solves systems of linear equations with upper or lower triangular -- matrices by -- -- backsubstitution. -- -- matrix is a tensor of shape `[..., M, M]` whose inner-most 2 -- dimensions form square matrices. If lower is True then -- the strictly upper triangular part of each inner-most matrix is -- assumed to be zero and not accessed. If lower is False then -- the strictly lower triangular part of each inner-most matrix is -- assumed to be zero and not accessed. rhs is a tensor of shape -- `[..., M, K]`. -- -- The output is a tensor of shape `[..., M, K]`. If adjoint is -- True then the innermost matrices in output` satisfy matrix -- equations `matrix[..., :, :] * output[..., :, :] = rhs[..., :, :]`. If -- adjoint is False then the strictly then the innermost -- matrices in output satisfy matrix equations -- `adjoint(matrix[..., i, k]) * output[..., k, j] = rhs[..., i, j]`. matrixTriangularSolve :: (TensorType t, OneOf '[Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Computes the (possibly normalized) Levenshtein Edit Distance. -- -- The inputs are variable-length sequences provided by SparseTensors -- (hypothesis_indices, hypothesis_values, hypothesis_shape) and -- (truth_indices, truth_values, truth_shape). -- -- The inputs are: editDistance :: (TensorType t) => Tensor v1 Int64 -> Tensor v2 t -> Tensor v3 Int64 -> Tensor v4 Int64 -> Tensor v5 t -> Tensor v6 Int64 -> Tensor Value Float -- | Computes the number of incomplete elements in the given barrier. barrierIncompleteSize :: Tensor v1 ByteString -> Tensor Value Int32 -- | Generates labels for candidate sampling with a learned unigram -- distribution. -- -- See explanations of candidate sampling and the data formats at -- go/candidate-sampling. -- -- For each batch, this op picks a single set of sampled candidate -- labels. -- -- The advantages of sampling candidates per-batch are simplicity and the -- possibility of efficient dense matrix multiplication. The disadvantage -- is that the sampled candidates must be chosen independently of the -- context and of the true labels. threadUnsafeUnigramCandidateSampler :: Int64 -> Int64 -> Int64 -> Bool -> Tensor v1 Int64 -> (Tensor Value Int64, Tensor Value Float, Tensor Value Float) -- | Computes the number of complete elements in the given barrier. barrierReadySize :: Tensor v1 ByteString -> Tensor Value Int32 -- | Closes the given barrier. -- -- This operation signals that no more new elements will be inserted in -- the given barrier. Subsequent InsertMany that try to introduce a new -- key will fail. Subsequent InsertMany operations that just add missing -- components to already existing elements will continue to succeed. -- Subsequent TakeMany operations will continue to succeed if sufficient -- completed elements remain in the barrier. Subsequent TakeMany -- operations that would block will fail immediately. barrierClose :: Tensor v1 ByteString -> ControlNode -- | A Reader that outputs the lines of a file delimited by '\n'. textLineReader :: Tensor Value ByteString -- | Compute the 3-dimensional discrete Fourier Transform over the -- inner-most 3 -- -- dimensions of input. fFT3D :: Tensor v1 (Complex Float) -> Tensor Value (Complex Float) -- | Exits the current frame to its parent frame. -- -- Exit makes its input `data` available to the parent frame. refExit :: (TensorType t) => Tensor v1 t -> Tensor Value t -- | Computes exponential of x element-wise. \(y = e^x\). exp :: (TensorType t, OneOf '[Complex Double, Complex Float, Word16, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Restores a tensor from checkpoint files. -- -- This is like Restore except that restored tensor can be -- listed as filling only a slice of a larger tensor. -- shape_and_slice specifies the shape of the larger tensor and -- the slice that the restored tensor covers. -- -- The shape_and_slice input has the same format as the elements -- of the shapes_and_slices input of the SaveSlices op. restoreSlice :: (TensorType dt) => Tensor v1 ByteString -> Tensor v2 ByteString -> Tensor v3 ByteString -> Tensor Value dt -- | Returns the complex conjugate of a complex number. -- -- Given a tensor input of complex numbers, this operation -- returns a tensor of complex numbers that are the complex conjugate of -- each element in input. The complex numbers in input -- must be of the form \(a + bj\), where *a* is the real part and *b* is -- the imaginary part. -- -- The complex conjugate returned by this operation is of the form \(a - -- bj\). -- -- For example: -- -- ``` # tensor input is [-2.25 + 4.75j, 3.25 + 5.75j] -- tf.conj(input) ==> [-2.25 - 4.75j, 3.25 - 5.75j] ``` conj :: (TensorType t, OneOf '[Complex Double, Complex Float] t) => Tensor v1 t -> Tensor Value t -- | Computes the gradient of nearest neighbor interpolation. resizeNearestNeighborGrad :: (TensorType t, OneOf '[Int32, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 Int32 -> Tensor Value t -- | Delete the TensorArray from its resource container. This enables -- -- the user to close and release the resource in the middle of a -- step/run. tensorArrayClose :: Tensor v1 ByteString -> ControlNode -- | Computes atan of x element-wise. atan :: (TensorType t, OneOf '[Complex Double, Complex Float, Int32, Int64, Word16, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Get the current size of the TensorArray. tensorArraySize :: Tensor v1 ByteString -> Tensor v2 Float -> Tensor Value Int32 -- | Concat the elements from the TensorArray into value value. -- -- Takes T elements of shapes -- -- ``` (n0 x d0 x d1 x ...), (n1 x d0 x d1 x ...), ..., (n(T-1) x d0 x d1 -- x ...) ``` -- -- and concatenates them into a Tensor of shape: -- -- ```(n0 + n1 + ... + n(T-1) x d0 x d1 x ...)``` -- -- All elements must have the same shape (excepting the first dimension). tensorArrayConcat :: (TensorType dtype) => Tensor v1 ByteString -> Tensor v2 Float -> (Tensor Value dtype, Tensor Value Int64) -- | Local Response Normalization. -- -- The 4-D input tensor is treated as a 3-D array of 1-D vectors -- (along the last dimension), and each vector is normalized -- independently. Within a given vector, each component is divided by the -- weighted, squared sum of inputs within depth_radius. In -- detail, -- -- sqr_sum[a, b, c, d] = sum(input[a, b, c, d - depth_radius : d + -- depth_radius + 1] ** 2) output = input / (bias + alpha * sqr_sum) ** -- beta -- -- For details, see Krizhevsky et al., ImageNet classification with -- deep convolutional neural networks (NIPS 2012). lRN :: (TensorType t, OneOf '[Word16, Float] t) => Tensor v1 t -> Tensor Value t -- | Converts each string in the input Tensor to its hash mod by a number -- of buckets. -- -- The hash function is deterministic on the content of the string within -- the process and will never change. However, it is not suitable for -- cryptography. This function may be used when CPU time is scarce and -- inputs are trusted or unimportant. There is a risk of adversaries -- constructing inputs that all hash to the same bucket. To prevent this -- problem, use a strong hash function with -- `tf.string_to_hash_bucket_strong`. stringToHashBucketFast :: Int64 -> Tensor v1 ByteString -> Tensor Value Int64 -- | Pack the elements from the TensorArray into output value. -- -- -- -- Instead of this op, use TensorArrayGather with `indices = -- RangeOp(0, TensorArraySizeOp)`. -- -- All elements must have the same shape. tensorArrayPack :: (TensorType dtype) => Tensor v1 ByteString -> Tensor v2 Float -> Tensor Value dtype -- | Computes offsets of concat inputs within its output. -- -- For example: -- -- ```prettyprint # x is [2, 2, 7] # y is [2, 3, 7] # -- z is [2, 5, 7] concat_offset(2, [x, y, z]) => [0, 0, 0], -- [0, 2, 0], [0, 5, 0] ``` concatOffset :: Tensor v1 Int32 -> [Tensor v2 Int32] -> [Tensor Value Int32] -- | Creates or finds a child frame, and makes `data` available to the -- child frame. -- -- The unique frame_name is used by the Executor to -- identify frames. If is_constant is true, output is a -- constant in the child frame; otherwise it may be changed in the child -- frame. At most parallel_iterations iterations are run in -- parallel in the child frame. refEnter :: (TensorType t) => Tensor v1 t -> Tensor Value t -- | Computes softsign: `features / (abs(features) + 1)`. softsign :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Push an element onto the tensor_array. tensorArrayWrite :: (TensorType t) => Tensor v1 ByteString -> Tensor v2 Int32 -> Tensor v3 t -> Tensor v4 Float -> Tensor Value Float -- | Returns a diagonal tensor with a given diagonal values. -- -- 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: -- -- ```prettyprint # 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]] ``` diag :: (TensorType t, OneOf '[Complex Double, Complex Float, Int32, Int64, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Returns the batched diagonal part of a batched tensor. -- -- This operation returns a tensor with the diagonal part of the -- batched input. The diagonal part is computed as -- follows: -- -- Assume input has k dimensions `[I, J, K, ..., N, -- N]`, then the output is a tensor of rank `k - 1` with dimensions `[I, -- J, K, ..., N]` where: -- -- `diagonal[i, j, k, ..., n] = input[i, j, k, ..., n, n]`. -- -- The input must be at least a matrix. -- -- For example: -- -- ```prettyprint # input is [[[1, 0, 0, 0] [0, 2, 0, 0] [0, 0, -- 3, 0] [0, 0, 0, 4]], [[5, 0, 0, 0] [0, 6, 0, 0] [0, 0, 7, 0] [0, 0, 0, -- 8]]] -- -- and input.shape = (2, 4, 4) -- -- tf.matrix_diag_part(input) ==> [[1, 2, 3, 4], [5, 6, 7, 8]] -- -- which has shape (2, 4) ``` matrixDiagPart :: (TensorType t) => Tensor v1 t -> Tensor Value t -- | Computes the number of elements in the given queue. queueSize :: Tensor v1 ByteString -> Tensor Value Int32 -- | Decode a PNG-encoded image to a uint8 or uint16 tensor. -- -- The attr channels indicates the desired number of color -- channels for the decoded image. -- -- Accepted values are: -- -- -- -- If needed, the PNG-encoded image is transformed to match the requested -- number of color channels. decodePng :: (TensorType dtype, OneOf '[Word16, Word8] dtype) => Tensor v1 ByteString -> Tensor Value dtype -- | Returns element-wise smallest integer in not less than x. ceil :: (TensorType t, OneOf '[Word16, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | A queue that produces elements sorted by the first component value. -- -- Note that the PriorityQueue requires the first component of any -- element to be a scalar int64, in addition to the other elements -- declared by component_types. Therefore calls to Enqueue and -- EnqueueMany (resp. Dequeue and DequeueMany) on a PriorityQueue will -- all require (resp. output) one extra entry in their input (resp. -- output) lists. priorityQueue :: Tensor Value ByteString -- | A placeholder op that passes though input when its output is -- not fed. placeholderWithDefault :: (TensorType dtype) => Tensor v1 dtype -> Tensor Value dtype -- | Computes the gradient of the crop_and_resize op wrt the input image -- tensor. cropAndResizeGradImage :: (TensorType t, OneOf '[Word16, Double, Float] t) => Tensor v1 Float -> Tensor v2 Float -> Tensor v3 Int32 -> Tensor v4 Int32 -> Tensor Value t -- | Restore a Reader to its initial clean state. readerReset :: Tensor v1 ByteString -> ControlNode -- | Extract patches from images and put them in the -- "depth" output dimension. extractImagePatches :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor Value t batchMatrixSetDiag :: (TensorType t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Delete the stack from its resource container. stackClose :: Tensor v1 ByteString -> ControlNode -- | Quantizes then dequantizes a tensor. -- -- This op simulates the precision loss from the quantized forward pass -- by: 1. Quantizing the tensor to fixed point numbers, which should -- match the target quantization method when it is used in inference. 2. -- Dequantizing it back to floating point numbers for the following ops, -- most likely matmul. -- -- There are different ways to quantize. This version does not use the -- full range of the output type, choosing to elide the lowest possible -- value for symmetry (e.g., output range is -127 to 127, not -128 to 127 -- for signed 8 bit quantization), so that 0.0 maps to 0. -- -- To perform this op, we first find the range of values in our tensor. -- The range we use is always centered on 0, so we find m such that -- --
    --
  1. m = max(abs(input_min), abs(input_max)) if range_given is -- true,
  2. --
  3. m = max(max(abs(min_elem(input)), abs(max_elem(input))) -- otherwise.
  4. --
-- -- Our input tensor range is then [-m, m]. -- -- Next, we choose our fixed-point quantization buckets, [min_fixed, -- max_fixed]. If signed_input is true, this is -- -- -- -- Otherwise, if signed_input is false, the fixed-point range is -- -- -- -- From this we compute our scaling factor, s: -- -- s = (max_fixed - min_fixed) / (2 * m). -- -- Now we can quantize and dequantize the elements of our tensor. An -- element e is transformed into e': -- -- e' = (e * s).round_to_nearest() / s. -- -- Note that we have a different number of buckets in the signed vs. -- unsigned cases. For example, if num_bits == 8, we get 254 buckets in -- the signed case vs. 255 in the unsigned case. -- -- For example, suppose num_bits = 8 and m = 1. Then -- -- -- -- Given the vector {-1, -0.5, 0, 0.3}, this is quantized to {-127, -63, -- 0, 38}, and dequantized to {-1, -63.0127, 0, 38.0127}. quantizeAndDequantize :: (TensorType t, OneOf '[Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Returns which elements of x are NaN. isNan :: (TensorType t, OneOf '[Word16, Double, Float] t) => Tensor v1 t -> Tensor Value Bool -- | Returns locations of true values in a boolean tensor. -- -- This operation returns the coordinates of true elements in -- input. The coordinates are returned in a 2-D tensor where the -- first dimension (rows) represents the number of true elements, and the -- second dimension (columns) represents the coordinates of the true -- elements. Keep in mind, the shape of the output tensor can vary -- depending on how many true values there are in input. Indices -- are output in row-major order. -- -- For example: -- -- ```prettyprint # input tensor is [[True, False] # [True, -- False]] # input has two true values, so output has two -- coordinates. # input has rank of 2, so coordinates have two -- indices. where(input) ==> [[0, 0], [1, 0]] -- -- # input tensor is [[[True, False] # [True, False]] # [[False, -- True] # [False, True]] # [[False, False] # [False, True]]] # -- input has 5 true values, so output has 5 coordinates. # -- input has rank of 3, so coordinates have three indices. -- where(input) ==> [[0, 0, 0], [0, 1, 0], [1, 0, 1], [1, 1, 1], [2, -- 1, 1]] ``` where' :: Tensor v1 Bool -> Tensor Value Int64 -- | Computes the difference between two lists of numbers or strings. -- -- Given a list x and a list y, this operation returns -- a list out that represents all values that are in x -- but not in y. The returned list out is sorted in the -- same order that the numbers appear in x (duplicates are -- preserved). This operation also returns a list idx that -- represents the position of each out element in x. In -- other words: -- -- `out[i] = x[idx[i]] for i in [0, 1, ..., len(out) - 1]` -- -- For example, given this input: -- -- ```prettyprint x = [1, 2, 3, 4, 5, 6] y = [1, 3, 5] ``` -- -- This operation would return: -- -- ```prettyprint out ==> [2, 4, 6] idx ==> [1, 3, 5] ``` listDiff :: (TensorType t, TensorType out_idx, OneOf '[Int32, Int64] out_idx) => Tensor v1 t -> Tensor v2 t -> (Tensor Value t, Tensor Value out_idx) -- | Return a strided slice from input. -- -- The output tensor is a tensor with dimensions implied by -- begin, end, and strides, whose values are -- extracted from begin. -- -- Specifically, the result tensor at index `(i[0], i[1], ..., i[n-1])` -- will obtain the value `input[begin[0] + i[0] * stride[0], ..., ` -- `begin[n-1] + i[n-1] * stride[n-1])]`. -- -- stridedSlice :: (TensorType index, OneOf '[Int32, Int64] index, TensorType t) => Tensor v1 t -> Tensor v2 index -> Tensor v3 index -> Tensor v4 index -> Tensor Value t -- | A queue that randomizes the order of elements. randomShuffleQueue :: Tensor Value ByteString -- | Returns the gradient of Tile. -- -- Since Tile takes an input and repeats the input -- multiples times along each dimension, TileGrad takes -- in multiples and aggregates each repeated tile of -- input into output. tileGrad :: (TensorType t) => Tensor v1 t -> Tensor v2 Int32 -> Tensor Value t -- | Assign value to the sliced l-value reference of ref. -- -- The values of value are assigned to the positions in the -- variable ref that are selected by the slice parameters. The -- slice parameters `begin, end, strides, etc. work -- exactly as in StridedSlice. -- -- NOTE this op currently does not support broadcasting and so -- value's shape must be exactly the shape produced by the slice -- of ref. stridedSliceAssign :: (TensorType index, OneOf '[Int32, Int64] index, TensorType t) => Tensor v1 t -> Tensor v2 index -> Tensor v3 index -> Tensor v4 index -> Tensor v5 t -> Tensor Value t -- | Reshapes a tensor. -- -- Given tensor, this operation returns a tensor that has the -- same values as tensor with shape shape. -- -- If one component of shape is the special value -1, the size of -- that dimension is computed so that the total size remains constant. In -- particular, a shape of `[-1]` flattens into 1-D. At most one -- component of shape can be -1. -- -- If shape is 1-D or higher, then the operation returns a tensor -- with shape shape filled with the values of tensor. In -- this case, the number of elements implied by shape must be the -- same as the number of elements in tensor. -- -- For example: -- -- ```prettyprint # tensor t is [1, 2, 3, 4, 5, 6, 7, 8, 9] # -- tensor t has shape [9] reshape(t, [3, 3]) ==> [[1, 2, 3], -- [4, 5, 6], [7, 8, 9]] -- -- # tensor t is [[[1, 1], [2, 2]], # [[3, 3], [4, 4]]] # tensor -- t has shape [2, 2, 2] reshape(t, [2, 4]) ==> [[1, 1, 2, -- 2], [3, 3, 4, 4]] -- -- # tensor t is [[[1, 1, 1], # [2, 2, 2]], # [[3, 3, 3], # [4, -- 4, 4]], # [[5, 5, 5], # [6, 6, 6]]] # tensor t has shape [3, -- 2, 3] # pass '[-1]' to flatten t reshape(t, [-1]) ==> [1, -- 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6] -- -- # -1 can also be used to infer the shape -- -- # -1 is inferred to be 9: reshape(t, [2, -1]) ==> [[1, 1, 1, 2, 2, -- 2, 3, 3, 3], [4, 4, 4, 5, 5, 5, 6, 6, 6]] # -1 is inferred to be 2: -- reshape(t, [-1, 9]) ==> [[1, 1, 1, 2, 2, 2, 3, 3, 3], [4, 4, 4, 5, -- 5, 5, 6, 6, 6]] # -1 is inferred to be 3: reshape(t, [ 2, -1, 3]) -- ==> [[[1, 1, 1], [2, 2, 2], [3, 3, 3]], [[4, 4, 4], [5, 5, 5], [6, -- 6, 6]]] -- -- # tensor t is [7] # shape `[]` reshapes to a scalar -- reshape(t, []) ==> 7 ``` reshape :: (TensorType t, TensorType tshape, OneOf '[Int32, Int64] tshape) => Tensor v1 t -> Tensor v2 tshape -> Tensor Value t -- | A queue that produces elements in first-in first-out order. fIFOQueue :: Tensor Value ByteString -- | Generates labels for candidate sampling with a learned unigram -- distribution. -- -- See explanations of candidate sampling and the data formats at -- go/candidate-sampling. -- -- For each batch, this op picks a single set of sampled candidate -- labels. -- -- The advantages of sampling candidates per-batch are simplicity and the -- possibility of efficient dense matrix multiplication. The disadvantage -- is that the sampled candidates must be chosen independently of the -- context and of the true labels. learnedUnigramCandidateSampler :: Int64 -> Int64 -> Int64 -> Bool -> Tensor v1 Int64 -> (Tensor Value Int64, Tensor Value Float, Tensor Value Float) -- | Performs fractional average pooling on the input. -- -- Fractional average pooling is similar to Fractional max pooling in the -- pooling region generation step. The only difference is that after -- pooling regions are generated, a mean operation is performed instead -- of a max operation in each pooling region. fractionalAvgPool :: (TensorType t, OneOf '[Int32, Int64, Double, Float] t) => Tensor v1 t -> (Tensor Value t, Tensor Value Int64, Tensor Value Int64) -- | Randomly crop image. -- -- size is a 1-D int64 tensor with 2 elements representing the -- crop height and width. The values must be non negative. -- -- This Op picks a random location in image and crops a -- height by width rectangle from that location. The -- random location is picked so the cropped area will fit inside the -- original image. randomCrop :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 Int64 -> Tensor Value t -- | Cast x of type SrcT to y of DstT. -- -- _HostCast requires its input and produces its output in host memory. _HostCast :: (TensorType dstT, TensorType srcT) => Tensor v1 srcT -> Tensor Value dstT -- | Closes the given queue. -- -- This operation signals that no more elements will be enqueued in the -- given queue. Subsequent Enqueue(Many) operations will fail. Subsequent -- Dequeue(Many) operations will continue to succeed if sufficient -- elements remain in the queue. Subsequent Dequeue(Many) operations that -- would block will fail immediately. queueClose :: Tensor v1 ByteString -> ControlNode -- | Return a slice from input. -- -- The output tensor is a tensor with dimensions described by size -- whose values are extracted from input starting at the offsets -- in begin. -- -- slice :: (TensorType index, OneOf '[Int32, Int64] index, TensorType t) => Tensor v1 t -> Tensor v2 index -> Tensor v3 index -> Tensor Value t -- | Returns the gradient of StridedSlice. -- -- Since StridedSlice cuts out pieces of its input -- which is size shape, its gradient will have the same shape -- (which is passed here as shape). The gradient will be zero in -- any element that the slice does not select. -- -- Arguments are the same as StridedSliceGrad with the exception that -- dy is the input gradient to be propagated and shape is -- the shape of StridedSlice's input. stridedSliceGrad :: (TensorType index, OneOf '[Int32, Int64] index, TensorType t) => Tensor v1 index -> Tensor v2 index -> Tensor v3 index -> Tensor v4 index -> Tensor v5 t -> Tensor Value t -- | Adds up a SparseTensor and a dense Tensor, producing a -- dense Tensor. -- -- This Op does not require a_indices be sorted in standard -- lexicographic order. sparseTensorDenseAdd :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t, TensorType tindices, OneOf '[Int32, Int64] tindices) => Tensor v1 tindices -> Tensor v2 t -> Tensor v3 tindices -> Tensor v4 t -> Tensor Value t -- | Returns the size of a tensor. -- -- This operation returns an integer representing the number of elements -- in input. -- -- For example: -- -- ```prettyprint # t is [[[1, 1,, 1], [2, 2, 2]], [[3, 3, 3], -- [4, 4, 4]]]] size(t) ==> 12 ``` size :: (TensorType t, TensorType out_type, OneOf '[Int32, Int64] out_type) => Tensor v1 t -> Tensor Value out_type -- | Defines a barrier that persists across different graph executions. -- -- A barrier represents a key-value map, where each key is a string, and -- each value is a tuple of tensors. -- -- At runtime, the barrier contains complete and -- incomplete elements. A complete element has defined tensors -- for all components of its value tuple, and may be accessed using -- BarrierTakeMany. An incomplete element has some undefined components -- in its value tuple, and may be updated using BarrierInsertMany. barrier :: Tensor Value ByteString -- | Computes the log of the absolute value of `Gamma(x)` element-wise. lgamma :: (TensorType t, OneOf '[Word16, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Decode a JPEG-encoded image to a uint8 tensor. -- -- The attr channels indicates the desired number of color -- channels for the decoded image. -- -- Accepted values are: -- -- -- -- If needed, the JPEG-encoded image is transformed to match the -- requested number of color channels. -- -- The attr ratio allows downscaling the image by an integer -- factor during decoding. Allowed values are: 1, 2, 4, and 8. This is -- much faster than downscaling the image later. decodeJpeg :: Tensor v1 ByteString -> Tensor Value Word8 -- | Returns shape of tensors. -- -- This operation returns N 1-D integer tensors representing shape of -- `input[i]s`. shapeN :: (TensorType t, TensorType out_type, OneOf '[Int32, Int64] out_type) => [Tensor v1 t] -> [Tensor Value out_type] -- | Generates labels for candidate sampling with a uniform distribution. -- -- See explanations of candidate sampling and the data formats at -- go/candidate-sampling. -- -- For each batch, this op picks a single set of sampled candidate -- labels. -- -- The advantages of sampling candidates per-batch are simplicity and the -- possibility of efficient dense matrix multiplication. The disadvantage -- is that the sampled candidates must be chosen independently of the -- context and of the true labels. uniformCandidateSampler :: Int64 -> Int64 -> Int64 -> Bool -> Tensor v1 Int64 -> (Tensor Value Int64, Tensor Value Float, Tensor Value Float) -- | Finds unique elements in a 1-D tensor. -- -- This operation returns a tensor y containing all of the -- unique elements of x sorted in the same order that they occur -- in x. This operation also returns a tensor idx the -- same size as x that contains the index of each value of -- x in the unique output y. In other words: -- -- `y[idx[i]] = x[i] for i in [0, 1,...,rank(x) - 1]` -- -- For example: -- -- ```prettyprint # tensor x is [1, 1, 2, 4, 4, 4, 7, 8, 8] y, -- idx = unique(x) y ==> [1, 2, 4, 7, 8] idx ==> [0, 0, 1, 2, 2, 2, -- 3, 4, 4] ``` unique :: (TensorType t, TensorType out_idx, OneOf '[Int32, Int64] out_idx) => Tensor v1 t -> (Tensor Value t, Tensor Value out_idx) -- | Draw bounding boxes on a batch of images. -- -- Outputs a copy of images but draws on top of the pixels zero -- or more bounding boxes specified by the locations in boxes. -- The coordinates of the each bounding box in boxes are encoded -- as `[y_min, x_min, y_max, x_max]`. The bounding box coordinates are -- floats in `[0.0, 1.0]` relative to the width and height of the -- underlying image. -- -- For example, if an image is 100 x 200 pixels and the bounding box is -- `[0.1, 0.2, 0.5, 0.9]`, the bottom-left and upper-right coordinates of -- the bounding box will be `(10, 40)` to `(50, 180)`. -- -- Parts of the bounding box may fall outside the image. drawBoundingBoxes :: (TensorType t, OneOf '[Word16, Float] t) => Tensor v1 t -> Tensor v2 Float -> Tensor Value t -- | Split the data from the input value into TensorArray elements. -- -- Assuming that lengths takes on values -- -- ```(n0, n1, ..., n(T-1))``` -- -- and that value has shape -- -- ```(n0 + n1 + ... + n(T-1) x d0 x d1 x ...)```, -- -- this splits values into a TensorArray with T tensors. -- -- TensorArray index t will be the subtensor of values with starting -- position -- -- ```(n0 + n1 + ... + n(t-1), 0, 0, ...)``` -- -- and having size -- -- ```nt x d0 x d1 x ...``` tensorArraySplit :: (TensorType t) => Tensor v1 ByteString -> Tensor v2 t -> Tensor v3 Int64 -> Tensor v4 Float -> Tensor Value Float -- | Splits a tensor into num_split tensors along one dimension. split :: (TensorType t) => Int64 -> Tensor v1 Int32 -> Tensor v2 t -> [Tensor Value t] -- | Computes the maximum along segments of a tensor. -- -- Read the section on Segmentation for an explanation of -- segments. -- -- Computes a tensor such that \(output_i = max_j(data_j)\) where -- max is over j such that `segment_ids[j] == i`. -- -- style="width:70%; margin:auto; margin-bottom:10px; -- margin-top:20px;" style="width:100%" -- src="../../images/SegmentMax.png" alt /div segmentMax :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t, TensorType tindices, OneOf '[Int32, Int64] tindices) => Tensor v1 t -> Tensor v2 tindices -> Tensor Value t -- | Raise a exception to abort the process when called. -- -- Returns nothing but an exception. abort :: ControlNode -- | Reorders a SparseTensor into the canonical, row-major ordering. -- -- Note that by convention, all sparse ops preserve the canonical -- ordering along increasing dimension number. The only time ordering can -- be violated is during manual manipulation of the indices and values -- vectors to add entries. -- -- Reordering does not affect the shape of the SparseTensor. -- -- If the tensor has rank R and N non-empty values, -- input_indices has shape `[N, R]`, input_values has length -- N, and input_shape has length R. sparseReorder :: (TensorType t) => Tensor v1 Int64 -> Tensor v2 t -> Tensor v3 Int64 -> (Tensor Value Int64, Tensor Value t) -- | Computes the gradient for the rsqrt of x wrt its input. -- -- Specifically, `grad = dy * -0.5 * y^3`, where `y = rsqrt(x)`, and -- dy is the corresponding input gradient. rsqrtGrad :: (TensorType t, OneOf '[Complex Double, Complex Float, Word16, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Reverses variable length slices. -- -- This op first slices input along the dimension -- batch_dim, and for each slice i, reverses the first -- `seq_lengths[i]` elements along the dimension seq_dim. -- -- The elements of seq_lengths must obey `seq_lengths[i] < -- input.dims[seq_dim]`, and seq_lengths must be a vector of -- length `input.dims[batch_dim]`. -- -- The output slice i along dimension batch_dim is then -- given by input slice i, with the first `seq_lengths[i]` -- slices along dimension seq_dim reversed. -- -- For example: -- -- ```prettyprint # Given this: batch_dim = 0 seq_dim = 1 input.dims = -- (4, 8, ...) seq_lengths = [7, 2, 3, 5] -- -- # then slices of input are reversed on seq_dim, but only up to -- seq_lengths: output[0, 0:7, :, ...] = input[0, 7:0:-1, :, ...] -- output[1, 0:2, :, ...] = input[1, 2:0:-1, :, ...] output[2, 0:3, :, -- ...] = input[2, 3:0:-1, :, ...] output[3, 0:5, :, ...] = input[3, -- 5:0:-1, :, ...] -- -- # while entries past seq_lens are copied through: output[0, 7:, :, -- ...] = input[0, 7:, :, ...] output[1, 2:, :, ...] = input[1, 2:, :, -- ...] output[2, 3:, :, ...] = input[2, 3:, :, ...] output[3, 2:, :, -- ...] = input[3, 2:, :, ...] ``` -- -- In contrast, if: -- -- ```prettyprint # Given this: batch_dim = 2 seq_dim = 0 input.dims = -- (8, ?, 4, ...) seq_lengths = [7, 2, 3, 5] -- -- # then slices of input are reversed on seq_dim, but only up to -- seq_lengths: output[0:7, :, 0, :, ...] = input[7:0:-1, :, 0, :, ...] -- output[0:2, :, 1, :, ...] = input[2:0:-1, :, 1, :, ...] output[0:3, :, -- 2, :, ...] = input[3:0:-1, :, 2, :, ...] output[0:5, :, 3, :, ...] = -- input[5:0:-1, :, 3, :, ...] -- -- # while entries past seq_lens are copied through: output[7:, :, 0, :, -- ...] = input[7:, :, 0, :, ...] output[2:, :, 1, :, ...] = input[2:, :, -- 1, :, ...] output[3:, :, 2, :, ...] = input[3:, :, 2, :, ...] -- output[2:, :, 3, :, ...] = input[2:, :, 3, :, ...] ``` reverseSequence :: (TensorType t, TensorType tlen, OneOf '[Int32, Int64] tlen) => Int64 -> Tensor v1 t -> Tensor v2 tlen -> Tensor Value t -- | Returns the number of records this Reader has produced. -- -- This is the same as the number of ReaderRead executions that have -- succeeded. readerNumRecordsProduced :: Tensor v1 ByteString -> Tensor Value Int64 -- | Deserialize and concatenate SparseTensors from a serialized -- minibatch. -- -- The input serialized_sparse must be a string matrix of shape -- `[N x 3]` where N is the minibatch size and the rows -- correspond to packed outputs of SerializeSparse. The ranks of -- the original SparseTensor objects must all match. When the -- final SparseTensor is created, it has rank one higher than -- the ranks of the incoming SparseTensor objects (they have -- been concatenated along a new row dimension). -- -- The output SparseTensor object's shape values for all -- dimensions but the first are the max across the input -- SparseTensor objects' shape values for the corresponding -- dimensions. Its first shape value is N, the minibatch size. -- -- The input SparseTensor objects' indices are assumed ordered -- in standard lexicographic order. If this is not the case, after this -- step run SparseReorder to restore index ordering. -- -- For example, if the serialized input is a `[2 x 3]` matrix -- representing two original SparseTensor objects: -- -- index = [ 0] [10] [20] values = [1, 2, 3] shape = [50] -- -- and -- -- index = [ 2] [10] values = [4, 5] shape = [30] -- -- then the final deserialized SparseTensor will be: -- -- index = [0 0] [0 10] [0 20] [1 2] [1 10] values = [1, 2, 3, 4, 5] -- shape = [2 50] deserializeManySparse :: (TensorType dtype) => Tensor v1 ByteString -> (Tensor Value Int64, Tensor Value dtype, Tensor Value Int64) -- | Returns immutable tensor from memory region. -- -- The current implementation memmaps the tensor from a file. immutableConst :: (TensorType dtype) => Tensor Value dtype -- | Returns the min of x and y (i.e. x < y ? x : y) element-wise. -- -- minimum :: (TensorType t, OneOf '[Int32, Int64, Word16, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Initializes a table from a text file. -- -- It inserts one key-value pair into the table for each line of the -- file. The key and value is extracted from the whole line content, -- elements from the split line based on delimiter or the line -- number (starting from zero). Where to extract the key and value from a -- line is specified by key_index and value_index. -- -- initializeTableFromTextFile :: Int64 -> Int64 -> Tensor v1 ByteString -> Tensor v2 ByteString -> ControlNode -- | Returns the diagonal part of the tensor. -- -- 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 example: -- -- ```prettyprint # input is [[1, 0, 0, 0] [0, 2, 0, 0] [0, 0, -- 3, 0] [0, 0, 0, 4]] -- -- tf.diag_part(input) ==> [1, 2, 3, 4] ``` diagPart :: (TensorType t, OneOf '[Complex Double, Complex Float, Int32, Int64, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Computes natural logarithm of x element-wise. -- -- I.e., \(y = log_e x\). log :: (TensorType t, OneOf '[Complex Double, Complex Float, Word16, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Scatter the data from the input value into specific TensorArray -- elements. -- -- indices must be a vector, its length must match the first dim -- of value. tensorArrayScatter :: (TensorType t) => Tensor v1 ByteString -> Tensor v2 Int32 -> Tensor v3 t -> Tensor v4 Float -> Tensor Value Float -- | Returns the rank of a tensor. -- -- This operation returns an integer representing the rank of -- input. -- -- For example: -- -- ```prettyprint # t is [[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], -- [4, 4, 4]]] # shape of tensor t is [2, 2, 3] rank(t) ==> 3 -- ``` -- -- rank :: (TensorType t) => Tensor v1 t -> Tensor Value Int32 -- | Return a tensor with the same shape and contents as the input tensor -- or value. identity :: (TensorType t) => Tensor v1 t -> Tensor Value t -- | Adjust the contrast of one or more images. -- -- images is a tensor of at least 3 dimensions. The last 3 -- dimensions are interpreted as `[height, width, channels]`. The other -- dimensions only represent a collection of images, such as `[batch, -- height, width, channels].` -- -- Contrast is adjusted independently for each channel of each image. -- -- For each channel, the Op first computes the mean of the image pixels -- in the channel and then adjusts each component of each pixel to `(x - -- mean) * contrast_factor + mean`. adjustContrastv2 :: Tensor v1 Float -> Tensor v2 Float -> Tensor Value Float -- | Sparse update entries in '*var' and '*accum' according to FOBOS -- algorithm. -- -- That is for rows we have grad for, we update var and accum as follows: -- accum += grad * grad prox_v = var prox_v -= lr * grad * (1 / -- sqrt(accum)) var = sign(prox_v)/(1+lr*l2) * max{|prox_v|-lr*l1,0} sparseApplyProximalAdagrad :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t, TensorType tindices, OneOf '[Int32, Int64] tindices) => Tensor v1 t -> Tensor v2 t -> Tensor v3 t -> Tensor v4 t -> Tensor v5 t -> Tensor v6 t -> Tensor v7 tindices -> Tensor Value t -- | Gather slices from params according to indices. -- -- indices must be an integer tensor of any dimension (usually -- 0-D or 1-D). Produces an output tensor with shape `indices.shape + -- params.shape[1:]` where: -- -- # Scalar indices output[:, ..., :] = params[indices, :, ... :] -- -- # Vector indices output[i, :, ..., :] = params[indices[i], :, ... :] -- -- # Higher rank indices output[i, ..., j, :, ... :] = params[indices[i, -- ..., j], :, ..., :] -- -- If indices is a permutation and `len(indices) == -- params.shape[0]` then this operation will permute params -- accordingly. -- -- style="width:70%; margin:auto; margin-bottom:10px; -- margin-top:20px;" style="width:100%" -- src="../../images/Gather.png" alt /div gather :: (TensorType tindices, OneOf '[Int32, Int64] tindices, TensorType tparams) => Tensor v1 tparams -> Tensor v2 tindices -> Tensor Value tparams -- | Checks whether a tensor has been initialized. -- -- Outputs boolean scalar indicating whether the tensor has been -- initialized. isVariableInitialized :: (TensorType dtype) => Tensor v1 dtype -> Tensor Value Bool -- | Concatenates tensors along one dimension. concat :: (TensorType t) => Tensor v1 Int32 -> [Tensor v2 t] -> Tensor Value t -- | Outputs random integers from a uniform distribution. -- -- The generated values are uniform integers in the range `[minval, -- maxval)`. The lower bound minval is included in the range, -- while the upper bound maxval is excluded. -- -- The random integers are slightly biased unless `maxval - minval` is an -- exact power of two. The bias is small for values of `maxval - minval` -- significantly smaller than the range of the output (either `2^32` or -- `2^64`). randomUniformInt :: (TensorType t, OneOf '[Int32, Int64] t, TensorType tout, OneOf '[Int32, Int64] tout) => Tensor v1 t -> Tensor v2 tout -> Tensor v3 tout -> Tensor Value tout -- | Stops gradient computation. -- -- When executed in a graph, this op outputs its input tensor as-is. -- -- When building ops to compute gradients, this op prevents the -- contribution of its inputs to be taken into account. Normally, the -- gradient generator adds ops to a graph to compute the derivatives of a -- specified loss by recursively finding out inputs that -- contributed to its computation. If you insert this op in the graph it -- inputs are masked from the gradient generator. They are not taken into -- account for computing gradients. -- -- This is useful any time you want to compute a value with TensorFlow -- but need to pretend that the value was a constant. Some examples -- include: -- -- stopGradient :: (TensorType t) => Tensor v1 t -> Tensor Value t -- | Performs average pooling on the input. -- -- Each entry in output is the mean of the corresponding size -- ksize window in value. avgPool :: (TensorType t, OneOf '[Word16, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | A Reader that outputs the entire contents of a file as a value. -- -- To use, enqueue filenames in a Queue. The output of ReaderRead will be -- a filename (key) and the contents of that file (value). wholeFileReader :: Tensor Value ByteString -- | Forwards `data` to the output port determined by pred. -- -- If pred is true, the `data` input is forwarded to -- output_true. Otherwise, the data goes to -- output_false. -- -- See also RefSwitch and Merge. switch :: (TensorType t) => Tensor v1 t -> Tensor v2 Bool -> (Tensor Value t, Tensor Value t) -- | Outputs random values from a normal distribution. -- -- The generated values will have mean 0 and standard deviation 1. randomStandardNormal :: (TensorType t, OneOf '[Int32, Int64] t, TensorType dtype, OneOf '[Word16, Double, Float] dtype) => Tensor v1 t -> Tensor Value dtype -- | Computes sigmoid of x element-wise. -- -- Specifically, `y = 1 / (1 + exp(-x))`. sigmoid :: (TensorType t, OneOf '[Complex Double, Complex Float, Word16, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Generate a single randomly distorted bounding box for an image. -- -- Bounding box annotations are often supplied in addition to -- ground-truth labels in image recognition or object localization tasks. -- A common technique for training such a system is to randomly distort -- an image while preserving its content, i.e. *data augmentation*. This -- Op outputs a randomly distorted localization of an object, i.e. -- bounding box, given an image_size, bounding_boxes -- and a series of constraints. -- -- The output of this Op is a single bounding box that may be used to -- crop the original image. The output is returned as 3 tensors: -- begin, size and bboxes. The first 2 tensors -- can be fed directly into `tf.slice` to crop the image. The latter may -- be supplied to `tf.image.draw_bounding_box` to visualize what the -- bounding box looks like. -- -- Bounding boxes are supplied and returned as `[y_min, x_min, y_max, -- x_max]`. The bounding box coordinates are floats in `[0.0, 1.0]` -- relative to the width and height of the underlying image. -- -- For example, -- -- # Generate a single distorted bounding box. begin, size, bbox_for_draw -- = tf.image.sample_distorted_bounding_box( tf.shape(image), -- bounding_boxes=bounding_boxes) -- -- # Draw the bounding box in an image summary. image_with_box = -- tf.image.draw_bounding_boxes(tf.expand_dims(image, 0), bbox_for_draw) -- tf.image_summary(images_with_box, image_with_box) -- -- # Employ the bounding box to distort the image. distorted_image = -- tf.slice(image, begin, size) -- -- Note that if no bounding box information is available, setting -- `use_image_if_no_bounding_boxes = true` will assume there is a single -- implicit bounding box covering the whole image. If -- use_image_if_no_bounding_boxes is false and no bounding boxes -- are supplied, an error is raised. sampleDistortedBoundingBox :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word8] t) => Tensor v1 t -> Tensor v2 Float -> (Tensor Value t, Tensor Value t, Tensor Value Float) -- | Returns the truth value of (x > y) element-wise. -- -- greater :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value Bool -- | Makes its input available to the next iteration. refNextIteration :: (TensorType t) => Tensor v1 t -> Tensor Value t -- | SpaceToDepth for tensors of type T. -- -- Rearranges blocks of spatial data, into depth. More specifically, this -- op outputs a copy of the input tensor where values from the -- height and width dimensions are moved to the -- depth dimension. The attr block_size indicates the -- input block size and how the data is moved. -- -- -- -- That is, assuming the input is in the shape: `[batch, height, width, -- depth]`, the shape of the output will be: `[batch, -- heightblock_size, widthblock_size, -- depth*block_size*block_size]` -- -- This operation requires that the input tensor be of rank 4, and that -- block_size be >=1 and a divisor of both the input -- height and width. -- -- This operation is useful for resizing the activations between -- convolutions (but keeping all data), e.g. instead of pooling. It is -- also useful for training purely convolutional models. -- -- For example, given this input of shape `[1, 2, 2, 1]`, and block_size -- of 2: -- -- ```prettyprint x = [[[[1], [2]], [[3], [4]]]] ``` -- -- This operation will output a tensor of shape `[1, 1, 1, 4]`: -- -- ```prettyprint [[[[1, 2, 3, 4]]]] ``` -- -- Here, the input has a batch of 1 and each batch element has shape `[2, -- 2, 1]`, the corresponding output will have a single element (i.e. -- width and height are both 1) and will have a depth of 4 channels (1 * -- block_size * block_size). The output element shape is `[1, 1, 4]`. -- -- For an input tensor with larger depth, here of shape `[1, 2, 2, 3]`, -- e.g. -- -- ```prettyprint x = [[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, -- 12]]]] ``` -- -- This operation, for block_size of 2, will return the following tensor -- of shape `[1, 1, 1, 12]` -- -- ```prettyprint [[[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]]] ``` -- -- Similarly, for the following input of shape `[1 4 4 1]`, and a block -- size of 2: -- -- ```prettyprint x = [[[[1], [2], [5], [6]], [[3], [4], [7], [8]], [[9], -- [10], [13], [14]], [[11], [12], [15], [16]]]] ``` -- -- the operator will return the following tensor of shape `[1 2 2 4]`: -- -- ```prettyprint x = [[[[1, 2, 3, 4], [5, 6, 7, 8]], [[9, 10, 11, 12], -- [13, 14, 15, 16]]]] ``` spaceToDepth :: (TensorType t) => Int64 -> Tensor v1 t -> Tensor Value t -- | Does nothing. Serves as a control trigger for scheduling. -- -- Only useful as a placeholder for control edges. controlTrigger :: ControlNode -- | Divides a variable reference by sparse updates. -- -- This operation computes -- -- # Scalar indices ref[indices, ...] /= updates[...] -- -- # Vector indices (for each i) ref[indices[i], ...] /= updates[i, ...] -- -- # High rank indices (for each i, ..., j) ref[indices[i, ..., j], ...] -- /= updates[i, ..., j, ...] -- -- This operation outputs ref after the update is done. This -- makes it easier to chain operations that need to use the reset value. -- -- Duplicate entries are handled correctly: if multiple indices -- reference the same location, their contributions divide. -- -- Requires `updates.shape = indices.shape + ref.shape[1:]`. scatterDiv :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t, TensorType tindices, OneOf '[Int32, Int64] tindices) => Tensor v1 t -> Tensor v2 tindices -> Tensor v3 t -> Tensor Value t -- | Copy Op. -- -- Performs CPU-to-CPU or GPU-to-GPU deep-copying of tensor, depending on -- the device on which the tensor is allocated. -- -- Unlike the CopyHost Op, this op does not have HostMemory constraint on -- its input or output. copy :: (TensorType t) => Tensor v1 t -> Tensor Value t -- | Computes the gradient of the crop_and_resize op wrt the input boxes -- tensor. cropAndResizeGradBoxes :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 Float -> Tensor v2 t -> Tensor v3 Float -> Tensor v4 Int32 -> Tensor Value Float -- | Computes the mean along sparse segments of a tensor. -- -- Read the section on Segmentation for an explanation of -- segments. -- -- Like SegmentMean, but segment_ids can have rank less -- than `data`'s first dimension, selecting a subset of dimension 0, -- specified by indices. sparseSegmentMean :: (TensorType t, OneOf '[Double, Float] t, TensorType tidx, OneOf '[Int32, Int64] tidx) => Tensor v1 t -> Tensor v2 tidx -> Tensor v3 Int32 -> Tensor Value t -- | Update ref by assigning value to it. -- -- This operation outputs "ref" after the assignment is done. This makes -- it easier to chain operations that need to use the reset value. assign :: (TensorType t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Restores a tensor from checkpoint files. -- -- Reads a tensor stored in one or several files. If there are several -- files (for instance because a tensor was saved as slices), -- file_pattern may contain wildcard symbols (* and -- ?) in the filename portion only, not in the directory -- portion. -- -- If a file_pattern matches several files, -- preferred_shard can be used to hint in which file the -- requested tensor is likely to be found. This op will first open the -- file at index preferred_shard in the list of matching files -- and try to restore tensors from that file. Only if some tensors or -- tensor slices are not found in that first file, then the Op opens all -- the files. Setting preferred_shard to match the value passed -- as the shard input of a matching Save Op may speed -- up Restore. This attribute only affects performance, not correctness. -- The default value -1 means files are processed in order. -- -- See also RestoreSlice. restore :: (TensorType dt) => Tensor v1 ByteString -> Tensor v2 ByteString -> Tensor Value dt -- | Computes gradients of the maxpooling function. maxPoolGradWithArgmax :: (TensorType t, OneOf '[Word16, Float] t, TensorType targmax, OneOf '[Int32, Int64] targmax) => Tensor v1 t -> Tensor v2 t -> Tensor v3 targmax -> Tensor Value t -- | Checks a tensor for NaN and Inf values. -- -- When run, reports an InvalidArgument error if tensor -- has any values that are not a number (NaN) or infinity (Inf). -- Otherwise, passes tensor as-is. checkNumerics :: (TensorType t, OneOf '[Word16, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Returns a tensor of zeros with the same shape and type as x. zerosLike :: (TensorType t) => Tensor v1 t -> Tensor Value t -- | Reads and outputs the entire contents of the input filename. readFile :: Tensor v1 ByteString -> Tensor Value ByteString -- | Shuffle dimensions of x according to a permutation. -- -- The output y has the same rank as x. The shapes of -- x and y satisfy: `y.shape[i] == x.shape[perm[i]] for -- i in [0, 1, ..., rank(x) - 1]` transpose :: (TensorType t, TensorType tperm, OneOf '[Int32, Int64] tperm) => Tensor v1 t -> Tensor v2 tperm -> Tensor Value t -- | Transforms a serialized tensorflow.TensorProto proto into a Tensor. parseTensor :: (TensorType out_type) => Tensor v1 ByteString -> Tensor Value out_type -- | Computes acos of x element-wise. acos :: (TensorType t, OneOf '[Complex Double, Complex Float, Int32, Int64, Word16, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Bitcasts a tensor from one type to another without copying data. -- -- Given a tensor input, this operation returns a tensor that -- has the same buffer data as input with datatype `type`. -- -- If the input datatype T is larger than the output datatype -- `type` then the shape changes from [...] to [..., -- sizeof(T)/sizeof(`type`)]. -- -- If T is smaller than `type`, the operator requires that the -- rightmost dimension be equal to sizeof(`type`)/sizeof(T). The -- shape then goes from [..., sizeof(`type`)/sizeof(T)] to -- [...]. -- -- bitcast :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t, TensorType type', OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] type') => Tensor v1 t -> Tensor Value type' -- | Replaces the contents of the table with the specified keys and values. -- -- The tensor keys must be of the same type as the keys of the -- table. The tensor values must be of the type of the table -- values. lookupTableImport :: (TensorType tin, TensorType tout) => Tensor v1 ByteString -> Tensor v2 tin -> Tensor v3 tout -> ControlNode -- | The backward operation for BiasAdd on the "bias" tensor. -- -- It accumulates all the values from out_backprop into the feature -- dimension. For NHWC data format, the feature dimension is the last. -- For NCHW data format, the feature dimension is the third-to-last. biasAddGrad :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor Value t batchSelfAdjointEig :: (TensorType t, OneOf '[Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Computes the product of elements across dimensions of a tensor. -- -- Reduces input along the dimensions given in -- reduction_indices. Unless keep_dims is true, the -- rank of the tensor is reduced by 1 for each entry in -- reduction_indices. If keep_dims is true, the reduced -- dimensions are retained with length 1. prod :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t, TensorType tidx, OneOf '[Int32, Int64] tidx) => Tensor v1 t -> Tensor v2 tidx -> Tensor Value t -- | Resize images to size using bilinear interpolation. -- -- Input images can be of different types but output images are always -- float. resizeBilinear :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 Int32 -> Tensor Value Float -- | Unpack the data from the input value into TensorArray elements. -- -- -- -- Instead of this op, use TensorArrayScatter with `indices = -- RangeOp(0, SizeOp(value)[0])`. tensorArrayUnpack :: (TensorType t) => Tensor v1 ByteString -> Tensor v2 t -> Tensor v3 Float -> Tensor Value Float batchMatrixDeterminant :: (TensorType t, OneOf '[Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Computes the sum of elements across dimensions of a tensor. -- -- Reduces input along the dimensions given in -- reduction_indices. Unless keep_dims is true, the -- rank of the tensor is reduced by 1 for each entry in -- reduction_indices. If keep_dims is true, the reduced -- dimensions are retained with length 1. sum :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t, TensorType tidx, OneOf '[Int32, Int64] tidx) => Tensor v1 t -> Tensor v2 tidx -> Tensor Value t -- | Compute the inverse 2-dimensional discrete Fourier Transform over the -- inner-most -- -- 2 dimensions of input. iFFT2D :: Tensor v1 (Complex Float) -> Tensor Value (Complex Float) -- | Creates a tensor filled with a scalar value. -- -- This operation creates a tensor of shape dims and fills it -- with value. -- -- For example: -- -- ```prettyprint # Output tensor has shape [2, 3]. fill([2, 3], 9) -- ==> [[9, 9, 9] [9, 9, 9]] ``` fill :: (TensorType t) => Tensor v1 Int32 -> Tensor v2 t -> Tensor Value t -- | Generates labels for candidate sampling with a learned unigram -- distribution. -- -- A unigram sampler could use a fixed unigram distribution read from a -- file or passed in as an in-memory array instead of building up the -- distribution from data on the fly. There is also an option to skew the -- distribution by applying a distortion power to the weights. -- -- The vocabulary file should be in CSV-like format, with the last field -- being the weight associated with the word. -- -- For each batch, this op picks a single set of sampled candidate -- labels. -- -- The advantages of sampling candidates per-batch are simplicity and the -- possibility of efficient dense matrix multiplication. The disadvantage -- is that the sampled candidates must be chosen independently of the -- context and of the true labels. fixedUnigramCandidateSampler :: Int64 -> Int64 -> Int64 -> Bool -> Tensor v1 Int64 -> (Tensor Value Int64, Tensor Value Float, Tensor Value Float) -- | Computes the grayscale dilation of 4-D input and 3-D -- filter tensors. -- -- The input tensor has shape `[batch, in_height, in_width, -- depth]` and the filter tensor has shape `[filter_height, -- filter_width, depth]`, i.e., each input channel is processed -- independently of the others with its own structuring function. The -- output tensor has shape `[batch, out_height, out_width, -- depth]`. The spatial dimensions of the output tensor depend on the -- padding algorithm. We currently only support the default -- NHWC data_format. -- -- In detail, the grayscale morphological 2-D dilation is the max-sum -- correlation (for consistency with conv2d, we use unmirrored -- filters): -- -- output[b, y, x, c] = max_{dy, dx} input[b, strides[1] * y + rates[1] * -- dy, strides[2] * x + rates[2] * dx, c] + filter[dy, dx, c] -- -- Max-pooling is a special case when the filter has size equal to the -- pooling kernel size and contains all zeros. -- -- Note on duality: The dilation of input by the filter -- is equal to the negation of the erosion of `-input` by the reflected -- filter. dilation2D :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Compute the polygamma function \(psi^{(n)}(x)\). -- -- The polygamma function is defined as: -- -- ``` psi^{(n)}(x) = frac{d^n}{dx^n} psi(x) ``` where \(psi(x)\) is the -- digamma function. polygamma :: (TensorType t, OneOf '[Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Return the same ref tensor as the input ref tensor. refIdentity :: (TensorType t) => Tensor v1 t -> Tensor Value t -- | PNG-encode an image. -- -- image is a 3-D uint8 or uint16 Tensor of shape `[height, -- width, channels]` where channels is: -- -- -- -- The ZLIB compression level, compression, can be -1 for the -- PNG-encoder default or a value from 0 to 9. 9 is the highest -- compression level, generating the smallest output, but is slower. encodePng :: (TensorType t, OneOf '[Word16, Word8] t) => Tensor v1 t -> Tensor Value ByteString -- | Updates the table to associates keys with values. -- -- The tensor keys must be of the same type as the keys of the -- table. The tensor values must be of the type of the table -- values. lookupTableInsert :: (TensorType tin, TensorType tout) => Tensor v1 ByteString -> Tensor v2 tin -> Tensor v3 tout -> ControlNode batchIFFT2D :: Tensor v1 (Complex Float) -> Tensor Value (Complex Float) -- | Finds unique elements in a 1-D tensor. -- -- This operation returns a tensor y containing all of the -- unique elements of x sorted in the same order that they occur -- in x. This operation also returns a tensor idx the -- same size as x that contains the index of each value of -- x in the unique output y. Finally, it returns a -- third tensor count that contains the count of each element of -- y in x. In other words: -- -- `y[idx[i]] = x[i] for i in [0, 1,...,rank(x) - 1]` -- -- For example: -- -- ```prettyprint # tensor x is [1, 1, 2, 4, 4, 4, 7, 8, 8] y, -- idx, count = unique_with_counts(x) y ==> [1, 2, 4, 7, 8] idx ==> -- [0, 0, 1, 2, 2, 2, 3, 4, 4] count ==> [2, 1, 3, 1, 2] ``` uniqueWithCounts :: (TensorType t, TensorType out_idx, OneOf '[Int32, Int64] out_idx) => Tensor v1 t -> (Tensor Value t, Tensor Value out_idx, Tensor Value out_idx) -- | Gather values or slices from params according to -- indices. -- -- params is a Tensor of rank R and indices is -- a Tensor of rank M. -- -- indices must be integer tensor, containing indices into -- params. It must be shape `[d_0, ..., d_N, R]` where `0 < R -- <= M`. -- -- The innermost dimension of indices (with length R) -- corresponds to indices into elements (if `R = M`) or slices (if `R -- < M`) along the Nth dimension of params. -- -- Produces an output tensor with shape -- -- -- -- Some examples below. -- -- Simple indexing into a matrix: -- -- indices = [[0, 0], [1, 1]] params = [[a, b], -- [c, d]] output = [a, d] -- -- Slice indexing into a matrix: -- -- indices = [[1], [0]] params = [[a, b], [c, -- d]] output = [[c, d], [a, -- b]] -- -- Indexing into a 3-tensor: -- -- indices = [[1]] params = [[[a0, b0], [c0, -- d0]], [[a1, b1], [c1, -- d1]]] output = [[[a1, b1], [c1, -- d1]]] -- -- indices = [[0, 1], [1, 0]] params = [[[a0, b0], -- [c0, d0]], [[a1, b1], -- [c1, d1]]] output = [[c0, d0], -- [a1, b1]] -- -- indices = [[0, 0, 1], [1, 0, 1]] params = [[[a0, -- b0], [c0, d0]], [[a1, -- b1], [c1, d1]]] output = [b0, -- b1] -- -- Batched indexing into a matrix: -- -- indices = [[[0, 0]], [[0, 1]]] params = [[a, b], -- [c, d]] output = [[a], [b]] -- -- Batched slice indexing into a matrix: -- -- indices = [[[1]], [[0]]] params = [[a, b], -- [c, d]] output = [[[c, d]], -- [[a, b]]] -- -- Batched indexing into a 3-tensor: -- -- indices = [[[1]], [[0]]] params = [[[a0, b0], -- [c0, d0]], [[a1, b1], -- [c1, d1]]] output = [[[[a1, b1], -- [c1, d1]]], [[[a0, b0], -- [c0, d0]]]] -- -- indices = [[[0, 1], [1, 0]], [[0, 0], [1, 1]]] params = -- [[[a0, b0], [c0, d0]], -- [[a1, b1], [c1, d1]]] output = -- [[[c0, d0], [a1, b1]], -- [[a0, b0], [c1, d1]]] -- -- indices = [[[0, 0, 1], [1, 0, 1]], [[0, 1, 1], [1, 1, 0]]] params = -- [[[a0, b0], [c0, d0]], -- [[a1, b1], [c1, d1]]] output = -- [[b0, b1], [d0, c1]] gatherNd :: (TensorType tindices, OneOf '[Int32, Int64] tindices, TensorType tparams) => Tensor v1 tparams -> Tensor v2 tindices -> Tensor Value tparams -- | Read an element from the TensorArray into output value. tensorArrayRead :: (TensorType dtype) => Tensor v1 ByteString -> Tensor v2 Int32 -> Tensor v3 Float -> Tensor Value dtype -- | Returns up to num_records (key, value) pairs produced by a -- Reader. -- -- Will dequeue from the input queue if necessary (e.g. when the Reader -- needs to start reading from a new file since it has finished with the -- previous file). It may return less than num_records even -- before the last batch. readerReadUpTo :: Tensor v1 ByteString -> Tensor v2 ByteString -> Tensor v3 Int64 -> (Tensor Value ByteString, Tensor Value ByteString) -- | Compute the regularized incomplete beta integral \(I_x(a, b)\). -- -- The regularized incomplete beta integral is defined as: -- -- ``` I_x(a, b) = frac{B(x; a, b)}{B(a, b)} ``` where -- -- ``` B(x; a, b) = int_0^x t^{a-1} (1 - t)^{b-1} dt ``` -- -- is the incomplete beta function and \(B(a, b)\) is the *complete* beta -- function. betainc :: (TensorType t, OneOf '[Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor v3 t -> Tensor Value t batchMatrixBandPart :: (TensorType t) => Tensor v1 t -> Tensor v2 Int64 -> Tensor v3 Int64 -> Tensor Value t -- | Computes the gradients of depthwise convolution with respect to the -- input. depthwiseConv2dNativeBackpropInput :: (TensorType t, OneOf '[Double, Float] t) => Tensor v1 Int32 -> Tensor v2 t -> Tensor v3 t -> Tensor Value t -- | Forwards the indexth element of inputs to -- output. refSelect :: (TensorType t) => Tensor v1 Int32 -> [Tensor v2 t] -> Tensor Value t -- | Exits the current frame to its parent frame. -- -- Exit makes its input `data` available to the parent frame. exit :: (TensorType t) => Tensor v1 t -> Tensor Value t -- | Looks up keys in a table, outputs the corresponding values. -- -- The tensor keys must of the same type as the keys of the -- table. The output values is of the type of the table values. -- -- The scalar default_value is the value output for keys not -- present in the table. It must also be of the same type as the table -- values. lookupTableFind :: (TensorType tin, TensorType tout) => Tensor v1 ByteString -> Tensor v2 tin -> Tensor v3 tout -> Tensor Value tout -- | Removes dimensions of size 1 from the shape of a tensor. -- -- Given a tensor input, this operation returns a tensor of the -- same type with all dimensions of size 1 removed. If you don't want to -- remove all size 1 dimensions, you can remove specific size 1 -- dimensions by specifying squeeze_dims. -- -- For example: -- -- ```prettyprint # t is a tensor of shape [1, 2, 1, 3, 1, 1] -- shape(squeeze(t)) ==> [2, 3] ``` -- -- Or, to remove specific size 1 dimensions: -- -- ```prettyprint # t is a tensor of shape [1, 2, 1, 3, 1, 1] -- shape(squeeze(t, [2, 4])) ==> [1, 2, 3, 1] ``` squeeze :: (TensorType t) => Tensor v1 t -> Tensor Value t -- | Computes the mean of elements across dimensions of a tensor. -- -- Reduces input along the dimensions given in -- reduction_indices. Unless keep_dims is true, the -- rank of the tensor is reduced by 1 for each entry in -- reduction_indices. If keep_dims is true, the reduced -- dimensions are retained with length 1. mean :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t, TensorType tidx, OneOf '[Int32, Int64] tidx) => Tensor v1 t -> Tensor v2 tidx -> Tensor Value t -- | SpaceToBatch for N-D tensors of type T. -- -- This operation divides "spatial" dimensions `[1, ..., M]` of the input -- into a grid of blocks of shape block_shape, and interleaves -- these blocks with the "batch" dimension (0) such that in the output, -- the spatial dimensions `[1, ..., M]` correspond to the position within -- the grid, and the batch dimension combines both the position within a -- spatial block and the original batch position. Prior to division into -- blocks, the spatial dimensions of the input are optionally zero padded -- according to paddings. See below for a precise description. spaceToBatchND :: (TensorType t, TensorType tblock_shape, OneOf '[Int32, Int64] tblock_shape, TensorType tpaddings, OneOf '[Int32, Int64] tpaddings) => Tensor v1 t -> Tensor v2 tblock_shape -> Tensor v3 tpaddings -> Tensor Value t -- | SpaceToBatch for 4-D tensors of type T. -- -- This is a legacy version of the more general SpaceToBatchND. -- -- Zero-pads and then rearranges (permutes) blocks of spatial data into -- batch. More specifically, this op outputs a copy of the input tensor -- where values from the height and width dimensions -- are moved to the batch dimension. After the zero-padding, -- both height and width of the input must be divisible -- by the block size. spaceToBatch :: (TensorType t, TensorType tpaddings, OneOf '[Int32, Int64] tpaddings) => Int64 -> Tensor v1 t -> Tensor v2 tpaddings -> Tensor Value t -- | Performs greedy decoding on the logits given in inputs. -- -- A note about the attribute merge_repeated: if enabled, when -- consecutive logits' maximum indices are the same, only the first of -- these is emitted. Labeling the blank *, the sequence "A B B * B -- B" becomes "A B" if merge_repeated = True and "A B B B B" if -- merge_repeated = False. -- -- Regardless of the value of merge_repeated, if the maximum index of a -- given time and batch corresponds to the blank, index `(num_classes - -- 1)`, no new element is emitted. cTCGreedyDecoder :: Tensor v1 Float -> Tensor v2 Int32 -> (Tensor Value Int64, Tensor Value Int64, Tensor Value Int64, Tensor Value Float) -- | BatchToSpace for N-D tensors of type T. -- -- This operation reshapes the "batch" dimension 0 into `M + 1` -- dimensions of shape `block_shape + [batch]`, interleaves these blocks -- back into the grid defined by the spatial dimensions `[1, ..., M]`, to -- obtain a result with the same rank as the input. The spatial -- dimensions of this intermediate result are then optionally cropped -- according to crops to produce the output. This is the reverse -- of SpaceToBatch. See below for a precise description. batchToSpaceND :: (TensorType t, TensorType tblock_shape, OneOf '[Int32, Int64] tblock_shape, TensorType tcrops, OneOf '[Int32, Int64] tcrops) => Tensor v1 t -> Tensor v2 tblock_shape -> Tensor v3 tcrops -> Tensor Value t -- | Packs a list of N rank-R tensors into one -- rank-`(R+1)` tensor. -- -- Packs the N tensors in values into a tensor with -- rank one higher than each tensor in values, by packing them -- along the axis dimension. Given a list of tensors of shape -- `(A, B, C)`; -- -- if `axis == 0` then the output tensor will have the shape -- `(N, A, B, C)`. if `axis == 1` then the output tensor will -- have the shape `(A, N, B, C)`. Etc. -- -- For example: -- -- ```prettyprint # x is [1, 4] # y is [2, 5] # -- z is [3, 6] pack([x, y, z]) => [[1, 4], [2, 5], [3, 6]] # -- Pack along first dim. pack([x, y, z], axis=1) => [[1, 2, 3], [4, 5, -- 6]] ``` -- -- This is the opposite of unpack. pack :: (TensorType t) => [Tensor v1 t] -> Tensor Value t -- | Returns a one-hot tensor. -- -- The locations represented by indices in indices take value -- on_value, while all other locations take value -- off_value. -- -- If the input indices is rank N, the output will have -- rank `N+1`, The new axis is created at dimension axis -- (default: the new axis is appended at the end). -- -- If indices is a scalar the output shape will be a vector of -- length depth. -- -- If indices is a vector of length features, the -- output shape will be: ``` features x depth if axis == -1 depth x -- features if axis == 0 ``` -- -- If indices is a matrix (batch) with shape `[batch, -- features]`, the output shape will be: ``` batch x features x depth if -- axis == -1 batch x depth x features if axis == 1 depth x batch x -- features if axis == 0 ``` -- -- Examples ========= -- -- Suppose that -- -- ``` indices = [0, 2, -1, 1] depth = 3 on_value = 5.0 off_value = 0.0 -- axis = -1 ``` -- -- Then output is `[4 x 3]`: -- -- ```output = [5.0 0.0 0.0] // one_hot(0) [0.0 0.0 5.0] // one_hot(2) -- [0.0 0.0 0.0] // one_hot(-1) [0.0 5.0 0.0] // one_hot(1) ``` -- -- Suppose that -- -- ``` indices = [0, 2, -1, 1] depth = 3 on_value = 0.0 off_value = 3.0 -- axis = 0 ``` -- -- Then output is `[3 x 4]`: -- -- ```output = [0.0 3.0 3.0 3.0] [3.0 3.0 3.0 0.0] [3.0 3.0 3.0 3.0] [3.0 -- 0.0 3.0 3.0] // ^ one_hot(0) // ^ one_hot(2) // ^ one_hot(-1) // ^ -- one_hot(1) ``` Suppose that -- -- ``` indices = [[0, 2], [1, -1]] depth = 3 on_value = 1.0 off_value = -- 0.0 axis = -1 ``` -- -- Then output is `[2 x 2 x 3]`: -- -- ```output = [ [1.0, 0.0, 0.0] // one_hot(0) [0.0, 0.0, 1.0] // -- one_hot(2) ][ [0.0, 1.0, 0.0] // one_hot(1) [0.0, 0.0, 0.0] // -- one_hot(-1) ]``` oneHot :: (TensorType t, TensorType tI, OneOf '[Int32, Int64, Word8] tI) => Tensor v1 tI -> Tensor v2 Int32 -> Tensor v3 t -> Tensor v4 t -> Tensor Value t -- | Return the reduction indices for computing gradients of s0 op s1 with -- broadcast. -- -- This is typically used by gradient computations for a broadcasting -- operation. broadcastGradientArgs :: (TensorType t, OneOf '[Int32, Int64] t) => Tensor v1 t -> Tensor v2 t -> (Tensor Value t, Tensor Value t) -- | Returns a batched matrix tensor with new batched diagonal values. -- -- Given input and diagonal, this operation returns a -- tensor with the same shape and values as input, except for -- the diagonals of the innermost matrices. These will be overwritten by -- the values in diagonal. The batched matrices must be square. -- -- The output is computed as follows: -- -- Assume input has `k+1` dimensions `[I, J, K, ..., N, N]` and -- diagonal has k dimensions `[I, J, K, ..., N]`. Then -- the output is a tensor of rank `k+1` with dimensions [I, J, K, ..., N, -- N]` where: -- -- matrixSetDiag :: (TensorType t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Update '*var' according to the RMSProp algorithm. -- -- Note that in dense implement of this algorithm, ms and mom will update -- even if the grad is zero, but in this sparse implement, ms and mom -- will not update in iterations the grad is zero. -- -- mean_square = decay * mean_square + (1-decay) * gradient ** 2 Delta = -- learning_rate * gradient / sqrt(mean_square + epsilon) -- -- ms <- rho * ms_{t-1} + (1-rho) * grad * grad mom <- momentum * -- mom_{t-1} + lr * grad / sqrt(ms + epsilon) var <- var - mom applyRMSProp :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor v3 t -> Tensor v4 t -> Tensor v5 t -> Tensor v6 t -> Tensor v7 t -> Tensor v8 t -> Tensor Value t -- | Returns a constant tensor. const :: (TensorType dtype) => Tensor Value dtype -- | Creates or finds a child frame, and makes `data` available to the -- child frame. -- -- This op is used together with Exit to create loops in the -- graph. The unique frame_name is used by the Executor -- to identify frames. If is_constant is true, output -- is a constant in the child frame; otherwise it may be changed in the -- child frame. At most parallel_iterations iterations are run -- in parallel in the child frame. enter :: (TensorType t) => Tensor v1 t -> Tensor Value t -- | Debug Identity Op. -- -- Provides an identity mapping of the non-Ref type input tensor for -- debugging. debugIdentity :: (TensorType t) => Tensor v1 t -> Tensor Value t -- | Debug NaN Value Counter Op -- -- Counts number of NaNs in the input tensor, for debugging. debugNanCount :: (TensorType t) => Tensor v1 t -> Tensor Value Int64 -- | Batch normalization. -- -- This op is deprecated. Prefer `tf.nn.batch_normalization`. batchNormWithGlobalNormalization :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Bool -> Float -> Tensor v1 t -> Tensor v2 t -> Tensor v3 t -> Tensor v4 t -> Tensor v5 t -> Tensor Value t batchMatrixDiag :: (TensorType t) => Tensor v1 t -> Tensor Value t -- | Unpacks a given dimension of a rank-R tensor into -- num rank-`(R-1)` tensors. -- -- Unpacks num tensors from value by chipping it along -- the axis dimension. For example, given a tensor of shape `(A, -- B, C, D)`; -- -- If `axis == 0` then the i'th tensor in output is the slice -- `value[i, :, :, :]` and each tensor in output will have shape -- `(B, C, D)`. (Note that the dimension unpacked along is gone, unlike -- split). -- -- If `axis == 1` then the i'th tensor in output is the slice -- `value[:, i, :, :]` and each tensor in output will have shape -- `(A, C, D)`. Etc. -- -- This is the opposite of pack. unpack :: (TensorType t) => Int64 -> Tensor v1 t -> [Tensor Value t] -- | Split a SparseTensor into num_split tensors along -- one dimension. -- -- If the `shape[split_dim]` is not an integer multiple of -- num_split. Slices `[0 : shape[split_dim] % num_split]` gets -- one extra dimension. For example, if `split_dim = 1` and `num_split = -- 2` and the input is -- -- input_tensor = shape = [2, 7] [ a d e ] [b c ] -- -- Graphically the output tensors are: -- -- output_tensor[0] = shape = [2, 4] [ a ] [b c ] -- -- output_tensor[1] = shape = [2, 3] [ d e ] [ ] sparseSplit :: (TensorType t) => Int64 -> Tensor v1 Int64 -> Tensor v2 Int64 -> Tensor v3 t -> Tensor v4 Int64 -> ([Tensor Value Int64], [Tensor Value t], [Tensor Value Int64]) -- | Pads a tensor with mirrored values. -- -- This operation pads a input with mirrored values according to -- the paddings you specify. paddings is an integer -- tensor with shape `[n, 2]`, where n is the rank of input. For -- each dimension D of input, `paddings[D, 0]` indicates how -- many values to add before the contents of input in that -- dimension, and `paddings[D, 1]` indicates how many values to add after -- the contents of input in that dimension. Both `paddings[D, -- 0]` and `paddings[D, 1]` must be no greater than `input.dim_size(D)` -- (or `input.dim_size(D) - 1`) if copy_border is true (if -- false, respectively). -- -- The padded size of each dimension D of the output is: -- -- `paddings(D, 0) + input.dim_size(D) + paddings(D, 1)` -- -- For example: -- -- ```prettyprint # t is [[1, 2, 3], [4, 5, 6]]. # -- paddings is [[1, 1]], [2, 2]]. # mode is SYMMETRIC. -- # rank of t is 2. pad(t, paddings) ==> [[2, 1, 1, 2, 3, 3, -- 2] [2, 1, 1, 2, 3, 3, 2] [5, 4, 4, 5, 6, 6, 5] [5, 4, 4, 5, 6, 6, 5]] -- ``` mirrorPad :: (TensorType t, TensorType tpaddings, OneOf '[Int32, Int64] tpaddings) => Tensor v1 t -> Tensor v2 tpaddings -> Tensor Value t batchMatrixDiagPart :: (TensorType t) => Tensor v1 t -> Tensor Value t -- | Computes gradient of the FractionalMaxPool function. fractionalMaxPoolGrad :: (TensorType t, OneOf '[Int32, Int64, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor v3 t -> Tensor v4 Int64 -> Tensor v5 Int64 -> Tensor Value t -- | Returns the set of files matching a pattern. -- -- Note that this routine only supports wildcard characters in the -- basename portion of the pattern, not in the directory portion. matchingFiles :: Tensor v1 ByteString -> Tensor Value ByteString -- | Constructs a tensor by tiling a given tensor. -- -- This operation creates a new tensor by replicating input -- multiples times. The output tensor's i'th dimension has -- `input.dims(i) * multiples[i]` elements, and the values of -- input are replicated `multiples[i]` times along the -- ith dimension. For example, tiling `[a b c d]` by `[2]` -- produces `[a b c d a b c d]`. tile :: (TensorType t, TensorType tmultiples, OneOf '[Int32, Int64] tmultiples) => Tensor v1 t -> Tensor v2 tmultiples -> Tensor Value t -- | Returns the element-wise min of two SparseTensors. -- -- Assumes the two SparseTensors have the same shape, i.e., no -- broadcasting. sparseSparseMinimum :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 Int64 -> Tensor v2 t -> Tensor v3 Int64 -> Tensor v4 Int64 -> Tensor v5 t -> Tensor v6 Int64 -> (Tensor Value Int64, Tensor Value t) -- | Generates labels for candidate sampling with a learned unigram -- distribution. -- -- See explanations of candidate sampling and the data formats at -- go/candidate-sampling. -- -- For each batch, this op picks a single set of sampled candidate -- labels. -- -- The advantages of sampling candidates per-batch are simplicity and the -- possibility of efficient dense matrix multiplication. The disadvantage -- is that the sampled candidates must be chosen independently of the -- context and of the true labels. allCandidateSampler :: Int64 -> Int64 -> Bool -> Tensor v1 Int64 -> (Tensor Value Int64, Tensor Value Float, Tensor Value Float) -- | Forwards the ref tensor `data` to the output port determined by -- pred. -- -- If pred is true, the `data` input is forwarded to -- output_true. Otherwise, the data goes to -- output_false. -- -- See also Switch and Merge. refSwitch :: (TensorType t) => Tensor v1 t -> Tensor v2 Bool -> (Tensor Value t, Tensor Value t) -- | Merges summaries. -- -- This op creates a `Summary` protocol buffer that contains the -- union of all the values in the input summaries. -- -- When the Op is run, it reports an InvalidArgument error if -- multiple values in the summaries to merge use the same tag. mergeSummary :: [Tensor v1 ByteString] -> Tensor Value ByteString -- | Returns the truth value of NOT x element-wise. logicalNot :: Tensor v1 Bool -> Tensor Value Bool -- | Gradients for Local Response Normalization. lRNGrad :: (TensorType t, OneOf '[Word16, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor v3 t -> Tensor Value t -- | Converts each string in the input Tensor to the specified numeric -- type. -- -- (Note that int32 overflow results in an error while float overflow -- results in a rounded value.) stringToNumber :: (TensorType out_type, OneOf '[Int32, Float] out_type) => Tensor v1 ByteString -> Tensor Value out_type -- | Multiply matrix "a" by matrix "b". -- -- The inputs must be two-dimensional matrices and the inner dimension of -- "a" must match the outer dimension of "b". This op is optimized for -- the case where at least one of "a" or "b" is sparse. The breakeven for -- using this versus a dense matrix multiply on one platform was 30% zero -- values in the sparse matrix. sparseMatMul :: (TensorType ta, OneOf '[Word16, Float] ta, TensorType tb, OneOf '[Word16, Float] tb) => Tensor v1 ta -> Tensor v2 tb -> Tensor Value Float -- | Forwards the value of an available tensor from inputs to -- output. -- -- Merge waits for at least one of the tensors in -- inputs to become available. It is usually combined with -- Switch to implement branching. -- -- Merge forwards the first tensor for become available to -- output, and sets value_index to its index in -- inputs. merge :: (TensorType t) => [Tensor v1 t] -> (Tensor Value t, Tensor Value Int32) -- | Computes the reverse mode backpropagated gradient of the Cholesky -- algorithm. -- -- For an explanation see "Differentiation of the Cholesky algorithm" by -- Iain Murray http://arxiv.org/abs/1602.07527. choleskyGrad :: (TensorType t, OneOf '[Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t batchCholeskyGrad :: (TensorType t, OneOf '[Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Gather specific elements from the TensorArray into output -- value. -- -- All elements selected by indices must have the same shape. tensorArrayGather :: (TensorType dtype) => Tensor v1 ByteString -> Tensor v2 Int32 -> Tensor v3 Float -> Tensor Value dtype -- | Resize images to size using nearest neighbor -- interpolation. resizeNearestNeighbor :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 Int32 -> Tensor Value t -- | Training via negative sampling. negTrain :: Int64 -> Tensor v1 Float -> Tensor v2 Float -> Tensor v3 Int32 -> Tensor v4 Int32 -> Tensor v5 Float -> ControlNode -- | Creates a TensorArray for storing the gradients of values in the given -- handle. -- -- If the given TensorArray gradient already exists, returns a reference -- to it. -- -- Locks the size of the original TensorArray by disabling its dynamic -- size flag. -- -- -- -- The handle flow_in forces the execution of the gradient lookup to -- occur only after certain other operations have occurred. For example, -- when the forward TensorArray is dynamically sized, writes to this -- TensorArray may resize the object. The gradient TensorArray is -- statically sized based on the size of the forward TensorArray when -- this operation executes. Furthermore, the size of the forward -- TensorArray is frozen by this call. As a result, the flow is used to -- ensure that the call to generate the gradient TensorArray only happens -- after all writes are executed. -- -- In the case of dynamically sized TensorArrays, gradient computation -- should only be performed on read operations that have themselves been -- chained via flow to occur only after all writes have executed. That -- way the final size of the forward TensorArray is known when this -- operation is called. -- -- -- -- TensorArray gradient calls use an accumulator TensorArray object. If -- multiple gradients are calculated and run in the same session, the -- multiple gradient nodes may accidentally flow throuth the same -- accumulator TensorArray. This double counts and generally breaks the -- TensorArray gradient flow. -- -- The solution is to identify which gradient call this particular -- TensorArray gradient is being called in. This is performed by -- identifying a unique string (e.g. "gradients", "gradients_1", ...) -- from the input gradient Tensor's name. This string is used as a suffix -- when creating the TensorArray gradient object here (the attribute -- source). -- -- The attribute source is added as a suffix to the forward -- TensorArray's name when performing the creation / lookup, so that each -- separate gradient calculation gets its own TensorArray accumulator. tensorArrayGrad :: Tensor v1 ByteString -> Tensor v2 Float -> Tensor Value ByteString -- | Outputs a Summary protocol buffer with audio. -- -- The summary has up to max_outputs summary values containing -- audio. The audio is built from tensor which must be 3-D with -- shape `[batch_size, frames, channels]` or 2-D with shape `[batch_size, -- frames]`. The values are assumed to be in the range of `[-1.0, 1.0]` -- with a sample rate of sample_rate. -- -- The tag argument is a scalar Tensor of type -- string. It is used to build the tag of the summary -- values: -- -- audioSummary :: Float -> Tensor v1 ByteString -> Tensor v2 Float -> Tensor Value ByteString -- | Does nothing. Only useful as a placeholder for control edges. noOp :: ControlNode -- | Makes its input available to the next iteration. nextIteration :: (TensorType t) => Tensor v1 t -> Tensor Value t -- | Computes softplus gradients for a softplus operation. softplusGrad :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Computes the singular value decompositions of one or more matrices. -- -- Computes the SVD of each inner matrix in input such that -- `input[..., :, :] = u[..., :, :] * diag(s[..., :, :]) * -- transpose(v[..., :, :])` -- -- ```prettyprint # a is a tensor containing a batch of matrices. # s is -- a tensor of singular values for each matrix. # u is the tensor -- containing of left singular vectors for each matrix. # v is the tensor -- containing of right singular vectors for each matrix. s, u, v = svd(a) -- s, _, _ = svd(a, compute_uv=False) ``` svd :: (TensorType t, OneOf '[Complex Double, Complex Float, Double, Float] t) => Tensor v1 t -> (Tensor Value t, Tensor Value t, Tensor Value t) -- | Convert one or more images from HSV to RGB. -- -- Outputs a tensor of the same shape as the images tensor, -- containing the RGB value of the pixels. The output is only well -- defined if the value in images are in `[0,1]`. -- -- See rgb_to_hsv for a description of the HSV encoding. hSVToRGB :: (TensorType t, OneOf '[Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Outputs random values from a normal distribution. The parameters may -- each be a -- -- scalar which applies to the entire output, or a vector of length -- shape[0] which stores the parameters for each batch. parameterizedTruncatedNormal :: (TensorType t, OneOf '[Int32, Int64] t, TensorType dtype, OneOf '[Word16, Double, Float] dtype) => Tensor v1 t -> Tensor v2 dtype -> Tensor v3 dtype -> Tensor v4 dtype -> Tensor v5 dtype -> Tensor Value dtype -- | Computes square of x element-wise. -- -- I.e., \(y = x * x = x^2\). square :: (TensorType t, OneOf '[Complex Double, Complex Float, Int32, Int64, Word16, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Computes exponential linear: `exp(features) - 1` if < 0, -- features otherwise. -- -- See Fast and Accurate Deep Network Learning by Exponential Linear -- Units (ELUs) elu :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Outputs all keys and values in the table. lookupTableExport :: (TensorType tkeys, TensorType tvalues) => Tensor v1 ByteString -> (Tensor Value tkeys, Tensor Value tvalues) -- | Computes the number of elements in the given table. lookupTableSize :: Tensor v1 ByteString -> Tensor Value Int64 -- | Computes gradients of the average pooling function. avgPoolGrad :: (TensorType t, OneOf '[Word16, Double, Float] t) => Tensor v1 Int32 -> Tensor v2 t -> Tensor Value t -- | Computes the ids of the positions in sampled_candidates that match -- true_labels. -- -- When doing log-odds NCE, the result of this op should be passed -- through a SparseToDense op, then added to the logits of the sampled -- candidates. This has the effect of removing the sampled -- labels that match the true labels by making the classifier sure that -- they are sampled labels. computeAccidentalHits :: Int64 -> Tensor v1 Int64 -> Tensor v2 Int64 -> (Tensor Value Int32, Tensor Value Int64, Tensor Value Float) -- | Calculates the CTC Loss (log probability) for each batch entry. Also -- calculates -- -- the gradient. This class performs the softmax operation for you, so -- inputs should be e.g. linear projections of outputs by an LSTM. cTCLoss :: Tensor v1 Float -> Tensor v2 Int64 -> Tensor v3 Int32 -> Tensor v4 Int32 -> (Tensor Value Float, Tensor Value Float) -- | Performs 3D average pooling on the input. avgPool3D :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Computes the reciprocal of x element-wise. -- -- I.e., \(y = 1 / x\). inv :: (TensorType t, OneOf '[Complex Double, Complex Float, Int32, Int64, Word16, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Pop the element at the top of the stack. stackPop :: (TensorType elem_type) => Tensor v1 ByteString -> Tensor Value elem_type -- | A queue that produces elements in first-in first-out order. -- -- Variable-size shapes are allowed by setting the corresponding shape -- dimensions to 0 in the shape attr. In this case DequeueMany will pad -- up to the maximum size of any given element in the minibatch. See -- below for details. paddingFIFOQueue :: Tensor Value ByteString batchSelfAdjointEigV2 :: (TensorType t, OneOf '[Double, Float] t) => Tensor v1 t -> (Tensor Value t, Tensor Value t) batchMatrixTriangularSolve :: (TensorType t, OneOf '[Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t batchMatrixSolveLs :: (TensorType t, OneOf '[Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor v3 Double -> Tensor Value t batchSvd :: (TensorType t, OneOf '[Complex Double, Complex Float, Double, Float] t) => Tensor v1 t -> (Tensor Value t, Tensor Value t, Tensor Value t) -- | Outputs a Summary protocol buffer with a tensor. tensorSummary :: (TensorType t) => Tensor v1 t -> Tensor Value ByteString -- | Computes softmax cross entropy cost and gradients to backpropagate. -- -- Unlike SoftmaxCrossEntropyWithLogits, this operation does not -- accept a matrix of label probabilities, but rather a single label per -- row of features. This label is considered to have probability 1.0 for -- the given row. -- -- Inputs are the logits, not probabilities. sparseSoftmaxCrossEntropyWithLogits :: (TensorType t, OneOf '[Word16, Double, Float] t, TensorType tlabels, OneOf '[Int32, Int64] tlabels) => Tensor v1 t -> Tensor v2 tlabels -> (Tensor Value t, Tensor Value t) -- | Performs max pooling on the input and outputs both max values and -- indices. -- -- The indices in argmax are flattened, so that a maximum value -- at position `[b, y, x, c]` becomes flattened index `((b * height + y) -- * width + x) * channels + c`. maxPoolWithArgmax :: (TensorType t, OneOf '[Word16, Float] t, TensorType targmax, OneOf '[Int32, Int64] targmax) => Tensor v1 t -> (Tensor Value t, Tensor Value targmax) -- | Compute the 1-dimensional discrete Fourier Transform over the -- inner-most -- -- dimension of input. fFT :: Tensor v1 (Complex Float) -> Tensor Value (Complex Float) -- | Outputs a Summary protocol buffer with a histogram. -- -- The generated `Summary` has one summary value containing a -- histogram for values. -- -- This op reports an InvalidArgument error if any value is not -- finite. histogramSummary :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 ByteString -> Tensor v2 t -> Tensor Value ByteString -- | Pads a tensor with zeros. -- -- This operation pads a input with zeros according to the -- paddings you specify. paddings is an integer tensor -- with shape `[Dn, 2]`, where n is the rank of input. For each -- dimension D of input, `paddings[D, 0]` indicates how many -- zeros to add before the contents of input in that dimension, -- and `paddings[D, 1]` indicates how many zeros to add after the -- contents of input in that dimension. -- -- The padded size of each dimension D of the output is: -- -- `paddings(D, 0) + input.dim_size(D) + paddings(D, 1)` -- -- For example: -- -- ```prettyprint # t is [[1, 1], [2, 2]] # paddings is -- [[1, 1], [2, 2]] # rank of t is 2 pad(t, paddings) ==> -- [[0, 0, 0, 0, 0, 0] [0, 0, 1, 1, 0, 0] [0, 0, 2, 2, 0, 0] [0, 0, 0, 0, -- 0, 0]] ``` pad :: (TensorType t, TensorType tpaddings, OneOf '[Int32, Int64] tpaddings) => Tensor v1 t -> Tensor v2 tpaddings -> Tensor Value t batchIFFT3D :: Tensor v1 (Complex Float) -> Tensor Value (Complex Float) -- | Outputs a Summary protocol buffer with images. -- -- The summary has up to max_images summary values containing -- images. The images are built from tensor which must be 4-D -- with shape `[batch_size, height, width, channels]` and where -- channels can be: -- -- -- -- The images have the same number of channels as the input tensor. For -- float input, the values are normalized one image at a time to fit in -- the range `[0, 255]`. uint8 values are unchanged. The op uses -- two different normalization algorithms: -- -- -- -- The tag argument is a scalar Tensor of type -- string. It is used to build the tag of the summary -- values: -- -- -- -- The bad_color argument is the color to use in the generated -- images for non-finite input values. It is a unit8 1-D tensor -- of length channels. Each element must be in the range `[0, -- 255]` (It represents the value of a pixel in the output image). -- Non-finite values in the input tensor are replaced by this tensor in -- the output image. The default value is the color red. imageSummary :: (TensorType t, OneOf '[Word16, Word8, Float] t) => Tensor v1 ByteString -> Tensor v2 t -> Tensor Value ByteString -- | Computes the sum along segments of a tensor. -- -- Read the section on Segmentation for an explanation of -- segments. -- -- Computes a tensor such that \(output_i = sum_j data_j\) where sum is -- over j such that `segment_ids[j] == i`. -- -- style="width:70%; margin:auto; margin-bottom:10px; -- margin-top:20px;" style="width:100%" -- src="../../images/SegmentSum.png" alt /div segmentSum :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t, TensorType tindices, OneOf '[Int32, Int64] tindices) => Tensor v1 t -> Tensor v2 tindices -> Tensor Value t -- | JPEG-encode an image. -- -- image is a 3-D uint8 Tensor of shape `[height, width, -- channels]`. -- -- The attr format can be used to override the color format of -- the encoded output. Values can be: -- -- -- -- If format is not specified or is the empty string, a default -- format is picked in function of the number of channels in -- image: -- -- encodeJpeg :: Tensor v1 Word8 -> Tensor Value ByteString -- | Gradients for batch normalization. -- -- This op is deprecated. See `tf.nn.batch_normalization`. batchNormWithGlobalNormalizationGrad :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Bool -> Float -> Tensor v1 t -> Tensor v2 t -> Tensor v3 t -> Tensor v4 t -> Tensor v5 t -> (Tensor Value t, Tensor Value t, Tensor Value t, Tensor Value t, Tensor Value t) -- | Adds bias to value. -- -- This is a deprecated version of BiasAdd and will be soon removed. -- -- This is a special case of `tf.add` where bias is restricted -- to be 1-D. Broadcasting is supported, so value may have any -- number of dimensions. biasAddV1 :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Computes the inverse permutation of a tensor. -- -- This operation computes the inverse of an index permutation. It takes -- a 1-D integer tensor x, which represents the indices of a -- zero-based array, and swaps each value with its index position. In -- other words, for an output tensor y and an input tensor -- x, this operation computes the following: -- -- `y[x[i]] = i for i in [0, 1, ..., len(x) - 1]` -- -- The values must include 0. There can be no duplicate values or -- negative values. -- -- For example: -- -- ```prettyprint # tensor x is [3, 4, 0, 2, 1] -- invert_permutation(x) ==> [2, 4, 3, 0, 1] ``` invertPermutation :: (TensorType t, OneOf '[Int32, Int64] t) => Tensor v1 t -> Tensor Value t -- | Gradient op for MirrorPad op. This op folds a mirror-padded -- tensor. -- -- This operation folds the padded areas of input by -- MirrorPad according to the paddings you specify. -- paddings must be the same as paddings argument given -- to the corresponding MirrorPad op. -- -- The folded size of each dimension D of the output is: -- -- `input.dim_size(D) - paddings(D, 0) - paddings(D, 1)` -- -- For example: -- -- ```prettyprint # t is [[1, 2, 3], [4, 5, 6], [7, 8, 9]]. # -- paddings is [[0, 1]], [0, 1]]. # mode is SYMMETRIC. -- # rank of t is 2. pad(t, paddings) ==> [[ 1, 5] [11, 28]] -- ``` mirrorPadGrad :: (TensorType t, TensorType tpaddings, OneOf '[Int32, Int64] tpaddings) => Tensor v1 t -> Tensor v2 tpaddings -> Tensor Value t -- | Reverses specific dimensions of a tensor. -- -- Given a tensor, and a bool tensor dims -- representing the dimensions of tensor, this operation -- reverses each dimension i of tensor where `dims[i]` is -- True. -- -- tensor can have up to 8 dimensions. The number of dimensions -- of tensor must equal the number of elements in dims. -- In other words: -- -- `rank(tensor) = size(dims)` -- -- For example: -- -- ```prettyprint # tensor t is [[[[ 0, 1, 2, 3], # [ 4, 5, 6, -- 7], # [ 8, 9, 10, 11]], # [[12, 13, 14, 15], # [16, 17, 18, 19], # -- [20, 21, 22, 23]]]] # tensor t shape is [1, 2, 3, 4] -- -- # dims is [False, False, False, True] reverse(t, dims) ==> -- [[[[ 3, 2, 1, 0], [ 7, 6, 5, 4], [ 11, 10, 9, 8]], [[15, 14, 13, 12], -- [19, 18, 17, 16], [23, 22, 21, 20]]]] -- -- # dims is [False, True, False, False] reverse(t, dims) ==> -- [[[[12, 13, 14, 15], [16, 17, 18, 19], [20, 21, 22, 23] [[ 0, 1, 2, -- 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11]]]] -- -- # dims is [False, False, True, False] reverse(t, dims) ==> -- [[[[8, 9, 10, 11], [4, 5, 6, 7], [0, 1, 2, 3]] [[20, 21, 22, 23], [16, -- 17, 18, 19], [12, 13, 14, 15]]]] ``` reverse :: (TensorType t, OneOf '[Complex Double, Complex Float, Bool, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 Bool -> Tensor Value t -- | Computes a 2-D convolution given 4-D input and filter -- tensors. -- -- Given an input tensor of shape `[batch, in_height, in_width, -- in_channels]` and a filter / kernel tensor of shape `[filter_height, -- filter_width, in_channels, out_channels]`, this op performs the -- following: -- --
    --
  1. Flattens the filter to a 2-D matrix with shape `[filter_height * -- filter_width * in_channels, output_channels]`.
  2. --
  3. Extracts image patches from the input tensor to form a *virtual* -- tensor of shape `[batch, out_height, out_width, filter_height * -- filter_width * in_channels]`.
  4. --
  5. For each patch, right-multiplies the filter matrix and the image -- patch vector.
  6. --
-- -- In detail, with the default NHWC format, -- -- output[b, i, j, k] = sum_{di, dj, q} input[b, strides[1] * i + di, -- strides[2] * j + dj, q] * filter[di, dj, q, k] -- -- Must have `strides[0] = strides[3] = 1`. For the most common case of -- the same horizontal and vertices strides, `strides = [1, stride, -- stride, 1]`. conv2D :: (TensorType t, OneOf '[Word16, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Computes the gradients of convolution with respect to the input. conv2DBackpropInput :: (TensorType t, OneOf '[Word16, Double, Float] t) => Tensor v1 Int32 -> Tensor v2 t -> Tensor v3 t -> Tensor Value t -- | Produce a string tensor that encodes the state of a Reader. -- -- Not all Readers support being serialized, so this can produce an -- Unimplemented error. readerSerializeState :: Tensor v1 ByteString -> Tensor Value ByteString -- | Returns a tensor that may be mutated, but only persists within a -- single step. -- -- This is an experimental op for internal use only and it is possible to -- use this op in unsafe ways. DO NOT USE unless you fully understand the -- risks. -- -- It is the caller's responsibility to ensure that ref is -- eventually passed to a matching DestroyTemporaryVariable op -- after all other uses have completed. -- -- Outputs a ref to the tensor state so it may be read or modified. -- -- E.g. var = state_ops._temporary_variable([1, 2], types.float_) -- var_name = var.op.name var = state_ops.assign(var, [[4.0, 5.0]]) var = -- state_ops.assign_add(var, [[6.0, 7.0]]) final = -- state_ops._destroy_temporary_variable(var, var_name=var_name) temporaryVariable :: (TensorType dtype) => Tensor Value dtype -- | Extracts crops from the input image tensor and bilinearly resizes them -- (possibly -- -- with aspect ratio change) to a common output size specified by -- crop_size. This is more general than the -- crop_to_bounding_box op which extracts a fixed size slice -- from the input image and does not allow resizing or aspect ratio -- change. -- -- Returns a tensor with crops from the input image at -- positions defined at the bounding box locations in boxes. The -- cropped boxes are all resized (with bilinear interpolation) to a fixed -- `size = [crop_height, crop_width]`. The result is a 4-D tensor -- `[num_boxes, crop_height, crop_width, depth]`. cropAndResize :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 Float -> Tensor v3 Int32 -> Tensor v4 Int32 -> Tensor Value Float -- | Computes gradients of the maxpooling function. maxPoolGrad :: (TensorType t, OneOf '[Word16, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor v3 t -> Tensor Value t -- | Performs a resize and padding as a preprocess during a convolution. -- -- It's often possible to do spatial transformations more efficiently as -- part of the packing stage of a convolution, so this op allows for an -- optimized implementation where these stages are fused together. This -- prevents the need to write out the intermediate results as whole -- tensors, reducing memory pressure, and we can get some latency gains -- by merging the transformation calculations. The data_format attribute -- for Conv2D isn't supported by this op, and defaults to NHWC -- order. Internally this op uses a single per-graph scratch buffer, -- which means that it will block if multiple versions are being run in -- parallel. This is because this operator is primarily an optimization -- to minimize memory usage. fusedResizeAndPadConv2D :: (TensorType t, OneOf '[Word16, Double, Float] t) => Tensor v1 t -> Tensor v2 Int32 -> Tensor v3 Int32 -> Tensor v4 t -> Tensor Value t -- | Outputs random values from a uniform distribution. -- -- The generated values follow a uniform distribution in the range `[0, -- 1)`. The lower bound 0 is included in the range, while the upper bound -- 1 is excluded. randomUniform :: (TensorType t, OneOf '[Int32, Int64] t, TensorType dtype, OneOf '[Word16, Double, Float] dtype) => Tensor v1 t -> Tensor Value dtype -- | Computes a 2-D depthwise convolution given 4-D input and -- filter tensors. -- -- Given an input tensor of shape `[batch, in_height, in_width, -- in_channels]` and a filter / kernel tensor of shape `[filter_height, -- filter_width, in_channels, channel_multiplier]`, containing -- in_channels convolutional filters of depth 1, -- depthwise_conv2d applies a different filter to each input -- channel (expanding from 1 channel to channel_multiplier -- channels for each), then concatenates the results together. Thus, the -- output has `in_channels * channel_multiplier` channels. -- -- for k in 0..in_channels-1 for q in 0..channel_multiplier-1 output[b, -- i, j, k * channel_multiplier + q] = sum_{di, dj} input[b, strides[1] * -- i + di, strides[2] * j + dj, k] * filter[di, dj, k, q] -- -- Must have `strides[0] = strides[3] = 1`. For the most common case of -- the same horizontal and vertices strides, `strides = [1, stride, -- stride, 1]`. depthwiseConv2dNative :: (TensorType t, OneOf '[Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | var: Should be from a Variable(). sparseApplyAdadelta :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t, TensorType tindices, OneOf '[Int32, Int64] tindices) => Tensor v1 t -> Tensor v2 t -> Tensor v3 t -> Tensor v4 t -> Tensor v5 t -> Tensor v6 t -> Tensor v7 t -> Tensor v8 tindices -> Tensor Value t -- | Computes the gradients of depthwise convolution with respect to the -- filter. depthwiseConv2dNativeBackpropFilter :: (TensorType t, OneOf '[Double, Float] t) => Tensor v1 t -> Tensor v2 Int32 -> Tensor v3 t -> Tensor Value t -- | Computes a 3-D convolution given 5-D input and filter -- tensors. -- -- In signal processing, cross-correlation is a measure of similarity of -- two waveforms as a function of a time-lag applied to one of them. This -- is also known as a sliding dot product or sliding inner-product. -- -- Our Conv3D implements a form of cross-correlation. conv3D :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Returns the truth value of (x >= y) element-wise. -- -- greaterEqual :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value Bool -- | Adds up a SparseTensor and a dense Tensor, using these special rules: -- --
    --
  1. Broadcasts the dense side to have the same shape as the sparse -- side, if eligible;
  2. --
  3. Then, only the dense values pointed to by the indices of the -- SparseTensor participate in the cwise addition.
  4. --
-- -- By these rules, the result is a logical SparseTensor with exactly the -- same indices and shape, but possibly with different non-zero values. -- The output of this Op is the resultant non-zero values. sparseDenseCwiseAdd :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 Int64 -> Tensor v2 t -> Tensor v3 Int64 -> Tensor v4 t -> Tensor Value t -- | Computes the gradients of 3-D convolution with respect to the filter. conv3DBackpropFilter :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor v3 t -> Tensor Value t -- | Computes the gradients of 3-D convolution with respect to the input. conv3DBackpropInputV2 :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 Int32 -> Tensor v2 t -> Tensor v3 t -> Tensor Value t -- | Returns element-wise remainder of division. -- -- mod :: (TensorType t, OneOf '[Int32, Int64, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Forwards the value of an available tensor from inputs to -- output. -- -- Merge waits for at least one of the tensors in -- inputs to become available. It is usually combined with -- Switch to implement branching. -- -- Merge forwards the first tensor for become available to -- output, and sets value_index to its index in -- inputs. refMerge :: (TensorType t) => [Tensor v1 t] -> (Tensor Value t, Tensor Value Int32) -- | Computes the gradients of 3-D convolution with respect to the filter. conv3DBackpropFilterV2 :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 Int32 -> Tensor v3 t -> Tensor Value t -- | Serialize an N-minibatch SparseTensor into an `[N, -- 3]` string Tensor. -- -- The SparseTensor must have rank R greater than 1, -- and the first dimension is treated as the minibatch dimension. -- Elements of the SparseTensor must be sorted in increasing -- order of this first dimension. The serialized SparseTensor -- objects going into each row of serialized_sparse will have -- rank `R-1`. -- -- The minibatch size N is extracted from `sparse_shape[0]`. serializeManySparse :: (TensorType t) => Tensor v1 Int64 -> Tensor v2 t -> Tensor v3 Int64 -> Tensor Value ByteString -- | Computes gradients of average pooling function. avgPool3DGrad :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 Int32 -> Tensor v2 t -> Tensor Value t -- | Computes gradients of max pooling function. maxPool3DGrad :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 Float -> Tensor v2 Float -> Tensor v3 t -> Tensor Value t -- | Computes the sum of elements across dimensions of a SparseTensor. -- -- This Op takes a SparseTensor and is the sparse counterpart to -- `tf.reduce_sum()`. In particular, this Op also returns a dense -- Tensor instead of a sparse one. -- -- Reduces sp_input along the dimensions given in -- reduction_axes. Unless keep_dims is true, the rank -- of the tensor is reduced by 1 for each entry in -- reduction_axes. If keep_dims is true, the reduced -- dimensions are retained with length 1. -- -- If reduction_axes has no entries, all dimensions are reduced, -- and a tensor with a single element is returned. Additionally, the axes -- can be negative, which are interpreted according to the indexing rules -- in Python. sparseReduceSum :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 Int64 -> Tensor v2 t -> Tensor v3 Int64 -> Tensor v4 Int32 -> Tensor Value t -- | Computes rectified linear: `max(features, 0)`. relu :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | L2 Loss. -- -- Computes half the L2 norm of a tensor without the sqrt: -- -- output = sum(t ** 2) / 2 l2Loss :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Restore a reader to a previously saved state. -- -- Not all Readers support being restored, so this can produce an -- Unimplemented error. readerRestoreState :: Tensor v1 ByteString -> Tensor v2 ByteString -> ControlNode -- | Returns the shape of a tensor. -- -- This operation returns a 1-D integer tensor representing the shape of -- input. -- -- For example: -- -- ```prettyprint # t is [[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], -- [4, 4, 4]]] shape(t) ==> [2, 2, 3] ``` shape :: (TensorType t, TensorType out_type, OneOf '[Int32, Int64] out_type) => Tensor v1 t -> Tensor Value out_type -- | Computes softmax cross entropy cost and gradients to backpropagate. -- -- Inputs are the logits, not probabilities. softmaxCrossEntropyWithLogits :: (TensorType t, OneOf '[Word16, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> (Tensor Value t, Tensor Value t) -- | Performs max pooling on the input. maxPool :: (TensorType t, OneOf '[Word16, Float] t) => Tensor v1 t -> Tensor Value t -- | Computes the gradient of morphological 2-D dilation with respect to -- the input. dilation2DBackpropInput :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor v3 t -> Tensor Value t -- | Returns the truth value of (x == y) element-wise. -- -- equal :: (TensorType t, OneOf '[Complex Double, Complex Float, Bool, ByteString, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value Bool -- | Computes the gradient of morphological 2-D dilation with respect to -- the filter. dilation2DBackpropFilter :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor v3 t -> Tensor Value t -- | Computes rectified linear gradients for a Relu operation. reluGrad :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Computes rectified linear 6: `min(max(features, 0), 6)`. relu6 :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Resize images to size using bicubic interpolation. -- -- Input images can be of different types but output images are always -- float. resizeBicubic :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 Int32 -> Tensor Value Float -- | Computes rectified linear 6 gradients for a Relu6 operation. relu6Grad :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Multiply SparseTensor (of rank 2) A by dense matrix B. -- -- No validity checking is performed on the indices of A. However, the -- following input format is recommended for optimal behavior: -- -- if adjoint_a == false: A should be sorted in lexicographically -- increasing order. Use SparseReorder if you're not sure. if adjoint_a -- == true: A should be sorted in order of increasing dimension 1 (i.e., -- "column major" order instead of "row major" order). sparseTensorDenseMatMul :: (TensorType t) => Tensor v1 Int64 -> Tensor v2 t -> Tensor v3 Int64 -> Tensor v4 t -> Tensor Value t -- | Computes softplus: `log(exp(features) + 1)`. softplus :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Multiplies slices of two tensors in batches. -- -- Multiplies all slices of Tensor x and y (each -- slice can be viewed as an element of a batch), and arranges the -- individual results in a single output tensor of the same batch size. -- Each of the individual slices can optionally be adjointed (to adjoint -- a matrix means to transpose and conjugate it) before multiplication by -- setting the adj_x or adj_y flag to True, -- which are by default False. -- -- The input tensors x and y are 3-D or higher with -- shape `[..., r_x, c_x]` and `[..., r_y, c_y]`. -- -- The output tensor is 3-D or higher with shape `[..., r_o, c_o]`, -- where: -- -- r_o = c_x if adj_x else r_x c_o = r_y if adj_y else c_y -- -- It is computed as: -- -- output[..., :, :] = matrix(x[..., :, :]) * matrix(y[..., :, :]) batchMatMul :: (TensorType t, OneOf '[Complex Double, Complex Float, Int32, Word16, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Computes softsign gradients for a softsign operation. softsignGrad :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Returns the truth value of (x <= y) element-wise. -- -- lessEqual :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value Bool -- | Computes log softmax activations. -- -- For each batch i and class j we have -- -- logsoftmax[i, j] = logits[i, j] - log(sum(exp(logits[i]))) logSoftmax :: (TensorType t, OneOf '[Word16, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Says whether the targets are in the top K predictions. -- -- This outputs a batch_size bool array, an entry `out[i]` is -- true if the prediction for the target class is among the top -- k predictions among all predictions for example i. -- Note that the behavior of InTopK differs from the -- TopK op in its handling of ties; if multiple classes have the -- same prediction value and straddle the top-k boundary, all of -- those classes are considered to be in the top k. -- -- More formally, let -- -- \(predictions_i\) be the predictions for all classes for example -- i, \(targets_i\) be the target class for example i, -- \(out_i\) be the output for example i, -- -- $$out_i = predictions_{i, targets_i} in -- TopKIncludingTies(predictions_i)$$ inTopK :: (TensorType t, OneOf '[Int32, Int64] t) => Int64 -> Tensor v1 Float -> Tensor v2 t -> Tensor Value Bool -- | Returns a batched diagonal tensor with a given batched diagonal -- values. -- -- 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 k dimensions `[I, J, K, ..., -- N]`, then the output is a tensor of rank `k+1` with dimensions [I, J, -- K, ..., N, N]` where: -- -- `output[i, j, k, ..., m, n] = 1{m=n} * diagonal[i, j, k, ..., n]`. -- -- For example: -- -- ```prettyprint # diagonal is [[1, 2, 3, 4], [5, 6, 7, 8]] -- -- and diagonal.shape = (2, 4) -- -- tf.matrix_diag(diagonal) ==> [[[1, 0, 0, 0] [0, 2, 0, 0] [0, 0, 3, -- 0] [0, 0, 0, 4]], [[5, 0, 0, 0] [0, 6, 0, 0] [0, 0, 7, 0] [0, 0, 0, -- 8]]] -- -- which has shape (2, 4, 4) ``` matrixDiag :: (TensorType t) => Tensor v1 t -> Tensor Value t -- | Performs 3D max pooling on the input. maxPool3D :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Finds values and indices of the k largest elements for the -- last dimension. -- -- If the input is a vector (rank-1), finds the k largest -- entries in the vector and outputs their values and indices as vectors. -- Thus `values[j]` is the j-th largest entry in input, -- and its index is `indices[j]`. -- -- For matrices (resp. higher rank input), computes the top k -- entries in each row (resp. vector along the last dimension). Thus, -- -- values.shape = indices.shape = input.shape[:-1] + [k] -- -- If two elements are equal, the lower-index element appears first. -- -- If k varies dynamically, use TopKV2 below. topK :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Int64 -> Tensor v1 t -> (Tensor Value t, Tensor Value Int32) -- | Finds values and indices of the k largest elements for the -- last dimension. -- -- If the input is a vector (rank-1), finds the k largest -- entries in the vector and outputs their values and indices as vectors. -- Thus `values[j]` is the j-th largest entry in input, -- and its index is `indices[j]`. -- -- For matrices (resp. higher rank input), computes the top k -- entries in each row (resp. vector along the last dimension). Thus, -- -- values.shape = indices.shape = input.shape[:-1] + [k] -- -- If two elements are equal, the lower-index element appears first. -- -- This is the same as TopK, but takes k as in input -- rather than an attr. topKV2 :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 Int32 -> (Tensor Value t, Tensor Value Int32) -- | Performs fractional max pooling on the input. -- -- Fractional max pooling is slightly different than regular max pooling. -- In regular max pooling, you downsize an input set by taking the -- maximum value of smaller N x N subsections of the set (often 2x2), and -- try to reduce the set by a factor of N, where N is an integer. -- Fractional max pooling, as you might expect from the word -- "fractional", means that the overall reduction ratio N does not have -- to be an integer. -- -- The sizes of the pooling regions are generated randomly but are fairly -- uniform. For example, let's look at the height dimension, and the -- constraints on the list of rows that will be pool boundaries. -- -- First we define the following: -- --
    --
  1. input_row_length : the number of rows from the input set
  2. --
  3. output_row_length : which will be smaller than the input
  4. --
  5. alpha = input_row_length / output_row_length : our reduction -- ratio
  6. --
  7. K = floor(alpha)
  8. --
  9. row_pooling_sequence : this is the result list of pool boundary -- rows
  10. --
-- -- Then, row_pooling_sequence should satisfy: -- --
    --
  1. a[0] = 0 : the first value of the sequence is 0
  2. --
  3. a[end] = input_row_length : the last value of the sequence is the -- size
  4. --
  5. K <= (a[i+1] - a[i]) <= K+1 : all intervals are K or K+1 -- size
  6. --
  7. length(row_pooling_sequence) = output_row_length+1
  8. --
-- -- For more details on fractional max pooling, see this paper: -- Benjamin Graham, Fractional Max-Pooling fractionalMaxPool :: (TensorType t, OneOf '[Int32, Int64, Double, Float] t) => Tensor v1 t -> (Tensor Value t, Tensor Value Int64, Tensor Value Int64) -- | Copy a tensor setting everything outside a central band in each -- innermost matrix -- -- to zero. -- -- 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)` is one if `(num_lower < 0 || -- (m-n) <= num_lower)) && (num_upper < 0 || (n-m) <= -- num_upper)`, and zero otherwise. -- -- For example: -- -- ```prettyprint # 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: -- -- ```prettyprint 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. ``` matrixBandPart :: (TensorType t) => Tensor v1 t -> Tensor v2 Int64 -> Tensor v3 Int64 -> Tensor Value t -- | Reinterpret the bytes of a string as a vector of numbers. decodeRaw :: (TensorType out_type, OneOf '[Int16, Int32, Int64, Int8, Word8, Double, Float] out_type) => Tensor v1 ByteString -> Tensor Value out_type -- | Convert JSON-encoded Example records to binary protocol buffer -- strings. -- -- This op translates a tensor containing Example records, encoded using -- the standard JSON mapping, into a tensor containing the same -- records encoded as binary protocol buffers. The resulting tensor can -- then be fed to any of the other Example-parsing ops. decodeJSONExample :: Tensor v1 ByteString -> Tensor Value ByteString -- | Outputs random values from a truncated normal distribution. -- -- The generated values follow a normal distribution with mean 0 and -- standard deviation 1, except that values whose magnitude is more than -- 2 standard deviations from the mean are dropped and re-picked. truncatedNormal :: (TensorType t, OneOf '[Int32, Int64] t, TensorType dtype, OneOf '[Word16, Double, Float] dtype) => Tensor v1 t -> Tensor Value dtype -- | Randomly shuffles a tensor along its first dimension. -- -- The tensor is shuffled along dimension 0, such that each `value[j]` is -- mapped to one and only one `output[i]`. For example, a mapping that -- might occur for a 3x2 tensor is: -- -- ```prettyprint [[1, 2], [[5, 6], [3, 4], ==> [1, 2], [5, 6]] [3, -- 4]] ``` randomShuffle :: (TensorType t) => Tensor v1 t -> Tensor Value t -- | Draws samples from a multinomial distribution. multinomial :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 Int32 -> Tensor Value Int64 -- | Outputs random values from the Gamma distribution(s) described by -- alpha. -- -- This op uses the algorithm by Marsaglia et al. to acquire samples via -- transformation-rejection from pairs of uniform and normal random -- variables. See http://dl.acm.org/citation.cfm?id=358414 randomGamma :: (TensorType s, OneOf '[Int32, Int64] s, TensorType t, OneOf '[Word16, Double, Float] t) => Tensor v1 s -> Tensor v2 t -> Tensor Value t -- | Add all input tensors element wise. addN :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => [Tensor v1 t] -> Tensor Value t -- | Computes the maximum of elements across dimensions of a tensor. -- -- Reduces input along the dimensions given in -- reduction_indices. Unless keep_dims is true, the -- rank of the tensor is reduced by 1 for each entry in -- reduction_indices. If keep_dims is true, the reduced -- dimensions are retained with length 1. max :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t, TensorType tidx, OneOf '[Int32, Int64] tidx) => Tensor v1 t -> Tensor v2 tidx -> Tensor Value t -- | A graph node which represents a return value of a function. _Retval :: (TensorType t) => Int64 -> Tensor v1 t -> ControlNode -- | Destroys the temporary variable and returns its final value. -- -- Sets output to the value of the Tensor pointed to by ref, -- then destroys the temporary variable called var_name. All -- other uses of ref *must* have executed before this op. This -- is typically achieved by chaining the ref through each assign op, or -- by using control dependencies. -- -- Outputs the final value of the tensor pointed to by ref. destroyTemporaryVariable :: (TensorType t) => Tensor v1 t -> Tensor Value t -- | Cast x of type SrcT to y of DstT. cast :: (TensorType dstT, TensorType srcT) => Tensor v1 srcT -> Tensor Value dstT -- | Increments ref until it reaches limit. -- -- This operation outputs "ref" after the update is done. This makes it -- easier to chain operations that need to use the updated value. countUpTo :: (TensorType t, OneOf '[Int32, Int64] t) => Int64 -> Tensor v1 t -> Tensor Value t -- | Computes the absolute value of a tensor. -- -- Given a tensor x, this operation returns a tensor containing -- the absolute value of each element in x. For example, if x is -- an input element and y is an output element, this operation computes -- \(y = |x|\). abs :: (TensorType t, OneOf '[Int32, Int64, Word16, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Computes numerical negative value element-wise. -- -- I.e., \(y = -x\). neg :: (TensorType t, OneOf '[Complex Double, Complex Float, Int32, Int64, Word16, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Returns the element-wise max of two SparseTensors. -- -- Assumes the two SparseTensors have the same shape, i.e., no -- broadcasting. sparseSparseMaximum :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 Int64 -> Tensor v2 t -> Tensor v3 Int64 -> Tensor v4 Int64 -> Tensor v5 t -> Tensor v6 Int64 -> (Tensor Value Int64, Tensor Value t) -- | Computes the gradient for the inverse of x wrt its input. -- -- Specifically, `grad = -dy * y*y`, where `y = 1/x`, and dy is -- the corresponding input gradient. invGrad :: (TensorType t, OneOf '[Complex Double, Complex Float, Word16, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Computes square root of x element-wise. -- -- I.e., \(y = sqrt{x} = x^{1/2}\). sqrt :: (TensorType t, OneOf '[Complex Double, Complex Float, Word16, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Computes the inverse of one or more square invertible matrices or -- their -- -- adjoints (conjugate transposes). -- -- 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. matrixInverse :: (TensorType t, OneOf '[Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Computes the gradient for the sqrt of x wrt its input. -- -- Specifically, `grad = dy * 0.5 / y`, where `y = sqrt(x)`, and -- dy is the corresponding input gradient. sqrtGrad :: (TensorType t, OneOf '[Complex Double, Complex Float, Word16, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Inserts a dimension of 1 into a tensor's shape. -- -- Given a tensor input, this operation inserts a dimension of 1 -- at the dimension index dim of input's shape. The -- dimension index dim starts at zero; if you specify a negative -- number for dim it is counted backward from the end. -- -- This operation is useful if you want to add a batch dimension to a -- single element. For example, if you have a single image of shape -- `[height, width, channels]`, you can make it a batch of 1 image with -- `expand_dims(image, 0)`, which will make the shape `[1, height, width, -- channels]`. -- -- Other examples: -- -- ```prettyprint # t is a tensor of shape [2] -- shape(expand_dims(t, 0)) ==> [1, 2] shape(expand_dims(t, 1)) ==> -- [2, 1] shape(expand_dims(t, -1)) ==> [2, 1] -- -- # t2 is a tensor of shape [2, 3, 5] shape(expand_dims(t2, 0)) -- ==> [1, 2, 3, 5] shape(expand_dims(t2, 2)) ==> [2, 3, 1, 5] -- shape(expand_dims(t2, 3)) ==> [2, 3, 5, 1] ``` -- -- This operation requires that: -- -- `-1-input.dims() <= dim <= input.dims()` -- -- This operation is related to `squeeze()`, which removes dimensions of -- size 1. expandDims :: (TensorType t, TensorType tdim, OneOf '[Int32, Int64] tdim) => Tensor v1 t -> Tensor v2 tdim -> Tensor Value t -- | Computes the "logical and" of elements across dimensions of a tensor. -- -- Reduces input along the dimensions given in -- reduction_indices. Unless keep_dims is true, the -- rank of the tensor is reduced by 1 for each entry in -- reduction_indices. If keep_dims is true, the reduced -- dimensions are retained with length 1. all :: (TensorType tidx, OneOf '[Int32, Int64] tidx) => Tensor v1 Bool -> Tensor v2 tidx -> Tensor Value Bool -- | Performs beam search decoding on the logits given in input. -- -- A note about the attribute merge_repeated: For the beam search -- decoder, this means that if consecutive entries in a beam are the -- same, only the first of these is emitted. That is, when the top path -- is "A B B B B", "A B" is returned if merge_repeated = True but "A B B -- B B" is returned if merge_repeated = False. cTCBeamSearchDecoder :: Int64 -> Int64 -> Tensor v1 Float -> Tensor v2 Int32 -> ([Tensor Value Int64], [Tensor Value Int64], [Tensor Value Int64], Tensor Value Float) -- | Computes reciprocal of square root of x element-wise. -- -- I.e., \(y = 1 / sqrt{x}\). rsqrt :: (TensorType t, OneOf '[Complex Double, Complex Float, Word16, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Computes the gradient for the tanh of x wrt its input. -- -- Specifically, `grad = dy * (1 - y*y)`, where `y = tanh(x)`, and -- dy is the corresponding input gradient. tanhGrad :: (TensorType t, OneOf '[Complex Double, Complex Float, Word16, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Computes sin of x element-wise. sin :: (TensorType t, OneOf '[Complex Double, Complex Float, Word16, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Computes the determinant of one ore more square matrices. -- -- 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 `[..., :, :]`. matrixDeterminant :: (TensorType t, OneOf '[Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Computes cos of x element-wise. cos :: (TensorType t, OneOf '[Complex Double, Complex Float, Word16, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | BatchToSpace for 4-D tensors of type T. -- -- This is a legacy version of the more general BatchToSpaceND. -- -- Rearranges (permutes) data from batch into blocks of spatial data, -- followed by cropping. This is the reverse transformation of -- SpaceToBatch. More specifically, this op outputs a copy of the input -- tensor where values from the batch dimension are moved in -- spatial blocks to the height and width dimensions, -- followed by cropping along the height and width -- dimensions. batchToSpace :: (TensorType t, TensorType tidx, OneOf '[Int32, Int64] tidx) => Int64 -> Tensor v1 t -> Tensor v2 tidx -> Tensor Value t -- | Converts a sparse representation into a dense tensor. -- -- Builds an array dense with shape output_shape such -- that -- -- ```prettyprint # If sparse_indices is scalar dense[i] = (i == -- sparse_indices ? sparse_values : default_value) -- -- # If sparse_indices is a vector, then for each i -- dense[sparse_indices[i]] = sparse_values[i] -- -- # If sparse_indices is an n by d matrix, then for each i in [0, n) -- dense[sparse_indices[i][0], ..., sparse_indices[i][d-1]] = -- sparse_values[i] ``` -- -- All other values in dense are set to default_value. -- If sparse_values is a scalar, all sparse indices are set to -- this single value. -- -- Indices should be sorted in lexicographic order, and indices must not -- contain any repeats. If validate_indices is true, these -- properties are checked during execution. sparseToDense :: (TensorType t, TensorType tindices, OneOf '[Int32, Int64] tindices) => Tensor v1 tindices -> Tensor v2 tindices -> Tensor v3 t -> Tensor v4 t -> Tensor Value t -- | Computes asin of x element-wise. asin :: (TensorType t, OneOf '[Complex Double, Complex Float, Int32, Int64, Word16, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Returns the index with the smallest value across dimensions of a -- tensor. argMin :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t, TensorType tidx, OneOf '[Int32, Int64] tidx) => Tensor v1 t -> Tensor v2 tidx -> Tensor Value Int64 -- | Returns which elements of x are Inf. isInf :: (TensorType t, OneOf '[Word16, Double, Float] t) => Tensor v1 t -> Tensor Value Bool -- | Returns an element-wise indication of the sign of a number. -- -- `y = sign(x) = -1` if `x 0 if `x == 0`; 1 if `x 0`. -- -- For complex numbers, `y = sign(x) = x / |x|` if `x != 0`, otherwise `y -- = 0`. sign :: (TensorType t, OneOf '[Complex Double, Complex Float, Int32, Int64, Word16, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Returns x + y element-wise. -- -- add :: (TensorType t, OneOf '[Complex Double, Complex Float, ByteString, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Update relevant entries in '*var' according to the Ftrl-proximal -- scheme. -- -- That is for rows we have grad for, we update var, accum and linear as -- follows: accum_new = accum + grad * grad linear += grad + -- (accum_new^(-lr_power) - accum^(-lr_power)) / lr * var quadratic = 1.0 -- / (accum_new^(lr_power) * lr) + 2 * l2 var = (sign(linear) * l1 - -- linear) / quadratic if |linear| > l1 else 0.0 accum = accum_new sparseApplyFtrl :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t, TensorType tindices, OneOf '[Int32, Int64] tindices) => Tensor v1 t -> Tensor v2 t -> Tensor v3 t -> Tensor v4 t -> Tensor v5 tindices -> Tensor v6 t -> Tensor v7 t -> Tensor v8 t -> Tensor v9 t -> Tensor Value t -- | Returns x - y element-wise. -- -- sub :: (TensorType t, OneOf '[Complex Double, Complex Float, Int32, Int64, Word16, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t batchFFT3D :: Tensor v1 (Complex Float) -> Tensor Value (Complex Float) -- | Computes the sum of elements across dimensions of a SparseTensor. -- -- This Op takes a SparseTensor and is the sparse counterpart to -- `tf.reduce_sum()`. In contrast to SparseReduceSum, this Op returns a -- SparseTensor. -- -- Reduces sp_input along the dimensions given in -- reduction_axes. Unless keep_dims is true, the rank -- of the tensor is reduced by 1 for each entry in -- reduction_axes. If keep_dims is true, the reduced -- dimensions are retained with length 1. -- -- If reduction_axes has no entries, all dimensions are reduced, -- and a tensor with a single element is returned. Additionally, the axes -- can be negative, which are interpreted according to the indexing rules -- in Python. sparseReduceSumSparse :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 Int64 -> Tensor v2 t -> Tensor v3 Int64 -> Tensor v4 Int32 -> (Tensor Value Int64, Tensor Value t, Tensor Value Int64) -- | Adds bias to value. -- -- This is a special case of `tf.add` where bias is restricted -- to be 1-D. Broadcasting is supported, so value may have any -- number of dimensions. biasAdd :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Returns x * y element-wise. -- -- mul :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Returns x / y element-wise. -- -- div :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Forwards the input to the output. -- -- This operator represents the loop termination condition used by the -- "pivot" switches of a loop. loopCond :: Tensor v1 Bool -> Tensor Value Bool -- | Returns (x - y)(x - y) element-wise. -- -- squaredDifference :: (TensorType t, OneOf '[Complex Double, Complex Float, Int32, Int64, Word16, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Returns the max of x and y (i.e. x > y ? x : y) element-wise. -- -- maximum :: (TensorType t, OneOf '[Int32, Int64, Word16, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Generates labels for candidate sampling with a log-uniform -- distribution. -- -- See explanations of candidate sampling and the data formats at -- go/candidate-sampling. -- -- For each batch, this op picks a single set of sampled candidate -- labels. -- -- The advantages of sampling candidates per-batch are simplicity and the -- possibility of efficient dense matrix multiplication. The disadvantage -- is that the sampled candidates must be chosen independently of the -- context and of the true labels. logUniformCandidateSampler :: Int64 -> Int64 -> Int64 -> Bool -> Tensor v1 Int64 -> (Tensor Value Int64, Tensor Value Float, Tensor Value Float) -- | Returns the truth value of (x < y) element-wise. -- -- less :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value Bool -- | Computes the power of one value to another. -- -- Given a tensor x and a tensor y, this operation -- computes \(x^y\) for corresponding elements in x and -- y. For example: -- -- ``` # tensor x is [[2, 2]], [3, 3]] # tensor y is -- [[8, 16], [2, 3]] tf.pow(x, y) ==> [[256, 65536], [9, 27]] ``` pow :: (TensorType t, OneOf '[Complex Double, Complex Float, Int32, Int64, Word16, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Compute the upper regularized incomplete Gamma function `Q(a, x)`. -- -- The upper regularized incomplete Gamma function is defined as: -- -- ``` Q(a, x) = Gamma(a, x) / Gamma(a) = 1 - P(a, x) ``` where ``` -- Gamma(a, x) = int_{x}^{infty} t^{a-1} exp(-t) dt ``` is the upper -- incomplete Gama function. -- -- Note, above `P(a, x)` (Igamma) is the lower regularized -- complete Gamma function. igammac :: (TensorType t, OneOf '[Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Compute the lower regularized incomplete Gamma function `Q(a, x)`. -- -- The lower regularized incomplete Gamma function is defined as: -- -- ``` P(a, x) = gamma(a, x) / Gamma(a) = 1 - Q(a, x) ``` where ``` -- gamma(a, x) = int_{0}^{x} t^{a-1} exp(-t) dt ``` is the lower -- incomplete Gamma function. -- -- Note, above `Q(a, x)` (Igammac) is the upper regularized -- complete Gamma function. igamma :: (TensorType t, OneOf '[Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Compute the Hurwitz zeta function \(zeta(x, q)\). -- -- The Hurwitz zeta function is defined as: -- -- ``` zeta(x, q) = sum_{n=0}^{infty} (q + n)^{-x} ``` zeta :: (TensorType t, OneOf '[Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Returns the imaginary part of a complex number. -- -- Given a tensor input of complex numbers, this operation -- returns a tensor of type float that is the imaginary part of -- each element in input. All elements in input must be -- complex numbers of the form \(a + bj\), where *a* is the real part and -- *b* is the imaginary part returned by this operation. -- -- For example: -- -- ``` # tensor input is [-2.25 + 4.75j, 3.25 + 5.75j] -- tf.imag(input) ==> [4.75, 5.75] ``` imag :: (TensorType t, OneOf '[Complex Double, Complex Float] t, TensorType tout, OneOf '[Double, Float] tout) => Tensor v1 t -> Tensor Value tout -- | Converts two real numbers to a complex number. -- -- Given a tensor real representing the real part of a complex -- number, and a tensor imag representing the imaginary part of a -- complex number, this operation returns complex numbers elementwise of -- the form \(a + bj\), where *a* represents the real part and *b* -- represents the imag part. -- -- The input tensors real and imag must have the same -- shape. -- -- For example: -- -- ``` # tensor real is [2.25, 3.25] # tensor imag is -- [4.75, 5.75] tf.complex(real, imag) ==> [[2.25 + 4.75j], [3.25 + -- 5.75j]] ``` complex :: (TensorType t, OneOf '[Double, Float] t, TensorType tout, OneOf '[Complex Double, Complex Float] tout) => Tensor v1 t -> Tensor v2 t -> Tensor Value tout -- | Returns the truth value of (x != y) element-wise. -- -- notEqual :: (TensorType t, OneOf '[Complex Double, Complex Float, Bool, ByteString, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value Bool -- | Computes the complex absolute value of a tensor. -- -- Given a tensor x of complex numbers, this operation returns a -- tensor of type float or double that is the absolute -- value of each element in x. All elements in x must -- be complex numbers of the form \(a + bj\). The absolute value is -- computed as \( sqrt{a^2 + b^2}\). -- -- For example: -- -- ``` # tensor x is [[-2.25 + 4.75j], [-3.25 + 5.75j]] -- tf.complex_abs(x) ==> [5.25594902, 6.60492229] ``` complexAbs :: (TensorType t, OneOf '[Complex Double, Complex Float] t, TensorType tout, OneOf '[Double, Float] tout) => Tensor v1 t -> Tensor Value tout -- | Returns the truth value of x AND y element-wise. -- -- logicalAnd :: Tensor v1 Bool -> Tensor v2 Bool -> Tensor Value Bool batchFFT :: Tensor v1 (Complex Float) -> Tensor Value (Complex Float) -- | Selects elements from t or e, depending on -- condition. -- -- The t, and e tensors must all have the same shape, -- and the output will also have that shape. The condition -- tensor must be a scalar if t and e are scalars. If -- t and e are vectors or higher rank, then -- condition must be either a vector with size matching the -- first dimension of t, or must have the same shape as -- t. -- -- The condition tensor acts as a mask that chooses, based on -- the value at each element, whether the corresponding element / row in -- the output should be taken from t (if true) or e (if -- false). -- -- If condition is a vector and t and e are -- higher rank matrices, then it chooses which row (outer dimension) to -- copy from t and e. If condition has the -- same shape as t and e, then it chooses which element -- to copy from t and e. -- -- For example: -- -- ```prettyprint # condition tensor is [[True, False] # [False, -- True]] # t is [[1, 2], # [3, 4]] # e is [[5, 6], # -- [7, 8]] select(condition, t, e) ==> [[1, 6], [7, 4]] -- -- # condition tensor is [True, False] # t is [[1, 2], -- # [3, 4]] # e is [[5, 6], # [7, 8]] select(condition, t, e) -- ==> [[1, 2], [7, 8]] -- -- ``` select :: (TensorType t) => Tensor v1 Bool -> Tensor v2 t -> Tensor v3 t -> Tensor Value t -- | Multiply the matrix "a" by the matrix "b". -- -- The inputs must be two-dimensional matrices and the inner dimension of -- "a" (after being transposed if transpose_a is true) must match the -- outer dimension of "b" (after being transposed if transposed_b is -- true). -- -- matMul :: (TensorType t, OneOf '[Complex Double, Complex Float, Int32, Word16, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Computes Psi, the derivative of Lgamma (the log of the absolute value -- of -- -- `Gamma(x)`), element-wise. digamma :: (TensorType t, OneOf '[Word16, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Computes the gradients of convolution with respect to the filter. conv2DBackpropFilter :: (TensorType t, OneOf '[Word16, Double, Float] t) => Tensor v1 t -> Tensor v2 Int32 -> Tensor v3 t -> Tensor Value t -- | Computes the minimum of elements across dimensions of a tensor. -- -- Reduces input along the dimensions given in -- reduction_indices. Unless keep_dims is true, the -- rank of the tensor is reduced by 1 for each entry in -- reduction_indices. If keep_dims is true, the reduced -- dimensions are retained with length 1. min :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t, TensorType tidx, OneOf '[Int32, Int64] tidx) => Tensor v1 t -> Tensor v2 tidx -> Tensor Value t -- | Returns which elements of x are finite. isFinite :: (TensorType t, OneOf '[Word16, Double, Float] t) => Tensor v1 t -> Tensor Value Bool -- | Returns the index with the largest value across dimensions of a -- tensor. argMax :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t, TensorType tidx, OneOf '[Int32, Int64] tidx) => Tensor v1 t -> Tensor v2 tidx -> Tensor Value Int64 -- | Computes the mean along segments of a tensor. -- -- Read the section on Segmentation for an explanation of -- segments. -- -- Computes a tensor such that \(output_i = frac{sum_j data_j}{N}\) where -- mean is over j such that `segment_ids[j] == i` and -- N is the total number of values summed. -- -- style="width:70%; margin:auto; margin-bottom:10px; -- margin-top:20px;" style="width:100%" -- src="../../images/SegmentMean.png" alt /div segmentMean :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t, TensorType tindices, OneOf '[Int32, Int64] tindices) => Tensor v1 t -> Tensor v2 tindices -> Tensor Value t -- | Compute the cumulative product of the tensor x along -- axis. -- -- By default, this op performs an inclusive cumprod, which means that -- the first element of the input is identical to the first element of -- the output: ```prettyprint tf.cumprod([a, b, c]) ==> [a, a * b, a * -- b * c] ``` -- -- By setting the exclusive kwarg to True, an exclusive -- cumprod is performed instead: ```prettyprint tf.cumprod([a, b, c], -- exclusive=True) ==> [0, a, a * b] ``` -- -- By setting the reverse kwarg to True, the cumprod is -- performed in the opposite direction: ```prettyprint tf.cumprod([a, b, -- c], reverse=True) ==> [a * b * c, b * c, c] ``` This is more -- efficient than using separate `tf.reverse` ops. -- -- The reverse and exclusive kwargs can also be combined: -- ```prettyprint tf.cumprod([a, b, c], exclusive=True, reverse=True) -- ==> [b * c, c, 0] ``` cumprod :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t, TensorType tidx, OneOf '[Int32, Int64] tidx) => Tensor v1 t -> Tensor v2 tidx -> Tensor Value t -- | Computes the minimum along segments of a tensor. -- -- Read the section on Segmentation for an explanation of -- segments. -- -- Computes a tensor such that \(output_i = min_j(data_j)\) where -- min is over j such that `segment_ids[j] == i`. -- -- style="width:70%; margin:auto; margin-bottom:10px; -- margin-top:20px;" style="width:100%" -- src="../../images/SegmentMin.png" alt /div segmentMin :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t, TensorType tindices, OneOf '[Int32, Int64] tindices) => Tensor v1 t -> Tensor v2 tindices -> Tensor Value t -- | Computes the sum along segments of a tensor. -- -- Read the section on Segmentation for an explanation of -- segments. -- -- Computes a tensor such that `(output[i] = sum_{j...} data[j...]` where -- the sum is over tuples `j...` such that `segment_ids[j...] == i`. -- Unlike SegmentSum, segment_ids need not be sorted -- and need not cover all values in the full range of valid values. -- -- If the sum is empty for a given segment ID i, `output[i] = -- 0`. -- -- num_segments should equal the number of distinct segment IDs. -- -- style="width:70%; margin:auto; margin-bottom:10px; -- margin-top:20px;" style="width:100%" -- src="../../images/UnsortedSegmentSum.png" alt /div unsortedSegmentSum :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t, TensorType tindices, OneOf '[Int32, Int64] tindices) => Tensor v1 t -> Tensor v2 tindices -> Tensor v3 Int32 -> Tensor Value t -- | A Reader that outputs the records from a TensorFlow Records file. tFRecordReader :: Tensor Value ByteString -- | Computes the sum along sparse segments of a tensor. -- -- Read the section on Segmentation for an explanation of -- segments. -- -- Like SegmentSum, but segment_ids can have rank less -- than `data`'s first dimension, selecting a subset of dimension 0, -- specified by indices. -- -- For example: -- -- ```prettyprint c = tf.constant([[1,2,3,4], [-1,-2,-3,-4], [5,6,7,8]]) -- -- # Select two rows, one segment. tf.sparse_segment_sum(c, -- tf.constant([0, 1]), tf.constant([0, 0])) ==> [[0 0 0 0]] -- -- # Select two rows, two segment. tf.sparse_segment_sum(c, -- tf.constant([0, 1]), tf.constant([0, 1])) ==> [[ 1 2 3 4] [-1 -2 -3 -- -4]] -- -- # Select all rows, two segments. tf.sparse_segment_sum(c, -- tf.constant([0, 1, 2]), tf.constant([0, 0, 1])) ==> [[0 0 0 0] [5 6 -- 7 8]] -- -- # Which is equivalent to: tf.segment_sum(c, tf.constant([0, 0, 1])) -- ``` sparseSegmentSum :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t, TensorType tidx, OneOf '[Int32, Int64] tidx) => Tensor v1 t -> Tensor v2 tidx -> Tensor v3 Int32 -> Tensor Value t -- | Computes the sum along sparse segments of a tensor divided by the sqrt -- of N. -- -- N is the size of the segment being reduced. -- -- Read the section on Segmentation for an explanation of -- segments. sparseSegmentSqrtN :: (TensorType t, OneOf '[Double, Float] t, TensorType tidx, OneOf '[Int32, Int64] tidx) => Tensor v1 t -> Tensor v2 tidx -> Tensor v3 Int32 -> Tensor Value t -- | Copy Host Op. -- -- Performs CPU-to-CPU deep-copying of tensor. -- -- Unlike the Copy Op, this op has HostMemory constraint on its input or -- output. copyHost :: (TensorType t) => Tensor v1 t -> Tensor Value t -- | Holds state in the form of a tensor that persists across steps. -- -- Outputs a ref to the tensor state so it may be read or modified. -- TODO(zhifengc/mrry): Adds a pointer to a more detail document about -- sharing states in tensorflow. variable :: (TensorType dtype) => Tensor Value dtype -- | Computes gradients for SparseSegmentSqrtN. -- -- Returns tensor "output" with same shape as grad, except for dimension -- 0 whose value is output_dim0. sparseSegmentSqrtNGrad :: (TensorType t, OneOf '[Double, Float] t, TensorType tidx, OneOf '[Int32, Int64] tidx) => Tensor v1 t -> Tensor v2 tidx -> Tensor v3 Int32 -> Tensor v4 Int32 -> Tensor Value t -- | Creates a sequence of integers. -- -- This operation creates a sequence of integers that begins at -- start and extends by increments of delta up to but -- not including limit. -- -- For example: -- -- ``` # start is 3 # limit is 18 # delta is 3 -- tf.range(start, limit, delta) ==> [3, 6, 9, 12, 15] ``` range :: (TensorType tidx, OneOf '[Int32, Int64] tidx) => Tensor v1 tidx -> Tensor v2 tidx -> Tensor v3 tidx -> Tensor Value tidx -- | Computes the "logical or" of elements across dimensions of a tensor. -- -- Reduces input along the dimensions given in -- reduction_indices. Unless keep_dims is true, the -- rank of the tensor is reduced by 1 for each entry in -- reduction_indices. If keep_dims is true, the reduced -- dimensions are retained with length 1. any :: (TensorType tidx, OneOf '[Int32, Int64] tidx) => Tensor v1 Bool -> Tensor v2 tidx -> Tensor Value Bool -- | Generates values in an interval. -- -- A sequence of num evenly-spaced values are generated -- beginning at start. If `num > 1`, the values in the -- sequence increase by `stop - start / num - 1`, so that the last one is -- exactly stop. -- -- For example: -- -- ``` tf.linspace(10.0, 12.0, 3, name="linspace") => [ 10.0 11.0 -- 12.0] ``` linSpace :: (TensorType t, OneOf '[Double, Float] t, TensorType tidx, OneOf '[Int32, Int64] tidx) => Tensor v1 t -> Tensor v2 t -> Tensor v3 tidx -> Tensor Value t -- | Resize images to size using area interpolation. -- -- Input images can be of different types but output images are always -- float. resizeArea :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 Int32 -> Tensor Value Float -- | Returns the real part of a complex number. -- -- Given a tensor input of complex numbers, this operation -- returns a tensor of type float that is the real part of each -- element in input. All elements in input must be -- complex numbers of the form \(a + bj\), where *a* is the real part -- returned by this operation and *b* is the imaginary part. -- -- For example: -- -- ``` # tensor input is [-2.25 + 4.75j, 3.25 + 5.75j] -- tf.real(input) ==> [-2.25, 3.25] ``` real :: (TensorType t, OneOf '[Complex Double, Complex Float] t, TensorType tout, OneOf '[Double, Float] tout) => Tensor v1 t -> Tensor Value tout -- | Compute the inverse 1-dimensional discrete Fourier Transform over the -- inner-most -- -- dimension of input. iFFT :: Tensor v1 (Complex Float) -> Tensor Value (Complex Float) -- | Compute the inverse 3-dimensional discrete Fourier Transform over the -- inner-most -- -- 3 dimensions of input. iFFT3D :: Tensor v1 (Complex Float) -> Tensor Value (Complex Float) -- | Compute the pairwise cross product. -- -- 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. cross :: (TensorType t, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 t -> Tensor Value t -- | Compute the cumulative sum of the tensor x along -- axis. -- -- By default, this op performs an inclusive cumsum, which means that the -- first element of the input is identical to the first element of the -- output: ```prettyprint tf.cumsum([a, b, c]) ==> [a, a + b, a + b + -- c] ``` -- -- By setting the exclusive kwarg to True, an exclusive -- cumsum is performed instead: ```prettyprint tf.cumsum([a, b, c], -- exclusive=True) ==> [0, a, a + b] ``` -- -- By setting the reverse kwarg to True, the cumsum is -- performed in the opposite direction: ```prettyprint tf.cumsum([a, b, -- c], reverse=True) ==> [a + b + c, b + c, c] ``` This is more -- efficient than using separate `tf.reverse` ops. -- -- The reverse and exclusive kwargs can also be combined: -- ```prettyprint tf.cumsum([a, b, c], exclusive=True, reverse=True) -- ==> [b + c, c, 0] ``` cumsum :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t, TensorType tidx, OneOf '[Int32, Int64] tidx) => Tensor v1 t -> Tensor v2 tidx -> Tensor Value t batchIFFT :: Tensor v1 (Complex Float) -> Tensor Value (Complex Float) -- | Computes the Gauss error function of x element-wise. erf :: (TensorType t, OneOf '[Word16, Double, Float] t) => Tensor v1 t -> Tensor Value t -- | For each key, assigns the respective value to the specified component. -- -- If a key is not found in the barrier, this operation will create a new -- incomplete element. If a key is found in the barrier, and the element -- already has a value at component_index, this operation will fail with -- INVALID_ARGUMENT, and leave the barrier in an undefined state. barrierInsertMany :: (TensorType t) => Int64 -> Tensor v1 ByteString -> Tensor v2 ByteString -> Tensor v3 t -> ControlNode -- | Returns element-wise largest integer not greater than x. floor :: (TensorType t, OneOf '[Word16, Double, Float] t) => Tensor v1 t -> Tensor Value t batchFFT2D :: Tensor v1 (Complex Float) -> Tensor Value (Complex Float) -- | The gradient operator for the SparseAdd op. -- -- The SparseAdd op calculates A + B, where A, B, and the sum are all -- represented as SparseTensor objects. This op takes in the -- upstream gradient w.r.t. non-empty values of the sum, and outputs the -- gradients w.r.t. the non-empty values of A and B. sparseAddGrad :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 t -> Tensor v2 Int64 -> Tensor v3 Int64 -> Tensor v4 Int64 -> (Tensor Value t, Tensor Value t) -- | Adds two SparseTensor objects to produce another -- SparseTensor. -- -- The input SparseTensor objects' indices are assumed ordered -- in standard lexicographic order. If this is not the case, before this -- step run SparseReorder to restore index ordering. -- -- By default, if two values sum to zero at some index, the output -- SparseTensor would still include that particular location in -- its index, storing a zero in the corresponding value slot. To override -- this, callers can specify thresh, indicating that if the sum -- has a magnitude strictly smaller than thresh, its -- corresponding value and index would then not be included. In -- particular, `thresh == 0` (default) means everything is kept and -- actual thresholding happens only for a positive value. -- -- In the following shapes, nnz is the count after taking -- thresh into account. sparseAdd :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t, TensorType treal, OneOf '[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] treal) => Tensor v1 Int64 -> Tensor v2 t -> Tensor v3 Int64 -> Tensor v4 Int64 -> Tensor v5 t -> Tensor v6 Int64 -> Tensor v7 treal -> (Tensor Value Int64, Tensor Value t, Tensor Value Int64) batchCholesky :: (TensorType t, OneOf '[Double, Float] t) => Tensor v1 t -> Tensor Value t -- | Partitions `data` into num_partitions tensors using indices -- from partitions. -- -- For each index tuple js of size `partitions.ndim`, the slice -- `data[js, ...]` becomes part of `outputs[partitions[js]]`. The slices -- with `partitions[js] = i` are placed in `outputs[i]` in lexicographic -- order of js, and the first dimension of `outputs[i]` is the -- number of entries in partitions equal to i. In -- detail, -- -- outputs[i].shape = [sum(partitions == i)] + -- data.shape[partitions.ndim:] -- -- outputs[i] = pack([data[js, ...] for js if partitions[js] == i]) -- -- `data.shape` must start with `partitions.shape`. -- -- For example: -- -- # Scalar partitions partitions = 1 num_partitions = 2 data = [10, 20] -- outputs[0] = [] # Empty with shape [0, 2] outputs[1] = [[10, 20]] -- -- # Vector partitions partitions = [0, 0, 1, 1, 0] num_partitions = 2 -- data = [10, 20, 30, 40, 50] outputs[0] = [10, 20, 50] outputs[1] = -- [30, 40] -- -- style="width:70%; margin:auto; margin-bottom:10px; -- margin-top:20px;" style="width:100%" -- src="../../images/DynamicPartition.png" alt /div dynamicPartition :: (TensorType t) => Int64 -> Tensor v1 t -> Tensor v2 Int32 -> [Tensor Value t] -- | Serialize a SparseTensor into a string 3-vector (1-D -- Tensor) object. serializeSparse :: (TensorType t) => Tensor v1 Int64 -> Tensor v2 t -> Tensor v3 Int64 -> Tensor Value ByteString -- | Concatenates a list of SparseTensor along the specified -- dimension. -- -- Concatenation is with respect to the dense versions of these sparse -- tensors. It is assumed that each input is a SparseTensor -- whose elements are ordered along increasing dimension number. -- -- All inputs' shapes must match, except for the concat dimension. The -- indices, values, and shapes lists must have -- the same length. -- -- The output shape is identical to the inputs', except along the concat -- dimension, where it is the sum of the inputs' sizes along that -- dimension. -- -- The output elements will be resorted to preserve the sort order along -- increasing dimension number. -- -- This op runs in `O(M log M)` time, where M is the total -- number of non-empty values across all inputs. This is due to the need -- for an internal sort in order to concatenate efficiently across an -- arbitrary dimension. -- -- For example, if `concat_dim = 1` and the inputs are -- -- sp_inputs[0]: shape = [2, 3] [0, 2]: "a" [1, 0]: "b" [1, 1]: "c" -- -- sp_inputs[1]: shape = [2, 4] [0, 1]: "d" [0, 2]: "e" -- -- then the output will be -- -- shape = [2, 7] [0, 2]: "a" [0, 4]: "d" [0, 5]: "e" [1, 0]: "b" [1, 1]: -- "c" -- -- Graphically this is equivalent to doing -- -- sparseConcat :: (TensorType t) => Int64 -> [Tensor v1 Int64] -> [Tensor v2 t] -> [Tensor v3 Int64] -> (Tensor Value Int64, Tensor Value t, Tensor Value Int64) -- | Computes the product along segments of a tensor. -- -- Read the section on Segmentation for an explanation of -- segments. -- -- Computes a tensor such that \(output_i = prod_j data_j\) where the -- product is over j such that `segment_ids[j] == i`. -- -- style="width:70%; margin:auto; margin-bottom:10px; -- margin-top:20px;" style="width:100%" -- src="../../images/SegmentProd.png" alt /div segmentProd :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t, TensorType tindices, OneOf '[Int32, Int64] tindices) => Tensor v1 t -> Tensor v2 tindices -> Tensor Value t -- | Reshapes a SparseTensor to represent values in a new dense shape. -- -- This operation has the same semantics as reshape on the represented -- dense tensor. The input_indices are recomputed based on the -- requested new_shape. -- -- If one component of new_shape is the special value -1, the -- size of that dimension is computed so that the total dense size -- remains constant. At most one component of new_shape can be -- -1. The number of dense elements implied by new_shape must be -- the same as the number of dense elements originally implied by -- input_shape. -- -- Reshaping does not affect the order of values in the SparseTensor. -- -- If the input tensor has rank R_in and N non-empty -- values, and new_shape has length R_out, then -- input_indices has shape `[N, R_in]`, input_shape has -- length R_in, output_indices has shape `[N, R_out]`, -- and output_shape has length R_out. sparseReshape :: Tensor v1 Int64 -> Tensor v2 Int64 -> Tensor v3 Int64 -> (Tensor Value Int64, Tensor Value Int64) -- | Component-wise multiplies a SparseTensor by a dense Tensor. -- -- The output locations corresponding to the implicitly zero elements in -- the sparse tensor will be zero (i.e., will not take up storage space), -- regardless of the contents of the dense tensor (even if it's +/-INF -- and that INF*0 == NaN). -- -- sparseDenseCwiseMul :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 Int64 -> Tensor v2 t -> Tensor v3 Int64 -> Tensor v4 t -> Tensor Value t -- | Component-wise divides a SparseTensor by a dense Tensor. -- -- sparseDenseCwiseDiv :: (TensorType t, OneOf '[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float] t) => Tensor v1 Int64 -> Tensor v2 t -> Tensor v3 Int64 -> Tensor v4 t -> Tensor Value t