tensorflow-core-ops-0.1.0.0: Haskell wrappers for Core Tensorflow Ops.

Safe HaskellNone
LanguageHaskell2010

TensorFlow.GenOps.Core

Synopsis

Documentation

_HostRecv Source

Arguments

:: TensorType tensor_type 
=> Int64

send_device_incarnation: The current incarnation of send_device.

-> Tensor Value tensor_type

tensor: The tensor to receive.

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.

_Recv Source

Arguments

:: TensorType tensor_type 
=> Int64

send_device_incarnation: The current incarnation of send_device.

-> Tensor Value tensor_type

tensor: The tensor to receive.

Receives the named tensor from send_device on recv_device.

_Send Source

Arguments

:: TensorType t 
=> Int64

send_device_incarnation: The current incarnation of send_device.

-> Tensor v1 t

tensor: The tensor to send.

-> ControlNode 

Sends the named tensor from send_device to recv_device.

_Arg Source

Arguments

:: TensorType t 
=> Int64

index: This argument is the index-th argument of the function.

-> Tensor Value t

output: The argument.

A graph node which represents an argument to a function.

sparseApplyRMSProp Source

Arguments

:: (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

var: Should be from a Variable().

-> Tensor v2 t

ms: Should be from a Variable().

-> Tensor v3 t

mom: Should be from a Variable().

-> Tensor v4 t

lr: Scaling factor. Must be a scalar.

-> Tensor v5 t

rho: Decay rate. Must be a scalar.

-> Tensor v6 t

momentum

-> Tensor v7 t

epsilon: Ridge term. Must be a scalar.

-> Tensor v8 t

grad: The gradient.

-> Tensor v9 tindices

indices: A vector of indices into the first dimension of var, ms and mom.

-> Tensor Value t

out: Same as "var".

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

applyAdam Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

var: Should be from a Variable().

-> Tensor v2 t

m: Should be from a Variable().

-> Tensor v3 t

v: Should be from a Variable().

-> Tensor v4 t

beta1_power: Must be a scalar.

-> Tensor v5 t

beta2_power: Must be a scalar.

-> Tensor v6 t

lr: Scaling factor. Must be a scalar.

-> Tensor v7 t

beta1: Momentum factor. Must be a scalar.

-> Tensor v8 t

beta2: Momentum factor. Must be a scalar.

-> Tensor v9 t

epsilon: Ridge term. Must be a scalar.

-> Tensor v10 t

grad: The gradient.

-> Tensor Value t

out: Same as "var".

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)

sparseApplyMomentum Source

Arguments

:: (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

var: Should be from a Variable().

-> Tensor v2 t

accum: Should be from a Variable().

-> Tensor v3 t

lr: Learning rate. Must be a scalar.

-> Tensor v4 t

grad: The gradient.

-> Tensor v5 tindices

indices: A vector of indices into the first dimension of var and accum.

-> Tensor v6 t

momentum: Momentum. Must be a scalar.

-> Tensor Value t

out: Same as "var".

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

applyMomentum Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

var: Should be from a Variable().

-> Tensor v2 t

accum: Should be from a Variable().

-> Tensor v3 t

lr: Scaling factor. Must be a scalar.

-> Tensor v4 t

grad: The gradient.

-> Tensor v5 t

momentum: Momentum. Must be a scalar.

-> Tensor Value t

out: Same as "var".

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

applyFtrl Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

var: Should be from a Variable().

-> Tensor v2 t

accum: Should be from a Variable().

-> Tensor v3 t

linear: Should be from a Variable().

-> Tensor v4 t

grad: The gradient.

-> Tensor v5 t

lr: Scaling factor. Must be a scalar.

-> Tensor v6 t

l1: L1 regulariation. Must be a scalar.

-> Tensor v7 t

l2: L2 regulariation. Must be a scalar.

-> Tensor v8 t

lr_power: Scaling factor. Must be a scalar.

-> Tensor Value t

out: Same as "var".

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

sparseApplyAdagradDA Source

Arguments

:: (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

var: Should be from a Variable().

-> Tensor v2 t

gradient_accumulator: Should be from a Variable().

-> Tensor v3 t

gradient_squared_accumulator: Should be from a Variable().

-> Tensor v4 t

grad: The gradient.

-> Tensor v5 tindices

indices: A vector of indices into the first dimension of var and accum.

-> Tensor v6 t

lr: Learning rate. Must be a scalar.

-> Tensor v7 t

l1: L1 regularization. Must be a scalar.

-> Tensor v8 t

l2: L2 regularization. Must be a scalar.

-> Tensor v9 Int64

global_step: Training step number. Must be a scalar.

-> Tensor Value t

out: Same as "var".

Update entries in '*var' and '*accum' according to the proximal adagrad scheme.

sparseApplyAdagrad Source

Arguments

:: (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

var: Should be from a Variable().

-> Tensor v2 t

accum: Should be from a Variable().

-> Tensor v3 t

lr: Learning rate. Must be a scalar.

-> Tensor v4 t

grad: The gradient.

-> Tensor v5 tindices

indices: A vector of indices into the first dimension of var and accum.

-> Tensor Value t

out: Same as "var".

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))

applyProximalAdagrad Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

var: Should be from a Variable().

-> Tensor v2 t

accum: Should be from a Variable().

-> Tensor v3 t

lr: Scaling factor. Must be a scalar.

-> Tensor v4 t

l1: L1 regularization. Must be a scalar.

-> Tensor v5 t

l2: L2 regularization. Must be a scalar.

-> Tensor v6 t

grad: The gradient.

-> Tensor Value t

out: Same as "var".

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}

applyAdagrad Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

var: Should be from a Variable().

-> Tensor v2 t

accum: Should be from a Variable().

-> Tensor v3 t

lr: Scaling factor. Must be a scalar.

-> Tensor v4 t

grad: The gradient.

-> Tensor Value t

out: Same as "var".

Update '*var' according to the adagrad scheme.

accum += grad * grad var -= lr * grad * (1 / sqrt(accum))

applyAdadelta Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

var: Should be from a Variable().

-> Tensor v2 t

accum: Should be from a Variable().

-> Tensor v3 t

accum_update: Should be from a Variable().

-> Tensor v4 t

lr: Scaling factor. Must be a scalar.

-> Tensor v5 t

rho: Decay factor. Must be a scalar.

-> Tensor v6 t

epsilon: Constant factor. Must be a scalar.

-> Tensor v7 t

grad: The gradient.

-> Tensor Value t

out: Same as "var".

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;

sparseApplyProximalGradientDescent Source

Arguments

:: (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

var: Should be from a Variable().

-> Tensor v2 t

alpha: Scaling factor. Must be a scalar.

-> Tensor v3 t

l1: L1 regularization. Must be a scalar.

-> Tensor v4 t

l2: L2 regularization. Must be a scalar.

-> Tensor v5 t

grad: The gradient.

-> Tensor v6 tindices

indices: A vector of indices into the first dimension of var and accum.

-> Tensor Value t

out: Same as "var".

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}

applyProximalGradientDescent Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

var: Should be from a Variable().

-> Tensor v2 t

alpha: Scaling factor. Must be a scalar.

-> Tensor v3 t

l1: L1 regularization. Must be a scalar.

-> Tensor v4 t

l2: L2 regularization. Must be a scalar.

-> Tensor v5 t

delta: The change.

-> Tensor Value t

out: Same as "var".

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}

encodeBase64 Source

Arguments

:: Tensor v1 ByteString

input: Strings to be encoded.

-> Tensor Value ByteString

output: Input strings encoded in base64.

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 /.

stringSplit Source

Arguments

:: Tensor v1 ByteString

input: 1-D. Strings to split.

-> Tensor v2 ByteString

delimiter: 0-D. Delimiter character, or empty string.

-> (Tensor Value Int64, Tensor Value ByteString, Tensor Value Int64)

(indices, values, shape)

  • indices: A dense matrix of int64 representing the indices of the sparse tensor.
  • values: A vector of strings corresponding to the splited values.
  • shape: a length-2 vector of int64 representing the shape of the sparse tensor, where the first value is N and the second value is the maximum number of tokens in a single input entry.

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]

stringJoin Source

Arguments

:: [Tensor v1 ByteString]

inputs: A list of string tensors. The tensors must all have the same shape, or be scalars. Scalars may be mixed in; these will be broadcast to the shape of non-scalar inputs.

-> Tensor Value ByteString

output

Joins the strings in the given list of string tensors into one tensor;

with the given separator (default is an empty separator).

asString Source

Arguments

:: (TensorType t, OneOf `[Complex Float, Bool, Int32, Int64, Int8, Double, Float]` t) 
=> Tensor v1 t

input

-> Tensor Value ByteString

output

Converts each entry in the given tensor to strings. Supports many numeric

types and boolean.

stringToHashBucketStrong Source

Arguments

:: Int64

num_buckets: The number of buckets.

-> Tensor v1 ByteString

input: The strings to assign a hash bucket.

-> Tensor Value Int64

output: A Tensor of the same shape as the input string_tensor.

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.

scatterMul Source

Arguments

:: (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

ref: Should be from a Variable node.

-> Tensor v2 tindices

indices: A tensor of indices into the first dimension of ref.

-> Tensor v3 t

updates: A tensor of updated values to multiply to ref.

-> Tensor Value t

output_ref: = Same as ref. Returned as a convenience for operations that want to use the updated values after the update is done.

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:]`.

reduceJoin Source

Arguments

:: Tensor v1 ByteString

inputs: The input to be joined. All reduced indices must have non-zero size.

-> Tensor v2 Int32

reduction_indices: The dimensions to reduce over. Dimensions are reduced in the order specified. Omitting reduction_indices is equivalent to passing `[n-1, n-2, ..., 0]`. Negative indices from `-n` to `-1` are supported.

-> Tensor Value ByteString

output: Has shape equal to that of the input with reduced dimensions removed or set to `1` depending on keep_dims.

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"] ```

scatterSub Source

Arguments

:: (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

ref: Should be from a Variable node.

-> Tensor v2 tindices

indices: A tensor of indices into the first dimension of ref.

-> Tensor v3 t

updates: A tensor of updated values to subtract from ref.

-> Tensor Value t

output_ref: = Same as ref. Returned as a convenience for operations that want to use the updated values after the update is done.

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

scatterAdd Source

Arguments

:: (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

ref: Should be from a Variable node.

-> Tensor v2 tindices

indices: A tensor of indices into the first dimension of ref.

-> Tensor v3 t

updates: A tensor of updated values to add to ref.

-> Tensor Value t

output_ref: = Same as ref. Returned as a convenience for operations that want to use the updated values after the update is done.

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

scatterUpdate Source

Arguments

:: (TensorType t, TensorType tindices, OneOf `[Int32, Int64]` tindices) 
=> Tensor v1 t

ref: Should be from a Variable node.

-> Tensor v2 tindices

indices: A tensor of indices into the first dimension of ref.

-> Tensor v3 t

updates: A tensor of updated values to store in ref.

-> Tensor Value t

output_ref: = Same as ref. Returned as a convenience for operations that want to use the updated values after the update is done.

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

assignSub Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

ref: Should be from a Variable node.

-> Tensor v2 t

value: The value to be subtracted to the variable.

-> Tensor Value t

output_ref: = Same as "ref". Returned as a convenience for operations that want to use the new value after the variable has been updated.

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.

assignAdd Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

ref: Should be from a Variable node.

-> Tensor v2 t

value: The value to be added to the variable.

-> Tensor Value t

output_ref: = Same as "ref". Returned as a convenience for operations that want to use the new value after the variable has been updated.

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.

sparseSegmentMeanGrad Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t, TensorType tidx, OneOf `[Int32, Int64]` tidx) 
=> Tensor v1 t

grad: gradient propagated to the SparseSegmentMean op.

-> Tensor v2 tidx

indices: indices passed to the corresponding SparseSegmentMean op.

-> Tensor v3 Int32

segment_ids: segment_ids passed to the corresponding SparseSegmentMean op.

-> Tensor v4 Int32

output_dim0: dimension 0 of "data" passed to SparseSegmentMean op.

-> Tensor Value t

output

Computes gradients for SparseSegmentMean.

Returns tensor "output" with same shape as grad, except for dimension 0 whose value is output_dim0.

sparseSoftmax Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t) 
=> Tensor v1 Int64

sp_indices: 2-D. `NNZ x R` matrix with the indices of non-empty values in a SparseTensor, in canonical ordering.

-> Tensor v2 t

sp_values: 1-D. NNZ non-empty values corresponding to sp_indices.

-> Tensor v3 Int64

sp_shape: 1-D. Shape of the input SparseTensor.

-> Tensor Value t

output: 1-D. The NNZ values for the result SparseTensor.

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. Masks out the original implicitly-zero locations;
  3. Renormalizes the remaining elements.

Hence, the SparseTensor result has exactly the same non-zero indices and shape.

matrixSolve Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t) 
=> Tensor v1 t

matrix: Shape is `[..., M, M]`.

-> Tensor v2 t

rhs: Shape is `[..., M, K]`.

-> Tensor Value t

output: Shape is `[..., M, K]`.

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[..., :, :]`.

selfAdjointEigV2 Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t) 
=> Tensor v1 t

input: Tensor input of shape `[N, N]`.

-> (Tensor Value t, Tensor Value t)

(e, v)

  • e: Eigenvalues. Shape is `[N]`.
  • v: Eigenvectors. Shape is `[N, N]`.

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) ```

selfAdjointEig Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t) 
=> Tensor v1 t

input: Shape is `[..., M, M]`.

-> Tensor Value t

output: Shape is `[..., M+1, M]`.

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.

applyGradientDescent Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

var: Should be from a Variable().

-> Tensor v2 t

alpha: Scaling factor. Must be a scalar.

-> Tensor v3 t

delta: The change.

-> Tensor Value t

out: Same as "var".

Update '*var' by subtracting alpha * delta from it.

stackPush Source

Arguments

:: TensorType t 
=> Tensor v1 ByteString

handle: The handle to a stack.

-> Tensor v2 t

elem: The tensor to be pushed onto the stack.

-> Tensor Value t

output: The same tensor as the input elem.

Push an element onto the stack.

cholesky Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t) 
=> Tensor v1 t

input: Shape is `[..., M, M]`.

-> Tensor Value t

output: Shape is `[..., M, M]`.

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 `[..., :, :]`.

dynamicStitch Source

Arguments

:: TensorType t 
=> [Tensor v1 Int32]

indices

-> [Tensor v2 t]

data

-> Tensor Value t

merged

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

readerNumWorkUnitsCompleted Source

Arguments

:: Tensor v1 ByteString

reader_handle: Handle to a Reader.

-> Tensor Value Int64

units_completed

Returns the number of work units this Reader has finished processing.

readerRead Source

Arguments

:: Tensor v1 ByteString

reader_handle: Handle to a Reader.

-> Tensor v2 ByteString

queue_handle: Handle to a Queue, with string work items.

-> (Tensor Value ByteString, Tensor Value ByteString)

(key, value)

  • key: A scalar.
  • value: A scalar.

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).

fFT2D Source

Arguments

:: Tensor v1 (Complex Float)

input: A complex64 tensor.

-> Tensor Value (Complex Float)

output: A complex64 tensor of the same shape as input. The inner-most 2 dimensions of input are replaced with their 2D Fourier Transform.

Compute the 2-dimensional discrete Fourier Transform over the inner-most

2 dimensions of input.

fixedLengthRecordReader Source

Arguments

:: Int64

record_bytes

-> Tensor Value ByteString

reader_handle: The handle to reference the Reader.

A Reader that outputs fixed-length records from a file.

placeholder Source

Arguments

:: TensorType dtype 
=> Tensor Value dtype

output: A placeholder tensor that must be replaced using the feed mechanism.

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.

scalarSummary Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 ByteString

tags: Tags for the summary.

-> Tensor v2 t

values: Same shape as `tags. Values for the summary.

-> Tensor Value ByteString

summary: Scalar. Serialized Summary protocol buffer.

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.

softmax Source

Arguments

:: (TensorType t, OneOf `[Word16, Double, Float]` t) 
=> Tensor v1 t

logits: 2-D with shape `[batch_size, num_classes]`.

-> Tensor Value t

softmax: Same shape as logits.

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]))

shardedFilename Source

Arguments

:: Tensor v1 ByteString

basename

-> Tensor v2 Int32

shard

-> Tensor v3 Int32

num_shards

-> Tensor Value ByteString

filename

Generate a sharded filename. The filename is printf formatted as

%s-%05d-of-%05d, basename, shard, num_shards.

_HostSend Source

Arguments

:: TensorType t 
=> Int64

send_device_incarnation: The current incarnation of send_device.

-> Tensor v1 t

tensor: The tensor to send.

-> ControlNode 

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.

sigmoidGrad Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor v2 t

y

-> Tensor Value t

z

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.

nonMaxSuppression Source

Arguments

:: Tensor v1 Float

boxes: A 2-D float tensor of shape `[num_boxes, 4]`.

-> Tensor v2 Float

scores: A 1-D float tensor of shape `[num_boxes]` representing a single score corresponding to each box (each row of boxes).

-> Tensor v3 Int32

max_output_size: A scalar integer tensor representing the maximum number of boxes to be selected by non max suppression.

-> Tensor Value Int32

selected_indices: A 1-D integer tensor of shape `[M]` representing the selected indices from the boxes tensor, where `M <= max_output_size`.

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)

identityReader Source

Arguments

:: Tensor Value ByteString

reader_handle: The handle to reference the Reader.

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).

extractGlimpse Source

Arguments

:: Tensor v1 Float

input: A 4-D float tensor of shape `[batch_size, height, width, channels]`.

-> Tensor v2 Int32

size: A 1-D tensor of 2 elements containing the size of the glimpses to extract. The glimpse height must be specified first, following by the glimpse width.

-> Tensor v3 Float

offsets: A 2-D integer tensor of shape `[batch_size, 2]` containing the x, y locations of the center of each window.

-> Tensor Value Float

glimpse: A tensor representing the glimpses `[batch_size, glimpse_height, glimpse_width, channels]`.

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:

  • If the coordinates are normalized but not centered, 0.0 and 1.0 correspond to the minimum and maximum of each height and width dimension.
  • If the coordinates are both normalized and centered, they range from
  • 1.0 to 1.0. The coordinates (-1.0, -1.0) correspond to the upper left corner, the lower right corner is located at (1.0, 1.0) and the center is at (0, 0).
  • If the coordinates are not normalized they are interpreted as numbers of pixels.

conv3DBackpropInput Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

input: Shape `[batch, depth, rows, cols, in_channels]`.

-> Tensor v2 t

filter: Shape `[depth, rows, cols, in_channels, out_channels]`. in_channels must match between input and filter.

-> Tensor v3 t

out_backprop: Backprop signal of shape `[batch, out_depth, out_rows, out_cols, out_channels]`.

-> Tensor Value t

output

Computes the gradients of 3-D convolution with respect to the input.

matrixSolveLs Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t) 
=> Tensor v1 t

matrix: Shape is `[..., M, N]`.

-> Tensor v2 t

rhs: Shape is `[..., M, K]`.

-> Tensor v3 Double

l2_regularizer: Scalar tensor.

-> Tensor Value t

output: Shape is `[..., N, K]`.

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.

rGBToHSV Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t) 
=> Tensor v1 t

images: 1-D or higher rank. RGB data to convert. Last dimension must be size 3.

-> Tensor Value t

output: images converted to HSV.

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.

decodeGif Source

Arguments

:: Tensor v1 ByteString

contents: 0-D. The GIF-encoded image.

-> Tensor Value Word8

image: 4-D with shape `[num_frames, height, width, 3]`. RGB order

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

adjustContrast Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word8, Double, Float]` t) 
=> Tensor v1 t

images

-> Tensor v2 Float

contrast_factor

-> Tensor v3 Float

min_value

-> Tensor v4 Float

max_value

-> Tensor Value Float

output

Deprecated. Disallowed in GraphDef version >= 2.

depthToSpace Source

Arguments

:: TensorType t 
=> Int64

block_size: The size of the spatial block, same as in Space2Depth.

-> Tensor v1 t

input

-> Tensor Value t

output

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.

  • Chunks of data of size `block_size * block_size` from depth are rearranged into non-overlapping blocks of size `block_size x block_size`
  • The width the output tensor is `input_depth * block_size`, whereas the height is `input_height * block_size`.
  • The depth of the input tensor must be divisible by `block_size * block_size`.

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]]]

```

batchMatrixSolve Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t) 
=> Tensor v1 t

matrix

-> Tensor v2 t

rhs

-> Tensor Value t

output

erfc Source

Arguments

:: (TensorType t, OneOf `[Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor Value t

y

Computes the complementary error function of x element-wise.

resizeBilinearGrad Source

Arguments

:: (TensorType t, OneOf `[Word16, Double, Float]` t) 
=> Tensor v1 Float

grads: 4-D with shape `[batch, height, width, channels]`.

-> Tensor v2 t

original_image: 4-D with shape `[batch, orig_height, orig_width, channels]`, The image tensor that was resized.

-> Tensor Value t

output: 4-D with shape `[batch, orig_height, orig_width, channels]`. Gradients with respect to the input image. Input image must have been float or double.

Computes the gradient of bilinear interpolation.

fact Source

Arguments

:: Tensor Value ByteString

fact

Output a fact about factorials.

deleteSessionTensor Source

Arguments

:: Tensor v1 ByteString

handle: The handle for a tensor stored in the session state.

-> ControlNode 

Delete the tensor specified by its handle in the session.

logicalOr Source

Arguments

:: Tensor v1 Bool

x

-> Tensor v2 Bool

y

-> Tensor Value Bool

z

Returns the truth value of x OR y element-wise.

  • NOTE*: LogicalOr supports broadcasting. More about broadcasting here

getSessionTensor Source

Arguments

:: TensorType dtype 
=> Tensor v1 ByteString

handle: The handle for a tensor stored in the session state.

-> Tensor Value dtype

value: The tensor for the given handle.

Get the value of the tensor specified by its handle.

batchMatrixInverse Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t) 
=> Tensor v1 t

input

-> Tensor Value t

output

shardedFilespec Source

Arguments

:: Tensor v1 ByteString

basename

-> Tensor v2 Int32

num_shards

-> Tensor Value ByteString

filename

Generate a glob pattern matching all sharded file names.

decodeBase64 Source

Arguments

:: Tensor v1 ByteString

input: Base64 strings to decode.

-> Tensor Value ByteString

output: Decoded strings.

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 /.

getSessionHandle Source

Arguments

:: TensorType t 
=> Tensor v1 t

value: The tensor to be stored.

-> Tensor Value ByteString

handle: The handle for the tensor stored in the session state.

Store the input tensor in the state of the current session.

initializeTable Source

Arguments

:: (TensorType tkey, TensorType tval) 
=> Tensor v1 ByteString

table_handle: Handle to a table which will be initialized.

-> Tensor v2 tkey

keys: Keys of type Tkey.

-> Tensor v3 tval

values: Values of type Tval.

-> ControlNode 

Table initializer that takes two tensors for keys and values respectively.

tan Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int32, Int64, Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor Value t

y

Computes tan of x element-wise.

tanh Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor Value t

y

Computes hyperbolic tangent of x element-wise.

applyAdagradDA Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

var: Should be from a Variable().

-> Tensor v2 t

gradient_accumulator: Should be from a Variable().

-> Tensor v3 t

gradient_squared_accumulator: Should be from a Variable().

-> Tensor v4 t

grad: The gradient.

-> Tensor v5 t

lr: Scaling factor. Must be a scalar.

-> Tensor v6 t

l1: L1 regularization. Must be a scalar.

-> Tensor v7 t

l2: L2 regularization. Must be a scalar.

-> Tensor v8 Int64

global_step: Training step number. Must be a scalar.

-> Tensor Value t

out: Same as "var".

Update '*var' according to the proximal adagrad scheme.

stringToHashBucket Source

Arguments

:: Int64

num_buckets: The number of buckets.

-> Tensor v1 ByteString

string_tensor

-> Tensor Value Int64

output: A Tensor of the same shape as the input string_tensor.

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()`.

eluGrad Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

gradients: The backpropagated gradients to the corresponding Elu operation.

-> Tensor v2 t

outputs: The outputs of the corresponding Elu operation.

-> Tensor Value t

backprops: The gradients: `gradients * (outputs + 1)` if outputs < 0, gradients otherwise.

Computes gradients for the exponential linear (Elu) operation.

fractionalAvgPoolGrad Source

Arguments

:: (TensorType t, OneOf `[Int32, Int64, Double, Float]` t) 
=> Tensor v1 Int64

orig_input_tensor_shape: Original input tensor shape for fractional_avg_pool

-> Tensor v2 t

out_backprop: 4-D with shape `[batch, height, width, channels]`. Gradients w.r.t. the output of fractional_avg_pool.

-> Tensor v3 Int64

row_pooling_sequence: row pooling sequence, form pooling region with col_pooling_sequence.

-> Tensor v4 Int64

col_pooling_sequence: column pooling sequence, form pooling region with row_pooling sequence.

-> Tensor Value t

output: 4-D. Gradients w.r.t. the input of fractional_avg_pool.

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.

matrixTriangularSolve Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t) 
=> Tensor v1 t

matrix: Shape is `[..., M, M]`.

-> Tensor v2 t

rhs: Shape is `[..., M, K]`.

-> Tensor Value t

output: Shape is `[..., M, K]`.

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]`.

editDistance Source

Arguments

:: TensorType t 
=> Tensor v1 Int64

hypothesis_indices: The indices of the hypothesis list SparseTensor. This is an N x R int64 matrix.

-> Tensor v2 t

hypothesis_values: The values of the hypothesis list SparseTensor. This is an N-length vector.

-> Tensor v3 Int64

hypothesis_shape: The shape of the hypothesis list SparseTensor. This is an R-length vector.

-> Tensor v4 Int64

truth_indices: The indices of the truth list SparseTensor. This is an M x R int64 matrix.

-> Tensor v5 t

truth_values: The values of the truth list SparseTensor. This is an M-length vector.

-> Tensor v6 Int64

truth_shape: truth indices, vector.

-> Tensor Value Float

output: A dense float tensor with rank R - 1.

For the example input:

// hypothesis represents a 2x1 matrix with variable-length values: // (0,0) = ["a"] // (1,0) = ["b"] hypothesis_indices = [[0, 0, 0], [1, 0, 0]] hypothesis_values = ["a", "b"] hypothesis_shape = [2, 1, 1]

// truth represents a 2x2 matrix with variable-length values: // (0,0) = [] // (0,1) = ["a"] // (1,0) = ["b", "c"] // (1,1) = ["a"] truth_indices = [[0, 1, 0], [1, 0, 0], [1, 0, 1], [1, 1, 0]] truth_values = ["a", "b", "c", "a"] truth_shape = [2, 2, 2] normalize = true

The output will be:

// output is a 2x2 matrix with edit distances normalized by truth lengths. output = [[inf, 1.0], // (0,0): no truth, (0,1): no hypothesis [0.5, 1.0]] // (1,0): addition, (1,1): no hypothesis

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:

barrierIncompleteSize Source

Arguments

:: Tensor v1 ByteString

handle: The handle to a barrier.

-> Tensor Value Int32

size: The number of incomplete elements (i.e. those with some of their value components not set) in the barrier.

Computes the number of incomplete elements in the given barrier.

threadUnsafeUnigramCandidateSampler Source

Arguments

:: Int64

num_sampled: Number of candidates to randomly sample per batch.

-> Int64

num_true: Number of true labels per context.

-> Int64

range_max: The sampler will sample integers from the interval [0, range_max).

-> Bool

unique: If unique is true, we sample with rejection, so that all sampled candidates in a batch are unique. This requires some approximation to estimate the post-rejection sampling probabilities.

-> Tensor v1 Int64

true_classes: A batch_size * num_true matrix, in which each row contains the IDs of the num_true target_classes in the corresponding original label.

-> (Tensor Value Int64, Tensor Value Float, Tensor Value Float)

(sampled_candidates, true_expected_count, sampled_expected_count)

  • sampled_candidates: A vector of length num_sampled, in which each element is the ID of a sampled candidate.
  • true_expected_count: A batch_size * num_true matrix, representing the number of times each candidate is expected to occur in a batch of sampled candidates. If unique=true, then this is a probability.
  • sampled_expected_count: A vector of length num_sampled, for each sampled candidate representing the number of times the candidate is expected to occur in a batch of sampled candidates. If unique=true, then this is a probability.

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.

barrierReadySize Source

Arguments

:: Tensor v1 ByteString

handle: The handle to a barrier.

-> Tensor Value Int32

size: The number of complete elements (i.e. those with all of their value components set) in the barrier.

Computes the number of complete elements in the given barrier.

barrierClose Source

Arguments

:: Tensor v1 ByteString

handle: The handle to a barrier.

-> ControlNode 

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.

textLineReader Source

Arguments

:: Tensor Value ByteString

reader_handle: The handle to reference the Reader.

A Reader that outputs the lines of a file delimited by '\n'.

fFT3D Source

Arguments

:: Tensor v1 (Complex Float)

input: A complex64 tensor.

-> Tensor Value (Complex Float)

output: A complex64 tensor of the same shape as input. The inner-most 3 dimensions of input are replaced with their 3D Fourier Transform.

Compute the 3-dimensional discrete Fourier Transform over the inner-most 3

dimensions of input.

refExit Source

Arguments

:: TensorType t 
=> Tensor v1 t

data: The tensor to be made available to the parent frame.

-> Tensor Value t

output: The same tensor as `data`.

Exits the current frame to its parent frame.

Exit makes its input `data` available to the parent frame.

exp Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor Value t

y

Computes exponential of x element-wise. \(y = e^x\).

restoreSlice Source

Arguments

:: TensorType dt 
=> Tensor v1 ByteString

file_pattern: Must have a single element. The pattern of the files from which we read the tensor.

-> Tensor v2 ByteString

tensor_name: Must have a single element. The name of the tensor to be restored.

-> Tensor v3 ByteString

shape_and_slice: Scalar. The shapes and slice specifications to use when restoring a tensors.

-> Tensor Value dt

tensor: The restored tensor.

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.

conj Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float]` t) 
=> Tensor v1 t

input

-> Tensor Value t

output

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] ```

resizeNearestNeighborGrad Source

Arguments

:: (TensorType t, OneOf `[Int32, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

grads: 4-D with shape `[batch, height, width, channels]`.

-> Tensor v2 Int32

size: = A 1-D int32 Tensor of 2 elements: `orig_height, orig_width`. The original input size.

-> Tensor Value t

output: 4-D with shape `[batch, orig_height, orig_width, channels]`. Gradients with respect to the input image.

Computes the gradient of nearest neighbor interpolation.

tensorArrayClose Source

Arguments

:: Tensor v1 ByteString

handle: The handle to a TensorArray (output of TensorArray or TensorArrayGrad).

-> ControlNode 

Delete the TensorArray from its resource container. This enables

the user to close and release the resource in the middle of a step/run.

atan Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int32, Int64, Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor Value t

y

Computes atan of x element-wise.

tensorArraySize Source

Arguments

:: Tensor v1 ByteString

handle: The handle to a TensorArray (output of TensorArray or TensorArrayGrad).

-> Tensor v2 Float

flow_in: A float scalar that enforces proper chaining of operations.

-> Tensor Value Int32

size: The current size of the TensorArray.

Get the current size of the TensorArray.

tensorArrayConcat Source

Arguments

:: TensorType dtype 
=> Tensor v1 ByteString

handle: The handle to a TensorArray.

-> Tensor v2 Float

flow_in: A float scalar that enforces proper chaining of operations.

-> (Tensor Value dtype, Tensor Value Int64)

(value, lengths)

  • value: All of the elements in the TensorArray, concatenated along the first axis.
  • lengths: A vector of the row sizes of the original T elements in the value output. In the example above, this would be the values: `(n1, n2, ..., n(T-1))`.

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).

lRN Source

Arguments

:: (TensorType t, OneOf `[Word16, Float]` t) 
=> Tensor v1 t

input: 4-D.

-> Tensor Value t

output

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).

stringToHashBucketFast Source

Arguments

:: Int64

num_buckets: The number of buckets.

-> Tensor v1 ByteString

input: The strings to assign a hash bucket.

-> Tensor Value Int64

output: A Tensor of the same shape as the input string_tensor.

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`.

tensorArrayPack Source

Arguments

:: TensorType dtype 
=> Tensor v1 ByteString

handle: The handle to a TensorArray.

-> Tensor v2 Float

flow_in: A float scalar that enforces proper chaining of operations.

-> Tensor Value dtype

value: All of the elements in the TensorArray, concatenated along a new axis (the new dimension 0).

Pack the elements from the TensorArray into output value.

  • *WARNING: This op is deprecated.**

Instead of this op, use TensorArrayGather with `indices = RangeOp(0, TensorArraySizeOp)`.

All elements must have the same shape.

concatOffset Source

Arguments

:: Tensor v1 Int32

concat_dim: The dimension along which to concatenate.

-> [Tensor v2 Int32]

shape: The N int32 vectors representing shape of tensors being concatenated.

-> [Tensor Value Int32]

offset: The N int32 vectors representing the starting offset of input tensors within the concatenated output.

This is typically used by gradient computations for a concat operation.

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] ```

refEnter Source

Arguments

:: TensorType t 
=> Tensor v1 t

data: The tensor to be made available to the child frame.

-> Tensor Value t

output: The same tensor as `data`.

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.

softsign Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

features

-> Tensor Value t

activations

Computes softsign: `features / (abs(features) + 1)`.

tensorArrayWrite Source

Arguments

:: TensorType t 
=> Tensor v1 ByteString

handle: The handle to a TensorArray.

-> Tensor v2 Int32

index: The position to write to inside the TensorArray.

-> Tensor v3 t

value: The tensor to write to the TensorArray.

-> Tensor v4 Float

flow_in: A float scalar that enforces proper chaining of operations.

-> Tensor Value Float

flow_out: A float scalar that enforces proper chaining of operations.

Push an element onto the tensor_array.

diag Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int32, Int64, Double, Float]` t) 
=> Tensor v1 t

diagonal: Rank k tensor where k is at most 3.

-> Tensor Value t

output

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]] ```

matrixDiagPart Source

Arguments

:: TensorType t 
=> Tensor v1 t

input: Rank k tensor where `k >= 2` and the last two dimensions are equal.

-> Tensor Value t

diagonal: The extracted diagonal(s) having shape `diagonal.shape = input.shape[:-1]`.

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) ```

queueSize Source

Arguments

:: Tensor v1 ByteString

handle: The handle to a queue.

-> Tensor Value Int32

size: The number of elements in the given queue.

Computes the number of elements in the given queue.

decodePng Source

Arguments

:: (TensorType dtype, OneOf `[Word16, Word8]` dtype) 
=> Tensor v1 ByteString

contents: 0-D. The PNG-encoded image.

-> Tensor Value dtype

image: 3-D with shape `[height, width, channels]`.

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:

  • 0: Use the number of channels in the PNG-encoded image.
  • 1: output a grayscale image.
  • 3: output an RGB image.
  • 4: output an RGBA image.

If needed, the PNG-encoded image is transformed to match the requested number of color channels.

ceil Source

Arguments

:: (TensorType t, OneOf `[Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor Value t

y

Returns element-wise smallest integer in not less than x.

priorityQueue Source

Arguments

:: Tensor Value ByteString

handle: The handle to the queue.

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.

placeholderWithDefault Source

Arguments

:: TensorType dtype 
=> Tensor v1 dtype

input: The default value to produce when output is not fed.

-> Tensor Value dtype

output: A placeholder tensor that defaults to input if it is not fed.

A placeholder op that passes though input when its output is not fed.

cropAndResizeGradImage Source

Arguments

:: (TensorType t, OneOf `[Word16, Double, Float]` t) 
=> Tensor v1 Float

grads: A 4-D tensor of shape `[num_boxes, crop_height, crop_width, depth]`.

-> Tensor v2 Float

boxes: A 2-D tensor of shape `[num_boxes, 4]`. The i-th row of the tensor specifies the coordinates of a box in the `box_ind[i]` image and is specified in normalized coordinates `[y1, x1, y2, x2]`. A normalized coordinate value of y is mapped to the image coordinate at `y * (image_height - 1)`, so as the `[0, 1]` interval of normalized image height is mapped to `[0, image_height - 1] in image height coordinates. We do allow y1 > y2, in which case the sampled crop is an up-down flipped version of the original image. The width dimension is treated similarly. Normalized coordinates outside the `[0, 1]` range are allowed, in which case we use extrapolation_value to extrapolate the input image values.

-> Tensor v3 Int32

box_ind: A 1-D tensor of shape `[num_boxes]` with int32 values in `[0, batch)`. The value of `box_ind[i]` specifies the image that the i-th box refers to.

-> Tensor v4 Int32

image_size: A 1-D tensor with value `[batch, image_height, image_width, depth]` containing the original image size. Both image_height and image_width need to be positive.

-> Tensor Value t

output: A 4-D tensor of shape `[batch, image_height, image_width, depth]`.

Computes the gradient of the crop_and_resize op wrt the input image tensor.

readerReset Source

Arguments

:: Tensor v1 ByteString

reader_handle: Handle to a Reader.

-> ControlNode 

Restore a Reader to its initial clean state.

extractImagePatches Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

images: 4-D Tensor with shape `[batch, in_rows, in_cols, depth]`.

-> Tensor Value t

patches: 4-D Tensor with shape `[batch, out_rows, out_cols, ksize_rows * ksize_cols * depth]` containing image patches with size `ksize_rows x ksize_cols x depth` vectorized in the "depth" dimension.

Extract patches from images and put them in the "depth" output dimension.

batchMatrixSetDiag Source

Arguments

:: TensorType t 
=> Tensor v1 t

input

-> Tensor v2 t

diagonal

-> Tensor Value t

output

stackClose Source

Arguments

:: Tensor v1 ByteString

handle: The handle to a stack.

-> ControlNode 

Delete the stack from its resource container.

quantizeAndDequantize Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t) 
=> Tensor v1 t

input: Tensor to quantize and then dequantize.

-> Tensor Value t

output

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. m = max(max(abs(min_elem(input)), abs(max_elem(input))) otherwise.

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

min_fixed, max_fixed
=
-(1 << (num_bits - 1) - 1), (1 << (num_bits - 1)) - 1
.

Otherwise, if signed_input is false, the fixed-point range is

min_fixed, max_fixed
= [0, (1 << num_bits) - 1].

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

min_fixed, max_fixed
= [-127, 127], and s = (127 + 127) / 2 = 127.

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}.

isNan Source

Arguments

:: (TensorType t, OneOf `[Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor Value Bool

y

Returns which elements of x are NaN.

where' Source

Arguments

:: Tensor v1 Bool

input

-> Tensor Value Int64

index

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]] ```

listDiff Source

Arguments

:: (TensorType t, TensorType out_idx, OneOf `[Int32, Int64]` out_idx) 
=> Tensor v1 t

x: 1-D. Values to keep.

-> Tensor v2 t

y: 1-D. Values to remove.

-> (Tensor Value t, Tensor Value out_idx)

(out, idx)

  • out: 1-D. Values present in x but not in y.
  • idx: 1-D. Positions of x values preserved in out.

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] ```

stridedSlice Source

Arguments

:: (TensorType index, OneOf `[Int32, Int64]` index, TensorType t) 
=> Tensor v1 t

input

-> Tensor v2 index

begin: `begin[i]` specifies the offset into the ith dimension of input to slice from.

-> Tensor v3 index

end: `end[i]` specifies the first offset into the ith dimension of input that will not be extracted. Out or range values are clamped to `[0,dim[i]) if slice[i] > 0` or `[-1,dim[i]-1]` `if slice[i] < 0`

-> Tensor v4 index

strides: `strides[i]` specifies the increment in the ith dimension after extracting a given element. Negative indices will reverse the original order. Out or range values are clamped to `[0,dim[i]) if slice[i]>0` or `[-1,dim[i]-1] if slice[i] < 0`

-> Tensor Value t

output

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])]`.

  • Requirements*: `0 != strides[i] for i in [0, n)`

randomShuffleQueue Source

Arguments

:: Tensor Value ByteString

handle: The handle to the queue.

A queue that randomizes the order of elements.

tileGrad Source

Arguments

:: TensorType t 
=> Tensor v1 t

input

-> Tensor v2 Int32

multiples

-> Tensor Value t

output

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.

stridedSliceAssign Source

Arguments

:: (TensorType index, OneOf `[Int32, Int64]` index, TensorType t) 
=> Tensor v1 t

ref

-> Tensor v2 index

begin

-> Tensor v3 index

end

-> Tensor v4 index

strides

-> Tensor v5 t

value

-> Tensor Value t

output_ref

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.

reshape Source

Arguments

:: (TensorType t, TensorType tshape, OneOf `[Int32, Int64]` tshape) 
=> Tensor v1 t

tensor

-> Tensor v2 tshape

shape: Defines the shape of the output tensor.

-> Tensor Value t

output

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 ```

fIFOQueue Source

Arguments

:: Tensor Value ByteString

handle: The handle to the queue.

A queue that produces elements in first-in first-out order.

learnedUnigramCandidateSampler Source

Arguments

:: Int64

num_sampled: Number of candidates to randomly sample per batch.

-> Int64

num_true: Number of true labels per context.

-> Int64

range_max: The sampler will sample integers from the interval [0, range_max).

-> Bool

unique: If unique is true, we sample with rejection, so that all sampled candidates in a batch are unique. This requires some approximation to estimate the post-rejection sampling probabilities.

-> Tensor v1 Int64

true_classes: A batch_size * num_true matrix, in which each row contains the IDs of the num_true target_classes in the corresponding original label.

-> (Tensor Value Int64, Tensor Value Float, Tensor Value Float)

(sampled_candidates, true_expected_count, sampled_expected_count)

  • sampled_candidates: A vector of length num_sampled, in which each element is the ID of a sampled candidate.
  • true_expected_count: A batch_size * num_true matrix, representing the number of times each candidate is expected to occur in a batch of sampled candidates. If unique=true, then this is a probability.
  • sampled_expected_count: A vector of length num_sampled, for each sampled candidate representing the number of times the candidate is expected to occur in a batch of sampled candidates. If unique=true, then this is a probability.

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.

fractionalAvgPool Source

Arguments

:: (TensorType t, OneOf `[Int32, Int64, Double, Float]` t) 
=> Tensor v1 t

value: 4-D with shape `[batch, height, width, channels]`.

-> (Tensor Value t, Tensor Value Int64, Tensor Value Int64)

(output, row_pooling_sequence, col_pooling_sequence)

  • output: output tensor after fractional avg pooling.
  • row_pooling_sequence: row pooling sequence, needed to calculate gradient.
  • col_pooling_sequence: column pooling sequence, needed to calculate gradient.

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.

randomCrop Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word8, Double, Float]` t) 
=> Tensor v1 t

image: 3-D of shape `[height, width, channels]`.

-> Tensor v2 Int64

size: 1-D of length 2 containing: crop_height, crop_width..

-> Tensor Value t

output: 3-D of shape `[crop_height, crop_width, channels].`

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.

_HostCast Source

Arguments

:: (TensorType dstT, TensorType srcT) 
=> Tensor v1 srcT

x

-> Tensor Value dstT

y

Cast x of type SrcT to y of DstT.

_HostCast requires its input and produces its output in host memory.

queueClose Source

Arguments

:: Tensor v1 ByteString

handle: The handle to a queue.

-> ControlNode 

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.

slice Source

Arguments

:: (TensorType index, OneOf `[Int32, Int64]` index, TensorType t) 
=> Tensor v1 t

input

-> Tensor v2 index

begin: begin[i] specifies the offset into the ith dimension of input to slice from.

-> Tensor v3 index

size: size[i] specifies the number of elements of the ith dimension of input to slice. If size[i] is -1, all remaining elements in dimension i are included in the slice (i.e. this is equivalent to setting size[i] = input.dim_size(i) - begin[i]).

-> Tensor Value t

output

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.

  • Requirements*: 0 <= begin[i] <= begin[i] + size[i] <= Di for i in [0, n)

stridedSliceGrad Source

Arguments

:: (TensorType index, OneOf `[Int32, Int64]` index, TensorType t) 
=> Tensor v1 index

shape

-> Tensor v2 index

begin

-> Tensor v3 index

end

-> Tensor v4 index

strides

-> Tensor v5 t

dy

-> Tensor Value t

output

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.

sparseTensorDenseAdd Source

Arguments

:: (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

a_indices: 2-D. The indices of the SparseTensor, with shape `[nnz, ndims]`.

-> Tensor v2 t

a_values: 1-D. The values of the SparseTensor, with shape `[nnz]`.

-> Tensor v3 tindices

a_shape: 1-D. The shape of the SparseTensor, with shape `[ndims]`.

-> Tensor v4 t

b: ndims-D Tensor. With shape a_shape.

-> Tensor Value t

output

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.

size Source

Arguments

:: (TensorType t, TensorType out_type, OneOf `[Int32, Int64]` out_type) 
=> Tensor v1 t

input

-> Tensor Value out_type

output

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 ```

barrier Source

Arguments

:: Tensor Value ByteString

handle: The handle to the barrier.

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.

lgamma Source

Arguments

:: (TensorType t, OneOf `[Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor Value t

y

Computes the log of the absolute value of `Gamma(x)` element-wise.

decodeJpeg Source

Arguments

:: Tensor v1 ByteString

contents: 0-D. The JPEG-encoded image.

-> Tensor Value Word8

image: 3-D with shape `[height, width, channels]`..

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:

  • 0: Use the number of channels in the JPEG-encoded image.
  • 1: output a grayscale image.
  • 3: output an RGB image.

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.

shapeN Source

Arguments

:: (TensorType t, TensorType out_type, OneOf `[Int32, Int64]` out_type) 
=> [Tensor v1 t]

input

-> [Tensor Value out_type]

output

Returns shape of tensors.

This operation returns N 1-D integer tensors representing shape of `input[i]s`.

uniformCandidateSampler Source

Arguments

:: Int64

num_sampled: Number of candidates to randomly sample per batch.

-> Int64

num_true: Number of true labels per context.

-> Int64

range_max: The sampler will sample integers from the interval [0, range_max).

-> Bool

unique: If unique is true, we sample with rejection, so that all sampled candidates in a batch are unique. This requires some approximation to estimate the post-rejection sampling probabilities.

-> Tensor v1 Int64

true_classes: A batch_size * num_true matrix, in which each row contains the IDs of the num_true target_classes in the corresponding original label.

-> (Tensor Value Int64, Tensor Value Float, Tensor Value Float)

(sampled_candidates, true_expected_count, sampled_expected_count)

  • sampled_candidates: A vector of length num_sampled, in which each element is the ID of a sampled candidate.
  • true_expected_count: A batch_size * num_true matrix, representing the number of times each candidate is expected to occur in a batch of sampled candidates. If unique=true, then this is a probability.
  • sampled_expected_count: A vector of length num_sampled, for each sampled candidate representing the number of times the candidate is expected to occur in a batch of sampled candidates. If unique=true, then this is a probability.

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.

unique Source

Arguments

:: (TensorType t, TensorType out_idx, OneOf `[Int32, Int64]` out_idx) 
=> Tensor v1 t

x: 1-D.

-> (Tensor Value t, Tensor Value out_idx)

(y, idx)

  • y: 1-D.
  • idx: 1-D.

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] ```

drawBoundingBoxes Source

Arguments

:: (TensorType t, OneOf `[Word16, Float]` t) 
=> Tensor v1 t

images: 4-D with shape `[batch, height, width, depth]`. A batch of images.

-> Tensor v2 Float

boxes: 3-D with shape `[batch, num_bounding_boxes, 4]` containing bounding boxes.

-> Tensor Value t

output: 4-D with the same shape as images. The batch of input images with bounding boxes drawn on the images.

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.

tensorArraySplit Source

Arguments

:: TensorType t 
=> Tensor v1 ByteString

handle: The handle to a TensorArray.

-> Tensor v2 t

value: The concatenated tensor to write to the TensorArray.

-> Tensor v3 Int64

lengths: The vector of lengths, how to split the rows of value into the TensorArray.

-> Tensor v4 Float

flow_in: A float scalar that enforces proper chaining of operations.

-> Tensor Value Float

flow_out: A float scalar that enforces proper chaining of operations.

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 ...```

split Source

Arguments

:: TensorType t 
=> Int64

num_split: The number of ways to split. Must evenly divide `value.shape[split_dim]`.

-> Tensor v1 Int32

split_dim: 0-D. The dimension along which to split. Must be in the range `[0, rank(value))`.

-> Tensor v2 t

value: The tensor to split.

-> [Tensor Value t]

output: They are identically shaped tensors, whose shape matches that of value except along split_dim, where their sizes are `values.shape[split_dim] / num_split`.

Splits a tensor into num_split tensors along one dimension.

segmentMax Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t, TensorType tindices, OneOf `[Int32, Int64]` tindices) 
=> Tensor v1 t

data

-> Tensor v2 tindices

segment_ids: A 1-D tensor whose rank is equal to the rank of `data`'s first dimension. Values should be sorted and can be repeated.

-> Tensor Value t

output: Has same shape as data, except for dimension 0 which has size k, the number of segments.

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

abort :: ControlNode Source

Raise a exception to abort the process when called.

Returns nothing but an exception.

sparseReorder Source

Arguments

:: TensorType t 
=> Tensor v1 Int64

input_indices: 2-D. `N x R` matrix with the indices of non-empty values in a SparseTensor, possibly not in canonical ordering.

-> Tensor v2 t

input_values: 1-D. N non-empty values corresponding to input_indices.

-> Tensor v3 Int64

input_shape: 1-D. Shape of the input SparseTensor.

-> (Tensor Value Int64, Tensor Value t)

(output_indices, output_values)

  • output_indices: 2-D. `N x R` matrix with the same indices as input_indices, but in canonical row-major ordering.
  • output_values: 1-D. N non-empty values corresponding to output_indices.

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.

rsqrtGrad Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor v2 t

y

-> Tensor Value t

z

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.

reverseSequence Source

Arguments

:: (TensorType t, TensorType tlen, OneOf `[Int32, Int64]` tlen) 
=> Int64

seq_dim: The dimension which is partially reversed.

-> Tensor v1 t

input: The input to reverse.

-> Tensor v2 tlen

seq_lengths: 1-D with length `input.dims(batch_dim)` and `max(seq_lengths) < input.dims(seq_dim)`

-> Tensor Value t

output: The partially reversed input. It has the same shape as input.

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, :, ...] ```

readerNumRecordsProduced Source

Arguments

:: Tensor v1 ByteString

reader_handle: Handle to a Reader.

-> Tensor Value Int64

records_produced

Returns the number of records this Reader has produced.

This is the same as the number of ReaderRead executions that have succeeded.

deserializeManySparse Source

Arguments

:: TensorType dtype 
=> Tensor v1 ByteString

serialized_sparse: 2-D, The N serialized SparseTensor objects. Must have 3 columns.

-> (Tensor Value Int64, Tensor Value dtype, Tensor Value Int64)

(sparse_indices, sparse_values, sparse_shape)

  • sparse_indices
  • sparse_values
  • sparse_shape

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]

immutableConst Source

Arguments

:: TensorType dtype 
=> Tensor Value dtype

tensor

Returns immutable tensor from memory region.

The current implementation memmaps the tensor from a file.

minimum Source

Arguments

:: (TensorType t, OneOf `[Int32, Int64, Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor v2 t

y

-> Tensor Value t

z

Returns the min of x and y (i.e. x < y ? x : y) element-wise.

  • NOTE*: Minimum supports broadcasting. More about broadcasting here

initializeTableFromTextFile Source

Arguments

:: Int64

key_index: Column index in a line to get the table key values from.

-> Int64

value_index: Column index that represents information of a line to get the table value values from.

-> Tensor v1 ByteString

table_handle: Handle to a table which will be initialized.

-> Tensor v2 ByteString

filename: Filename of a vocabulary text file.

-> ControlNode 

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.

  • A value of -1 means use the line number(starting from zero), expects int64.
  • A value of -2 means use the whole line content, expects string.
  • A value >= 0 means use the index (starting at zero) of the split line based on delimiter.

diagPart Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int32, Int64, Double, Float]` t) 
=> Tensor v1 t

input: Rank k tensor where k is 2, 4, or 6.

-> Tensor Value t

diagonal: The extracted diagonal.

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] ```

log Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor Value t

y

Computes natural logarithm of x element-wise.

I.e., \(y = log_e x\).

tensorArrayScatter Source

Arguments

:: TensorType t 
=> Tensor v1 ByteString

handle: The handle to a TensorArray.

-> Tensor v2 Int32

indices: The locations at which to write the tensor elements.

-> Tensor v3 t

value: The concatenated tensor to write to the TensorArray.

-> Tensor v4 Float

flow_in: A float scalar that enforces proper chaining of operations.

-> Tensor Value Float

flow_out: A float scalar that enforces proper chaining of operations.

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.

rank Source

Arguments

:: TensorType t 
=> Tensor v1 t

input

-> Tensor Value Int32

output

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 ```

  • *Note**: The rank of a tensor is not the same as the rank of a matrix. The rank of a tensor is the number of indices required to uniquely select each element of the tensor. Rank is also known as "order", "degree", or "ndims."

identity Source

Arguments

:: TensorType t 
=> Tensor v1 t

input

-> Tensor Value t

output

Return a tensor with the same shape and contents as the input tensor or value.

adjustContrastv2 Source

Arguments

:: Tensor v1 Float

images: Images to adjust. At least 3-D.

-> Tensor v2 Float

contrast_factor: A float multiplier for adjusting contrast.

-> Tensor Value Float

output: The contrast-adjusted image or images.

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`.

sparseApplyProximalAdagrad Source

Arguments

:: (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

var: Should be from a Variable().

-> Tensor v2 t

accum: Should be from a Variable().

-> Tensor v3 t

lr: Learning rate. Must be a scalar.

-> Tensor v4 t

l1: L1 regularization. Must be a scalar.

-> Tensor v5 t

l2: L2 regularization. Must be a scalar.

-> Tensor v6 t

grad: The gradient.

-> Tensor v7 tindices

indices: A vector of indices into the first dimension of var and accum.

-> Tensor Value t

out: Same as "var".

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}

gather Source

Arguments

:: (TensorType tindices, OneOf `[Int32, Int64]` tindices, TensorType tparams) 
=> Tensor v1 tparams

params

-> Tensor v2 tindices

indices

-> Tensor Value tparams

output

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

isVariableInitialized Source

Arguments

:: TensorType dtype 
=> Tensor v1 dtype

ref: Should be from a Variable node. May be uninitialized.

-> Tensor Value Bool

is_initialized

Checks whether a tensor has been initialized.

Outputs boolean scalar indicating whether the tensor has been initialized.

concat Source

Arguments

:: TensorType t 
=> Tensor v1 Int32

concat_dim: 0-D. The dimension along which to concatenate. Must be in the range [0, rank(values)).

-> [Tensor v2 t]

values: The N Tensors to concatenate. Their ranks and types must match, and their sizes must match in all dimensions except concat_dim.

-> Tensor Value t

output: A Tensor with the concatenation of values stacked along the concat_dim dimension. This tensor's shape matches that of values except in concat_dim where it has the sum of the sizes.

Concatenates tensors along one dimension.

randomUniformInt Source

Arguments

:: (TensorType t, OneOf `[Int32, Int64]` t, TensorType tout, OneOf `[Int32, Int64]` tout) 
=> Tensor v1 t

shape: The shape of the output tensor.

-> Tensor v2 tout

minval: 0-D. Inclusive lower bound on the generated integers.

-> Tensor v3 tout

maxval: 0-D. Exclusive upper bound on the generated integers.

-> Tensor Value tout

output: A tensor of the specified shape filled with uniform random integers.

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`).

stopGradient Source

Arguments

:: TensorType t 
=> Tensor v1 t

input

-> Tensor Value t

output

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:

  • The *EM* algorithm where the *M-step* should not involve backpropagation through the output of the *E-step*.
  • Contrastive divergence training of Boltzmann machines where, when differentiating the energy function, the training must not backpropagate through the graph that generated the samples from the model.
  • Adversarial training, where no backprop should happen through the adversarial example generation process.

avgPool Source

Arguments

:: (TensorType t, OneOf `[Word16, Double, Float]` t) 
=> Tensor v1 t

value: 4-D with shape `[batch, height, width, channels]`.

-> Tensor Value t

output: The average pooled output tensor.

Performs average pooling on the input.

Each entry in output is the mean of the corresponding size ksize window in value.

wholeFileReader Source

Arguments

:: Tensor Value ByteString

reader_handle: The handle to reference the Reader.

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).

switch Source

Arguments

:: TensorType t 
=> Tensor v1 t

data: The tensor to be forwarded to the appropriate output.

-> Tensor v2 Bool

pred: A scalar that specifies which output port will receive data.

-> (Tensor Value t, Tensor Value t)

(output_false, output_true)

  • output_false: If pred is false, data will be forwarded to this output.
  • output_true: If pred is true, data will be forwarded to this output.

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.

randomStandardNormal Source

Arguments

:: (TensorType t, OneOf `[Int32, Int64]` t, TensorType dtype, OneOf `[Word16, Double, Float]` dtype) 
=> Tensor v1 t

shape: The shape of the output tensor.

-> Tensor Value dtype

output: A tensor of the specified shape filled with random normal values.

Outputs random values from a normal distribution.

The generated values will have mean 0 and standard deviation 1.

sigmoid Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor Value t

y

Computes sigmoid of x element-wise.

Specifically, `y = 1 / (1 + exp(-x))`.

sampleDistortedBoundingBox Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word8]` t) 
=> Tensor v1 t

image_size: 1-D, containing `[height, width, channels]`.

-> Tensor v2 Float

bounding_boxes: 3-D with shape `[batch, N, 4]` describing the N bounding boxes associated with the image.

-> (Tensor Value t, Tensor Value t, Tensor Value Float)

(begin, size, bboxes)

  • begin: 1-D, containing `[offset_height, offset_width, 0]`. Provide as input to `tf.slice`.
  • size: 1-D, containing `[target_height, target_width, -1]`. Provide as input to `tf.slice`.
  • bboxes: 3-D with shape `[1, 1, 4]` containing the distorted bounding box. Provide as input to `tf.image.draw_bounding_boxes`.

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.

greater Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor v2 t

y

-> Tensor Value Bool

z

Returns the truth value of (x > y) element-wise.

  • NOTE*: Greater supports broadcasting. More about broadcasting here

refNextIteration Source

Arguments

:: TensorType t 
=> Tensor v1 t

data: The tensor to be made available to the next iteration.

-> Tensor Value t

output: The same tensor as `data`.

Makes its input available to the next iteration.

spaceToDepth Source

Arguments

:: TensorType t 
=> Int64

block_size: The size of the spatial block.

-> Tensor v1 t

input

-> Tensor Value t

output

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.

  • Non-overlapping blocks of size `block_size x block size` are rearranged into depth at each location.
  • The depth of the output tensor is `input_depth * block_size * block_size`.
  • The input tensor's height and width must be divisible by block_size.

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]]]] ```

controlTrigger :: ControlNode Source

Does nothing. Serves as a control trigger for scheduling.

Only useful as a placeholder for control edges.

scatterDiv Source

Arguments

:: (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

ref: Should be from a Variable node.

-> Tensor v2 tindices

indices: A tensor of indices into the first dimension of ref.

-> Tensor v3 t

updates: A tensor of values that ref is divided by.

-> Tensor Value t

output_ref: = Same as ref. Returned as a convenience for operations that want to use the updated values after the update is done.

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:]`.

copy Source

Arguments

:: TensorType t 
=> Tensor v1 t

input: Input tensor.

-> Tensor Value t

output: Output tensor, deep-copied from input.

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.

cropAndResizeGradBoxes Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 Float

grads: A 4-D tensor of shape `[num_boxes, crop_height, crop_width, depth]`.

-> Tensor v2 t

image: A 4-D tensor of shape `[batch, image_height, image_width, depth]`. Both image_height and image_width need to be positive.

-> Tensor v3 Float

boxes: A 2-D tensor of shape `[num_boxes, 4]`. The i-th row of the tensor specifies the coordinates of a box in the `box_ind[i]` image and is specified in normalized coordinates `[y1, x1, y2, x2]`. A normalized coordinate value of y is mapped to the image coordinate at `y * (image_height - 1)`, so as the `[0, 1]` interval of normalized image height is mapped to `[0, image_height - 1] in image height coordinates. We do allow y1 > y2, in which case the sampled crop is an up-down flipped version of the original image. The width dimension is treated similarly. Normalized coordinates outside the `[0, 1]` range are allowed, in which case we use extrapolation_value to extrapolate the input image values.

-> Tensor v4 Int32

box_ind: A 1-D tensor of shape `[num_boxes]` with int32 values in `[0, batch)`. The value of `box_ind[i]` specifies the image that the i-th box refers to.

-> Tensor Value Float

output: A 2-D tensor of shape `[num_boxes, 4]`.

Computes the gradient of the crop_and_resize op wrt the input boxes tensor.

sparseSegmentMean Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t, TensorType tidx, OneOf `[Int32, Int64]` tidx) 
=> Tensor v1 t

data

-> Tensor v2 tidx

indices: A 1-D tensor. Has same rank as segment_ids.

-> Tensor v3 Int32

segment_ids: A 1-D tensor. Values should be sorted and can be repeated.

-> Tensor Value t

output: Has same shape as data, except for dimension 0 which has size k, the number of segments.

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.

assign Source

Arguments

:: TensorType t 
=> Tensor v1 t

ref: Should be from a Variable node. May be uninitialized.

-> Tensor v2 t

value: The value to be assigned to the variable.

-> Tensor Value t

output_ref: = Same as "ref". Returned as a convenience for operations that want to use the new value after the variable has been reset.

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.

restore Source

Arguments

:: TensorType dt 
=> Tensor v1 ByteString

file_pattern: Must have a single element. The pattern of the files from which we read the tensor.

-> Tensor v2 ByteString

tensor_name: Must have a single element. The name of the tensor to be restored.

-> Tensor Value dt

tensor: The restored tensor.

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.

maxPoolGradWithArgmax Source

Arguments

:: (TensorType t, OneOf `[Word16, Float]` t, TensorType targmax, OneOf `[Int32, Int64]` targmax) 
=> Tensor v1 t

input: The original input.

-> Tensor v2 t

grad: 4-D with shape `[batch, height, width, channels]`. Gradients w.r.t. the output of max_pool.

-> Tensor v3 targmax

argmax: The indices of the maximum values chosen for each output of max_pool.

-> Tensor Value t

output: Gradients w.r.t. the input of max_pool.

Computes gradients of the maxpooling function.

checkNumerics Source

Arguments

:: (TensorType t, OneOf `[Word16, Double, Float]` t) 
=> Tensor v1 t

tensor

-> Tensor Value t

output

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.

zerosLike Source

Arguments

:: TensorType t 
=> Tensor v1 t

x: a tensor of type T.

-> Tensor Value t

y: a tensor of the same shape and type as x but filled with zeros.

Returns a tensor of zeros with the same shape and type as x.

readFile Source

Arguments

:: Tensor v1 ByteString

filename

-> Tensor Value ByteString

contents

Reads and outputs the entire contents of the input filename.

transpose Source

Arguments

:: (TensorType t, TensorType tperm, OneOf `[Int32, Int64]` tperm) 
=> Tensor v1 t

x

-> Tensor v2 tperm

perm

-> Tensor Value t

y

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]`

parseTensor Source

Arguments

:: TensorType out_type 
=> Tensor v1 ByteString

serialized: A scalar string containing a serialized TensorProto proto.

-> Tensor Value out_type

output: A Tensor of type out_type.

Transforms a serialized tensorflow.TensorProto proto into a Tensor.

acos Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int32, Int64, Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor Value t

y

Computes acos of x element-wise.

bitcast Source

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 [...].

  • NOTE*: Bitcast is implemented as a low-level cast, so machines with different endian orderings will give different results.

lookupTableImport Source

Arguments

:: (TensorType tin, TensorType tout) 
=> Tensor v1 ByteString

table_handle: Handle to the table.

-> Tensor v2 tin

keys: Any shape. Keys to look up.

-> Tensor v3 tout

values: Values to associate with keys.

-> ControlNode 

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.

biasAddGrad Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

out_backprop: Any number of dimensions.

-> Tensor Value t

output: 1-D with size the feature dimension of out_backprop.

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.

batchSelfAdjointEig Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t) 
=> Tensor v1 t

input

-> Tensor Value t

output

prod Source

Arguments

:: (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

input: The tensor to reduce.

-> Tensor v2 tidx

reduction_indices: The dimensions to reduce.

-> Tensor Value t

output: The reduced tensor.

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.

resizeBilinear Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

images: 4-D with shape `[batch, height, width, channels]`.

-> Tensor v2 Int32

size: = A 1-D int32 Tensor of 2 elements: `new_height, new_width`. The new size for the images.

-> Tensor Value Float

resized_images: 4-D with shape `[batch, new_height, new_width, channels]`.

Resize images to size using bilinear interpolation.

Input images can be of different types but output images are always float.

tensorArrayUnpack Source

Arguments

:: TensorType t 
=> Tensor v1 ByteString

handle: The handle to a TensorArray.

-> Tensor v2 t

value: The concatenated tensor to write to the TensorArray.

-> Tensor v3 Float

flow_in: A float scalar that enforces proper chaining of operations.

-> Tensor Value Float

flow_out: A float scalar that enforces proper chaining of operations.

Unpack the data from the input value into TensorArray elements.

  • *WARNING: This op is deprecated.**

Instead of this op, use TensorArrayScatter with `indices = RangeOp(0, SizeOp(value)[0])`.

batchMatrixDeterminant Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t) 
=> Tensor v1 t

input

-> Tensor Value t

output

sum Source

Arguments

:: (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

input: The tensor to reduce.

-> Tensor v2 tidx

reduction_indices: The dimensions to reduce.

-> Tensor Value t

output: The reduced tensor.

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.

iFFT2D Source

Arguments

:: Tensor v1 (Complex Float)

input: A complex64 tensor.

-> Tensor Value (Complex Float)

output: A complex64 tensor of the same shape as input. The inner-most 2 dimensions of input are replaced with their inverse 2D Fourier Transform.

Compute the inverse 2-dimensional discrete Fourier Transform over the inner-most

2 dimensions of input.

fill Source

Arguments

:: TensorType t 
=> Tensor v1 Int32

dims: 1-D. Represents the shape of the output tensor.

-> Tensor v2 t

value: 0-D (scalar). Value to fill the returned tensor.

-> Tensor Value t

output

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]] ```

fixedUnigramCandidateSampler Source

Arguments

:: Int64

num_sampled: Number of candidates to randomly sample per batch.

-> Int64

num_true: Number of true labels per context.

-> Int64

range_max: The sampler will sample integers from the interval [0, range_max).

-> Bool

unique: If unique is true, we sample with rejection, so that all sampled candidates in a batch are unique. This requires some approximation to estimate the post-rejection sampling probabilities.

-> Tensor v1 Int64

true_classes: A batch_size * num_true matrix, in which each row contains the IDs of the num_true target_classes in the corresponding original label.

-> (Tensor Value Int64, Tensor Value Float, Tensor Value Float)

(sampled_candidates, true_expected_count, sampled_expected_count)

  • sampled_candidates: A vector of length num_sampled, in which each element is the ID of a sampled candidate.
  • true_expected_count: A batch_size * num_true matrix, representing the number of times each candidate is expected to occur in a batch of sampled candidates. If unique=true, then this is a probability.
  • sampled_expected_count: A vector of length num_sampled, for each sampled candidate representing the number of times the candidate is expected to occur in a batch of sampled candidates. If unique=true, then this is a probability.

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.

dilation2D Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

input: 4-D with shape `[batch, in_height, in_width, depth]`.

-> Tensor v2 t

filter: 3-D with shape `[filter_height, filter_width, depth]`.

-> Tensor Value t

output: 4-D with shape `[batch, out_height, out_width, depth]`.

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.

polygamma Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t) 
=> Tensor v1 t

a

-> Tensor v2 t

x

-> Tensor Value t

z

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.

refIdentity Source

Arguments

:: TensorType t 
=> Tensor v1 t

input

-> Tensor Value t

output

Return the same ref tensor as the input ref tensor.

encodePng Source

Arguments

:: (TensorType t, OneOf `[Word16, Word8]` t) 
=> Tensor v1 t

image: 3-D with shape `[height, width, channels]`.

-> Tensor Value ByteString

contents: 0-D. PNG-encoded image.

PNG-encode an image.

image is a 3-D uint8 or uint16 Tensor of shape `[height, width, channels]` where channels is:

  • 1: for grayscale.
  • 2: for grayscale + alpha.
  • 3: for RGB.
  • 4: for RGBA.

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.

lookupTableInsert Source

Arguments

:: (TensorType tin, TensorType tout) 
=> Tensor v1 ByteString

table_handle: Handle to the table.

-> Tensor v2 tin

keys: Any shape. Keys to look up.

-> Tensor v3 tout

values: Values to associate with keys.

-> ControlNode 

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.

batchIFFT2D Source

Arguments

:: Tensor v1 (Complex Float)

input

-> Tensor Value (Complex Float)

output

uniqueWithCounts Source

Arguments

:: (TensorType t, TensorType out_idx, OneOf `[Int32, Int64]` out_idx) 
=> Tensor v1 t

x: 1-D.

-> (Tensor Value t, Tensor Value out_idx, Tensor Value out_idx)

(y, idx, count)

  • y: 1-D.
  • idx: 1-D.
  • count: 1-D.

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] ```

gatherNd Source

Arguments

:: (TensorType tindices, OneOf `[Int32, Int64]` tindices, TensorType tparams) 
=> Tensor v1 tparams

params: `M-D`. The tensor from which to gather values.

-> Tensor v2 tindices

indices: `(N+1)-D`. Index tensor having shape `[d_0, ..., d_N, R]`.

-> Tensor Value tparams

output: `(N+M-R)-D`. Values from params gathered from indices given by indices.

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

d_0, ..., d_{n-1}, params.shape[R
, ..., params.shape[M-1]].

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]]

tensorArrayRead Source

Arguments

:: TensorType dtype 
=> Tensor v1 ByteString

handle: The handle to a TensorArray.

-> Tensor v2 Int32

index

-> Tensor v3 Float

flow_in: A float scalar that enforces proper chaining of operations.

-> Tensor Value dtype

value: The tensor that is read from the TensorArray.

Read an element from the TensorArray into output value.

readerReadUpTo Source

Arguments

:: Tensor v1 ByteString

reader_handle: Handle to a Reader.

-> Tensor v2 ByteString

queue_handle: Handle to a Queue, with string work items.

-> Tensor v3 Int64

num_records: number of records to read from Reader.

-> (Tensor Value ByteString, Tensor Value ByteString)

(keys, values)

  • keys: A 1-D tensor.
  • values: A 1-D tensor.

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.

betainc Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t) 
=> Tensor v1 t

a

-> Tensor v2 t

b

-> Tensor v3 t

x

-> Tensor Value t

z

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.

batchMatrixBandPart Source

Arguments

:: TensorType t 
=> Tensor v1 t

input

-> Tensor v2 Int64

num_lower

-> Tensor v3 Int64

num_upper

-> Tensor Value t

band

depthwiseConv2dNativeBackpropInput Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t) 
=> Tensor v1 Int32

input_sizes: An integer vector representing the shape of input, where input is a 4-D `[batch, height, width, channels]` tensor.

-> Tensor v2 t

filter: 4-D with shape `[filter_height, filter_width, in_channels, depthwise_multiplier]`.

-> Tensor v3 t

out_backprop: 4-D with shape `[batch, out_height, out_width, out_channels]`. Gradients w.r.t. the output of the convolution.

-> Tensor Value t

output: 4-D with shape `[batch, in_height, in_width, in_channels]`. Gradient w.r.t. the input of the convolution.

Computes the gradients of depthwise convolution with respect to the input.

refSelect Source

Arguments

:: TensorType t 
=> Tensor v1 Int32

index: A scalar that determines the input that gets selected.

-> [Tensor v2 t]

inputs: A list of ref tensors, one of which will be forwarded to output.

-> Tensor Value t

output: The forwarded tensor.

Forwards the indexth element of inputs to output.

exit Source

Arguments

:: TensorType t 
=> Tensor v1 t

data: The tensor to be made available to the parent frame.

-> Tensor Value t

output: The same tensor as `data`.

Exits the current frame to its parent frame.

Exit makes its input `data` available to the parent frame.

lookupTableFind Source

Arguments

:: (TensorType tin, TensorType tout) 
=> Tensor v1 ByteString

table_handle: Handle to the table.

-> Tensor v2 tin

keys: Any shape. Keys to look up.

-> Tensor v3 tout

default_value

-> Tensor Value tout

values: Same shape as keys. Values found in the table, or default_values for missing keys.

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.

squeeze Source

Arguments

:: TensorType t 
=> Tensor v1 t

input: The input to squeeze.

-> Tensor Value t

output: Contains the same data as input, but has one or more dimensions of size 1 removed.

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] ```

mean Source

Arguments

:: (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

input: The tensor to reduce.

-> Tensor v2 tidx

reduction_indices: The dimensions to reduce.

-> Tensor Value t

output: The reduced tensor.

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.

spaceToBatchND Source

Arguments

:: (TensorType t, TensorType tblock_shape, OneOf `[Int32, Int64]` tblock_shape, TensorType tpaddings, OneOf `[Int32, Int64]` tpaddings) 
=> Tensor v1 t

input: N-D with shape `input_shape = [batch] + spatial_shape + remaining_shape`, where spatial_shape has M dimensions.

-> Tensor v2 tblock_shape

block_shape: 1-D with shape `[M]`, all values must be >= 1.

-> Tensor v3 tpaddings

paddings: 2-D with shape `[M, 2]`, all values must be >= 0. `paddings[i] = [pad_start, pad_end]` specifies the padding for input dimension `i + 1`, which corresponds to spatial dimension i. It is required that `block_shape[i]` divides `input_shape[i + 1] + pad_start + pad_end`.

This operation is equivalent to the following steps:

  1. Zero-pad the start and end of dimensions `[1, ..., M]` of the input according to paddings to produce padded of shape padded_shape.
  2. Reshape padded to reshaped_padded of shape: [batch] + [padded_shape[1] / block_shape[0], block_shape[0], ..., padded_shape[M] / block_shape[M-1], block_shape[M-1]] + remaining_shape
  3. Permute dimensions of reshaped_padded to produce permuted_reshaped_padded of shape: block_shape + [batch] + [padded_shape[1] / block_shape[0], ..., padded_shape[M] / block_shape[M-1]] + remaining_shape
  4. Reshape permuted_reshaped_padded to flatten block_shape into the batch dimension, producing an output tensor of shape: [batch * prod(block_shape)] + [padded_shape[1] / block_shape[0], ..., padded_shape[M] / block_shape[M-1]] + remaining_shape

Some examples:

  1. For the following input of shape `[1, 2, 2, 1]`, `block_shape = [2, 2]`, and `paddings = [[0, 0], [0, 0]]`:

```prettyprint x = [[[[1], [2]], [[3], [4]]]] ```

The output tensor has shape `[4, 1, 1, 1]` and value:

```prettyprint [[[[1]]], [[[2]]], [[[3]]], [[[4]]]] ```

  1. For the following input of shape `[1, 2, 2, 3]`, `block_shape = [2, 2]`, and `paddings = [[0, 0], [0, 0]]`:

```prettyprint x = [[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]] ```

The output tensor has shape `[4, 1, 1, 3]` and value:

```prettyprint [[[1, 2, 3]], [[4, 5, 6]], [[7, 8, 9]], [[10, 11, 12]]] ```

  1. For the following input of shape `[1, 4, 4, 1]`, `block_shape = [2, 2]`, and `paddings = [[0, 0], [0, 0]]`:

```prettyprint x = [[[[1], [2], [3], [4]], [[5], [6], [7], [8]], [[9], [10], [11], [12]], [[13], [14], [15], [16]]]] ```

The output tensor has shape `[4, 2, 2, 1]` and value:

```prettyprint x = [[[[1], [3]], [[5], [7]]], [[[2], [4]], [[10], [12]]], [[[5], [7]], [[13], [15]]], [[[6], [8]], [[14], [16]]]] ```

  1. For the following input of shape `[2, 2, 4, 1]`, block_shape = `[2, 2]`, and paddings = `[[0, 0], [2, 0]]`:

```prettyprint x = [[[[1], [2], [3], [4]], [[5], [6], [7], [8]]], [[[9], [10], [11], [12]], [[13], [14], [15], [16]]]] ```

The output tensor has shape `[8, 1, 3, 1]` and value:

```prettyprint x = [[[[0], [1], [3]]], [[[0], [9], [11]]], [[[0], [2], [4]]], [[[0], [10], [12]]], [[[0], [5], [7]]], [[[0], [13], [15]]], [[[0], [6], [8]]], [[[0], [14], [16]]]] ```

Among others, this operation is useful for reducing atrous convolution into regular convolution.

-> Tensor Value t

output

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.

spaceToBatch Source

Arguments

:: (TensorType t, TensorType tpaddings, OneOf `[Int32, Int64]` tpaddings) 
=> Int64

block_size

-> Tensor v1 t

input: 4-D with shape `[batch, height, width, depth]`.

-> Tensor v2 tpaddings

paddings: 2-D tensor of non-negative integers with shape `[2, 2]`. It specifies the padding of the input with zeros across the spatial dimensions as follows:

paddings = [[pad_top, pad_bottom], [pad_left, pad_right]]

The effective spatial dimensions of the zero-padded input tensor will be:

height_pad = pad_top + height + pad_bottom width_pad = pad_left + width + pad_right

The attr block_size must be greater than one. It indicates the block size.

  • Non-overlapping blocks of size `block_size x block size` in the height and width dimensions are rearranged into the batch dimension at each location.
  • The batch of the output tensor is `batch * block_size * block_size`.
  • Both height_pad and width_pad must be divisible by block_size.

The shape of the output will be:

[batch*block_size*block_size, height_padblock_size, width_padblock_size, depth]

Some examples:

  1. For the following input of shape `[1, 2, 2, 1]` and block_size of 2:

```prettyprint x = [[[[1], [2]], [[3], [4]]]] ```

The output tensor has shape `[4, 1, 1, 1]` and value:

```prettyprint [[[[1]]], [[[2]]], [[[3]]], [[[4]]]] ```

  1. For the following input of shape `[1, 2, 2, 3]` and block_size of 2:

```prettyprint x = [[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]] ```

The output tensor has shape `[4, 1, 1, 3]` and value:

```prettyprint [[[1, 2, 3]], [[4, 5, 6]], [[7, 8, 9]], [[10, 11, 12]]] ```

  1. For the following input of shape `[1, 4, 4, 1]` and block_size of 2:

```prettyprint x = [[[[1], [2], [3], [4]], [[5], [6], [7], [8]], [[9], [10], [11], [12]], [[13], [14], [15], [16]]]] ```

The output tensor has shape `[4, 2, 2, 1]` and value:

```prettyprint x = [[[[1], [3]], [[5], [7]]], [[[2], [4]], [[10], [12]]], [[[5], [7]], [[13], [15]]], [[[6], [8]], [[14], [16]]]] ```

  1. For the following input of shape `[2, 2, 4, 1]` and block_size of 2:

```prettyprint x = [[[[1], [2], [3], [4]], [[5], [6], [7], [8]]], [[[9], [10], [11], [12]], [[13], [14], [15], [16]]]] ```

The output tensor has shape `[8, 1, 2, 1]` and value:

```prettyprint x = [[[[1], [3]]], [[[9], [11]]], [[[2], [4]]], [[[10], [12]]], [[[5], [7]]], [[[13], [15]]], [[[6], [8]]], [[[14], [16]]]] ```

Among others, this operation is useful for reducing atrous convolution into regular convolution.

-> Tensor Value t

output

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.

cTCGreedyDecoder Source

Arguments

:: Tensor v1 Float

inputs: 3-D, shape: `(max_time x batch_size x num_classes)`, the logits.

-> Tensor v2 Int32

sequence_length: A vector containing sequence lengths, size `(batch_size)`.

-> (Tensor Value Int64, Tensor Value Int64, Tensor Value Int64, Tensor Value Float)

(decoded_indices, decoded_values, decoded_shape, log_probability)

  • decoded_indices: Indices matrix, size `(total_decoded_outputs x 2)`, of a `SparseTensor2`. The rows store: [batch, time].
  • decoded_values: Values vector, size: `(total_decoded_outputs)`, of a `SparseTensor2`. The vector stores the decoded classes.
  • decoded_shape: Shape vector, size `(2)`, of the decoded SparseTensor. Values are: `[batch_size, max_decoded_length]`.
  • log_probability: Matrix, size `(batch_size x 1)`, containing sequence log-probabilities.

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.

batchToSpaceND Source

Arguments

:: (TensorType t, TensorType tblock_shape, OneOf `[Int32, Int64]` tblock_shape, TensorType tcrops, OneOf `[Int32, Int64]` tcrops) 
=> Tensor v1 t

input: N-D with shape `input_shape = [batch] + spatial_shape + remaining_shape`, where spatial_shape has M dimensions.

-> Tensor v2 tblock_shape

block_shape: 1-D with shape `[M]`, all values must be >= 1.

-> Tensor v3 tcrops

crops: 2-D with shape `[M, 2]`, all values must be >= 0. `crops[i] = [crop_start, crop_end]` specifies the amount to crop from input dimension `i + 1`, which corresponds to spatial dimension i. It is required that `crop_start[i] + crop_end[i] <= block_shape[i] * input_shape[i + 1]`.

This operation is equivalent to the following steps:

  1. Reshape input to reshaped of shape: [block_shape[0], ..., block_shape[M-1], batch / prod(block_shape), input_shape[1], ..., input_shape[N-1]]
  2. Permute dimensions of reshaped to produce permuted of shape [batch / prod(block_shape),

input_shape[1], block_shape[0], ..., input_shape[M], block_shape[M-1],

input_shape[M+1], ..., input_shape[N-1]]

  1. Reshape permuted to produce reshaped_permuted of shape [batch / prod(block_shape),

input_shape[1] * block_shape[0], ..., input_shape[M] * block_shape[M-1],

input_shape[M+1], ..., input_shape[N-1]]

  1. Crop the start and end of dimensions `[1, ..., M]` of reshaped_permuted according to crops to produce the output of shape: [batch / prod(block_shape),

input_shape[1] * block_shape[0] - crops[0,0] - crops[0,1], ..., input_shape[M] * block_shape[M-1] - crops[M-1,0] - crops[M-1,1],

input_shape[M+1], ..., input_shape[N-1]]

Some examples:

  1. For the following input of shape `[4, 1, 1, 1]`, `block_shape = [2, 2]`, and `crops = [[0, 0], [0, 0]]`:

```prettyprint [[[[1]]], [[[2]]], [[[3]]], [[[4]]]] ```

The output tensor has shape `[1, 2, 2, 1]` and value:

```prettyprint x = [[[[1], [2]], [[3], [4]]]] ```

  1. For the following input of shape `[4, 1, 1, 3]`, `block_shape = [2, 2]`, and `crops = [[0, 0], [0, 0]]`:

```prettyprint [[[1, 2, 3]], [[4, 5, 6]], [[7, 8, 9]], [[10, 11, 12]]] ```

The output tensor has shape `[1, 2, 2, 3]` and value:

```prettyprint x = [[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]] ```

  1. For the following input of shape `[4, 2, 2, 1]`, `block_shape = [2, 2]`, and `crops = [[0, 0], [0, 0]]`:

```prettyprint x = [[[[1], [3]], [[5], [7]]], [[[2], [4]], [[10], [12]]], [[[5], [7]], [[13], [15]]], [[[6], [8]], [[14], [16]]]] ```

The output tensor has shape `[1, 4, 4, 1]` and value:

```prettyprint x = [[[1], [2], [3], [4]], [[5], [6], [7], [8]], [[9], [10], [11], [12]], [[13], [14], [15], [16]]] ```

  1. For the following input of shape `[8, 1, 3, 1]`, `block_shape = [2, 2]`, and `crops = [[0, 0], [2, 0]]`:

```prettyprint x = [[[[0], [1], [3]]], [[[0], [9], [11]]], [[[0], [2], [4]]], [[[0], [10], [12]]], [[[0], [5], [7]]], [[[0], [13], [15]]], [[[0], [6], [8]]], [[[0], [14], [16]]]] ```

The output tensor has shape `[2, 2, 4, 1]` and value:

```prettyprint x = [[[[1], [2], [3], [4]], [[5], [6], [7], [8]]], [[[9], [10], [11], [12]], [[13], [14], [15], [16]]]] ```

-> Tensor Value t

output

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.

pack Source

Arguments

:: TensorType t 
=> [Tensor v1 t]

values: Must be of same shape and type.

-> Tensor Value t

output: The packed tensor.

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.

oneHot Source

Arguments

:: (TensorType t, TensorType tI, OneOf `[Int32, Int64, Word8]` tI) 
=> Tensor v1 tI

indices: A tensor of indices.

-> Tensor v2 Int32

depth: A scalar defining the depth of the one hot dimension.

-> Tensor v3 t

on_value: A scalar defining the value to fill in output when `indices[j] = i`.

-> Tensor v4 t

off_value: A scalar defining the value to fill in output when `indices[j] != i`.

-> Tensor Value t

output: The one-hot tensor.

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) ]```

broadcastGradientArgs Source

Arguments

:: (TensorType t, OneOf `[Int32, Int64]` t) 
=> Tensor v1 t

s0

-> Tensor v2 t

s1

-> (Tensor Value t, Tensor Value t)

(r0, r1)

  • r0
  • r1

Return the reduction indices for computing gradients of s0 op s1 with broadcast.

This is typically used by gradient computations for a broadcasting operation.

matrixSetDiag Source

Arguments

:: TensorType t 
=> Tensor v1 t

input: Rank `k+1`, where `k >= 1`.

-> Tensor v2 t

diagonal: Rank k, where `k >= 1`.

-> Tensor Value t

output: Rank `k+1`, with `output.shape = input.shape`.

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:

  • `output[i, j, k, ..., m, n] = diagonal[i, j, k, ..., n]` for `m == n`.
  • `output[i, j, k, ..., m, n] = input[i, j, k, ..., m, n]` for `m != n`.

applyRMSProp Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

var: Should be from a Variable().

-> Tensor v2 t

ms: Should be from a Variable().

-> Tensor v3 t

mom: Should be from a Variable().

-> Tensor v4 t

lr: Scaling factor. Must be a scalar.

-> Tensor v5 t

rho: Decay rate. Must be a scalar.

-> Tensor v6 t

momentum

-> Tensor v7 t

epsilon: Ridge term. Must be a scalar.

-> Tensor v8 t

grad: The gradient.

-> Tensor Value t

out: Same as "var".

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

const Source

Arguments

:: TensorType dtype 
=> Tensor Value dtype

output

Returns a constant tensor.

enter Source

Arguments

:: TensorType t 
=> Tensor v1 t

data: The tensor to be made available to the child frame.

-> Tensor Value t

output: The same tensor as `data`.

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.

debugIdentity Source

Arguments

:: TensorType t 
=> Tensor v1 t

input: Input tensor, non-Reference type.

-> Tensor Value t

output: Output tensor that equals the input tensor.

Debug Identity Op.

Provides an identity mapping of the non-Ref type input tensor for debugging.

debugNanCount Source

Arguments

:: TensorType t 
=> Tensor v1 t

input: Input tensor, non-Reference type.

-> Tensor Value Int64

output: An integer output tensor that is the number of NaNs in the input.

Debug NaN Value Counter Op

Counts number of NaNs in the input tensor, for debugging.

batchNormWithGlobalNormalization Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Bool

scale_after_normalization: A bool indicating whether the resulted tensor needs to be multiplied with gamma.

-> Float

variance_epsilon: A small float number to avoid dividing by 0.

-> Tensor v1 t

t: A 4D input Tensor.

-> Tensor v2 t

m: A 1D mean Tensor with size matching the last dimension of t. This is the first output from tf.nn.moments, or a saved moving average thereof.

-> Tensor v3 t

v: A 1D variance Tensor with size matching the last dimension of t. This is the second output from tf.nn.moments, or a saved moving average thereof.

-> Tensor v4 t

beta: A 1D beta Tensor with size matching the last dimension of t. An offset to be added to the normalized tensor.

-> Tensor v5 t

gamma: A 1D gamma Tensor with size matching the last dimension of t. If "scale_after_normalization" is true, this tensor will be multiplied with the normalized tensor.

-> Tensor Value t

result

Batch normalization.

This op is deprecated. Prefer `tf.nn.batch_normalization`.

batchMatrixDiag Source

Arguments

:: TensorType t 
=> Tensor v1 t

diagonal

-> Tensor Value t

output

unpack Source

Arguments

:: TensorType t 
=> Int64

num

-> Tensor v1 t

value: 1-D or higher, with axis dimension size equal to num.

-> [Tensor Value t]

output: The list of tensors unpacked from value.

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.

sparseSplit Source

Arguments

:: TensorType t 
=> Int64

num_split: The number of ways to split.

-> Tensor v1 Int64

split_dim: 0-D. The dimension along which to split. Must be in the range `[0, rank(shape))`.

-> Tensor v2 Int64

indices: 2-D tensor represents the indices of the sparse tensor.

-> Tensor v3 t

values: 1-D tensor represents the values of the sparse tensor.

-> Tensor v4 Int64

shape: 1-D. tensor represents the shape of the sparse tensor. output indices: A list of 1-D tensors represents the indices of the output sparse tensors.

-> ([Tensor Value Int64], [Tensor Value t], [Tensor Value Int64])

(output_indices, output_values, output_shape)

  • output_indices
  • output_values: A list of 1-D tensors represents the values of the output sparse tensors.
  • output_shape: A list of 1-D tensors represents the shape of the output sparse tensors.

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 ] [ ]

mirrorPad Source

Arguments

:: (TensorType t, TensorType tpaddings, OneOf `[Int32, Int64]` tpaddings) 
=> Tensor v1 t

input: The input tensor to be padded.

-> Tensor v2 tpaddings

paddings: A two-column matrix specifying the padding sizes. The number of rows must be the same as the rank of input.

-> Tensor Value t

output: The padded tensor.

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]] ```

batchMatrixDiagPart Source

Arguments

:: TensorType t 
=> Tensor v1 t

input

-> Tensor Value t

diagonal

fractionalMaxPoolGrad Source

Arguments

:: (TensorType t, OneOf `[Int32, Int64, Double, Float]` t) 
=> Tensor v1 t

orig_input: Original input for fractional_max_pool

-> Tensor v2 t

orig_output: Original output for fractional_max_pool

-> Tensor v3 t

out_backprop: 4-D with shape `[batch, height, width, channels]`. Gradients w.r.t. the output of fractional_max_pool.

-> Tensor v4 Int64

row_pooling_sequence: row pooling sequence, form pooling region with col_pooling_sequence.

-> Tensor v5 Int64

col_pooling_sequence: column pooling sequence, form pooling region with row_pooling sequence.

-> Tensor Value t

output: 4-D. Gradients w.r.t. the input of fractional_max_pool.

Computes gradient of the FractionalMaxPool function.

matchingFiles Source

Arguments

:: Tensor v1 ByteString

pattern: A (scalar) shell wildcard pattern.

-> Tensor Value ByteString

filenames: A vector of matching filenames.

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.

tile Source

Arguments

:: (TensorType t, TensorType tmultiples, OneOf `[Int32, Int64]` tmultiples) 
=> Tensor v1 t

input: 1-D or higher.

-> Tensor v2 tmultiples

multiples: 1-D. Length must be the same as the number of dimensions in input

-> Tensor Value t

output

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]`.

sparseSparseMinimum Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 Int64

a_indices: 2-D. `N x R` matrix with the indices of non-empty values in a SparseTensor, in the canonical lexicographic ordering.

-> Tensor v2 t

a_values: 1-D. N non-empty values corresponding to a_indices.

-> Tensor v3 Int64

a_shape: 1-D. Shape of the input SparseTensor.

-> Tensor v4 Int64

b_indices: counterpart to a_indices for the other operand.

-> Tensor v5 t

b_values: counterpart to a_values for the other operand; must be of the same dtype.

-> Tensor v6 Int64

b_shape: counterpart to a_shape for the other operand; the two shapes must be equal.

-> (Tensor Value Int64, Tensor Value t)

(output_indices, output_values)

  • output_indices: 2-D. The indices of the output SparseTensor.
  • output_values: 1-D. The values of the output SparseTensor.

Returns the element-wise min of two SparseTensors.

Assumes the two SparseTensors have the same shape, i.e., no broadcasting.

allCandidateSampler Source

Arguments

:: Int64

num_sampled: Number of candidates to produce per batch.

-> Int64

num_true: Number of true labels per context.

-> Bool

unique: If unique is true, we sample with rejection, so that all sampled candidates in a batch are unique. This requires some approximation to estimate the post-rejection sampling probabilities.

-> Tensor v1 Int64

true_classes: A batch_size * num_true matrix, in which each row contains the IDs of the num_true target_classes in the corresponding original label.

-> (Tensor Value Int64, Tensor Value Float, Tensor Value Float)

(sampled_candidates, true_expected_count, sampled_expected_count)

  • sampled_candidates: A vector of length num_sampled, in which each element is the ID of a sampled candidate.
  • true_expected_count: A batch_size * num_true matrix, representing the number of times each candidate is expected to occur in a batch of sampled candidates. If unique=true, then this is a probability.
  • sampled_expected_count: A vector of length num_sampled, for each sampled candidate representing the number of times the candidate is expected to occur in a batch of sampled candidates. If unique=true, then this is a probability.

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.

refSwitch Source

Arguments

:: TensorType t 
=> Tensor v1 t

data: The ref tensor to be forwarded to the appropriate output.

-> Tensor v2 Bool

pred: A scalar that specifies which output port will receive data.

-> (Tensor Value t, Tensor Value t)

(output_false, output_true)

  • output_false: If pred is false, data will be forwarded to this output.
  • output_true: If pred is true, data will be forwarded to this output.

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.

mergeSummary Source

Arguments

:: [Tensor v1 ByteString]

inputs: Can be of any shape. Each must contain serialized Summary protocol buffers.

-> Tensor Value ByteString

summary: Scalar. Serialized Summary protocol buffer.

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.

logicalNot Source

Arguments

:: Tensor v1 Bool

x

-> Tensor Value Bool

y

Returns the truth value of NOT x element-wise.

lRNGrad Source

Arguments

:: (TensorType t, OneOf `[Word16, Float]` t) 
=> Tensor v1 t

input_grads: 4-D with shape `[batch, height, width, channels]`.

-> Tensor v2 t

input_image: 4-D with shape `[batch, height, width, channels]`.

-> Tensor v3 t

output_image: 4-D with shape `[batch, height, width, channels]`.

-> Tensor Value t

output: The gradients for LRN.

Gradients for Local Response Normalization.

stringToNumber Source

Arguments

:: (TensorType out_type, OneOf `[Int32, Float]` out_type) 
=> Tensor v1 ByteString

string_tensor

-> Tensor Value out_type

output: A Tensor of the same shape as the input string_tensor.

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.)

sparseMatMul Source

Arguments

:: (TensorType ta, OneOf `[Word16, Float]` ta, TensorType tb, OneOf `[Word16, Float]` tb) 
=> Tensor v1 ta

a

-> Tensor v2 tb

b

-> Tensor Value Float

product

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.

merge Source

Arguments

:: TensorType t 
=> [Tensor v1 t]

inputs: The input tensors, exactly one of which will become available.

-> (Tensor Value t, Tensor Value Int32)

(output, value_index)

  • output: Will be set to the available input tensor.
  • value_index: The index of the chosen input tensor in inputs.

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.

choleskyGrad Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t) 
=> Tensor v1 t

l: Output of batch Cholesky algorithm l = cholesky(A). Shape is `[..., M, M]`. Algorithm depends only on lower triangular part of the innermost matrices of this tensor.

-> Tensor v2 t

grad: df/dl where f is some scalar function. Shape is `[..., M, M]`. Algorithm depends only on lower triangular part of the innermost matrices of this tensor.

-> Tensor Value t

output: Symmetrized version of df/dA . Shape is `[..., M, M]`

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.

batchCholeskyGrad Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t) 
=> Tensor v1 t

l

-> Tensor v2 t

grad

-> Tensor Value t

output

tensorArrayGather Source

Arguments

:: TensorType dtype 
=> Tensor v1 ByteString

handle: The handle to a TensorArray.

-> Tensor v2 Int32

indices: The locations in the TensorArray from which to read tensor elements.

-> Tensor v3 Float

flow_in: A float scalar that enforces proper chaining of operations.

-> Tensor Value dtype

value: All of the elements in the TensorArray, concatenated along a new axis (the new dimension 0).

Gather specific elements from the TensorArray into output value.

All elements selected by indices must have the same shape.

resizeNearestNeighbor Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

images: 4-D with shape `[batch, height, width, channels]`.

-> Tensor v2 Int32

size: = A 1-D int32 Tensor of 2 elements: `new_height, new_width`. The new size for the images.

-> Tensor Value t

resized_images: 4-D with shape `[batch, new_height, new_width, channels]`.

Resize images to size using nearest neighbor interpolation.

negTrain Source

Arguments

:: Int64

num_negative_samples: Number of negative samples per example.

-> Tensor v1 Float

w_in: input word embedding.

-> Tensor v2 Float

w_out: output word embedding.

-> Tensor v3 Int32

examples: A vector of word ids.

-> Tensor v4 Int32

labels: A vector of word ids.

-> Tensor v5 Float

lr

-> ControlNode 

Training via negative sampling.

tensorArrayGrad Source

Arguments

:: Tensor v1 ByteString

handle: The handle to the forward TensorArray.

-> Tensor v2 Float

flow_in: A float scalar that enforces proper chaining of operations.

-> Tensor Value ByteString

grad_handle

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.

  • *A note about the input flow_in:**

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.

  • *A note about the source attribute:**

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.

audioSummary Source

Arguments

:: Float

sample_rate: The sample rate of the signal in hertz.

-> Tensor v1 ByteString

tag: Scalar. Used to build the tag attribute of the summary values.

-> Tensor v2 Float

tensor: 2-D of shape `[batch_size, frames]`.

-> Tensor Value ByteString

summary: Scalar. Serialized Summary protocol buffer.

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:

  • If max_outputs is 1, the summary value tag is '*tag*/audio'.
  • If max_outputs is greater than 1, the summary value tags are generated sequentially as '*tag*/audio/0', '*tag*/audio/1', etc.

noOp :: ControlNode Source

Does nothing. Only useful as a placeholder for control edges.

nextIteration Source

Arguments

:: TensorType t 
=> Tensor v1 t

data: The tensor to be made available to the next iteration.

-> Tensor Value t

output: The same tensor as `data`.

Makes its input available to the next iteration.

softplusGrad Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

gradients: The backpropagated gradients to the corresponding softplus operation.

-> Tensor v2 t

features: The features passed as input to the corresponding softplus operation.

-> Tensor Value t

backprops: The gradients: `gradients / (1 + exp(-features))`.

Computes softplus gradients for a softplus operation.

svd Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Double, Float]` t) 
=> Tensor v1 t

input: A tensor of shape `[..., M, N]` whose inner-most 2 dimensions form matrices of size `[M, N]`. Let P be the minimum of M and N.

-> (Tensor Value t, Tensor Value t, Tensor Value t)

(s, u, v)

  • s: Singular values. Shape is `[..., P]`.
  • u: Left singular vectors. If full_matrices is False then shape is `[..., M, M]`; if full_matrices is True then shape is `[..., M, P]`. Undefined if compute_uv is False.
  • v: Left singular vectors. If full_matrices is False then shape is `[..., N, N]`. If full_matrices is True then shape is `[..., N, P]`. Undefined if compute_uv is false.

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) ```

hSVToRGB Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t) 
=> Tensor v1 t

images: 1-D or higher rank. HSV data to convert. Last dimension must be size 3.

-> Tensor Value t

output: images converted to RGB.

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.

parameterizedTruncatedNormal Source

Arguments

:: (TensorType t, OneOf `[Int32, Int64]` t, TensorType dtype, OneOf `[Word16, Double, Float]` dtype) 
=> Tensor v1 t

shape: The shape of the output tensor. Batches are indexed by the 0th dimension.

-> Tensor v2 dtype

means: The mean parameter of each batch.

-> Tensor v3 dtype

stdevs: The standard deviation parameter of each batch. Must be greater than 0.

-> Tensor v4 dtype

minvals: The minimum cutoff. May be -infinity.

-> Tensor v5 dtype

maxvals: The maximum cutoff. May be +infinity, and must be more than the minval for each batch.

-> Tensor Value dtype

output: A matrix of shape num_batches x samples_per_batch, filled with random truncated normal values using the parameters for each row.

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.

square Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int32, Int64, Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor Value t

y

Computes square of x element-wise.

I.e., \(y = x * x = x^2\).

elu Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

features

-> Tensor Value t

activations

Computes exponential linear: `exp(features) - 1` if < 0, features otherwise.

See Fast and Accurate Deep Network Learning by Exponential Linear Units (ELUs)

lookupTableExport Source

Arguments

:: (TensorType tkeys, TensorType tvalues) 
=> Tensor v1 ByteString

table_handle: Handle to the table.

-> (Tensor Value tkeys, Tensor Value tvalues)

(keys, values)

  • keys: Vector of all keys present in the table.
  • values: Tensor of all values in the table. Indexed in parallel with keys.

Outputs all keys and values in the table.

lookupTableSize Source

Arguments

:: Tensor v1 ByteString

table_handle: Handle to the table.

-> Tensor Value Int64

size: Scalar that contains number of elements in the table.

Computes the number of elements in the given table.

avgPoolGrad Source

Arguments

:: (TensorType t, OneOf `[Word16, Double, Float]` t) 
=> Tensor v1 Int32

orig_input_shape: 1-D. Shape of the original input to avg_pool.

-> Tensor v2 t

grad: 4-D with shape `[batch, height, width, channels]`. Gradients w.r.t. the output of avg_pool.

-> Tensor Value t

output: 4-D. Gradients w.r.t. the input of avg_pool.

Computes gradients of the average pooling function.

computeAccidentalHits Source

Arguments

:: Int64

num_true: Number of true labels per context.

-> Tensor v1 Int64

true_classes: The true_classes output of UnpackSparseLabels.

-> Tensor v2 Int64

sampled_candidates: The sampled_candidates output of CandidateSampler.

-> (Tensor Value Int32, Tensor Value Int64, Tensor Value Float)

(indices, ids, weights)

  • indices: A vector of indices corresponding to rows of true_candidates.
  • ids: A vector of IDs of positions in sampled_candidates that match a true_label for the row with the corresponding index in indices.
  • weights: A vector of the same length as indices and ids, in which each element is -FLOAT_MAX.

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.

cTCLoss Source

Arguments

:: Tensor v1 Float

inputs: 3-D, shape: `(max_time x batch_size x num_classes)`, the logits.

-> Tensor v2 Int64

labels_indices: The indices of a `SparseTensor2`. `labels_indices(i, :) == [b, t]` means `labels_values(i)` stores the id for `(batch b, time t)`.

-> Tensor v3 Int32

labels_values: The values (labels) associated with the given batch and time.

-> Tensor v4 Int32

sequence_length: A vector containing sequence lengths (batch).

-> (Tensor Value Float, Tensor Value Float)

(loss, gradient)

  • loss: A vector (batch) containing log-probabilities.
  • gradient: The gradient of loss. 3-D, shape: `(max_time x batch_size x num_classes)`.

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.

avgPool3D Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

input: Shape `[batch, depth, rows, cols, channels]` tensor to pool over.

-> Tensor Value t

output: The average pooled output tensor.

Performs 3D average pooling on the input.

inv Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int32, Int64, Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor Value t

y

Computes the reciprocal of x element-wise.

I.e., \(y = 1 / x\).

stackPop Source

Arguments

:: TensorType elem_type 
=> Tensor v1 ByteString

handle: The handle to a stack.

-> Tensor Value elem_type

elem: The tensor that is popped from the top of the stack.

Pop the element at the top of the stack.

paddingFIFOQueue Source

Arguments

:: Tensor Value ByteString

handle: The handle to the queue.

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.

batchSelfAdjointEigV2 Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t) 
=> Tensor v1 t

input

-> (Tensor Value t, Tensor Value t)

(e, v)

  • e
  • v

batchMatrixTriangularSolve Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t) 
=> Tensor v1 t

matrix

-> Tensor v2 t

rhs

-> Tensor Value t

output

batchMatrixSolveLs Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t) 
=> Tensor v1 t

matrix

-> Tensor v2 t

rhs

-> Tensor v3 Double

l2_regularizer

-> Tensor Value t

output

batchSvd Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Double, Float]` t) 
=> Tensor v1 t

input

-> (Tensor Value t, Tensor Value t, Tensor Value t)

(s, u, v)

  • s
  • u
  • v

tensorSummary Source

Arguments

:: TensorType t 
=> Tensor v1 t

tensor: A tensor to serialize.

-> Tensor Value ByteString

summary

Outputs a Summary protocol buffer with a tensor.

sparseSoftmaxCrossEntropyWithLogits Source

Arguments

:: (TensorType t, OneOf `[Word16, Double, Float]` t, TensorType tlabels, OneOf `[Int32, Int64]` tlabels) 
=> Tensor v1 t

features: batch_size x num_classes matrix

-> Tensor v2 tlabels

labels: batch_size vector with values in [0, num_classes). This is the label for the given minibatch entry.

-> (Tensor Value t, Tensor Value t)

(loss, backprop)

  • loss: Per example loss (batch_size vector).
  • backprop: backpropagated gradients (batch_size x num_classes matrix).

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.

maxPoolWithArgmax Source

Arguments

:: (TensorType t, OneOf `[Word16, Float]` t, TensorType targmax, OneOf `[Int32, Int64]` targmax) 
=> Tensor v1 t

input: 4-D with shape `[batch, height, width, channels]`. Input to pool over.

-> (Tensor Value t, Tensor Value targmax)

(output, argmax)

  • output: The max pooled output tensor.
  • argmax: 4-D. The flattened indices of the max values chosen for each output.

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`.

fFT Source

Arguments

:: Tensor v1 (Complex Float)

input: A complex64 tensor.

-> Tensor Value (Complex Float)

output: A complex64 tensor of the same shape as input. The inner-most dimension of input is replaced with its 1D Fourier Transform.

Compute the 1-dimensional discrete Fourier Transform over the inner-most

dimension of input.

histogramSummary Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 ByteString

tag: Scalar. Tag to use for the Value.

-> Tensor v2 t

values: Any shape. Values to use to build the histogram.

-> Tensor Value ByteString

summary: Scalar. Serialized Summary protocol buffer.

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.

pad Source

Arguments

:: (TensorType t, TensorType tpaddings, OneOf `[Int32, Int64]` tpaddings) 
=> Tensor v1 t

input

-> Tensor v2 tpaddings

paddings

-> Tensor Value t

output

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]] ```

batchIFFT3D Source

Arguments

:: Tensor v1 (Complex Float)

input

-> Tensor Value (Complex Float)

output

imageSummary Source

Arguments

:: (TensorType t, OneOf `[Word16, Word8, Float]` t) 
=> Tensor v1 ByteString

tag: Scalar. Used to build the tag attribute of the summary values.

-> Tensor v2 t

tensor: 4-D of shape `[batch_size, height, width, channels]` where channels is 1, 3, or 4.

-> Tensor Value ByteString

summary: Scalar. Serialized Summary protocol buffer.

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:

  • 1: tensor is interpreted as Grayscale.
  • 3: tensor is interpreted as RGB.
  • 4: tensor is interpreted as RGBA.

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:

  • If the input values are all positive, they are rescaled so the largest one is 255.
  • If any input value is negative, the values are shifted so input value 0.0 is at 127. They are then rescaled so that either the smallest value is 0, or the largest one is 255.

The tag argument is a scalar Tensor of type string. It is used to build the tag of the summary values:

  • If max_images is 1, the summary value tag is '*tag*/image'.
  • If max_images is greater than 1, the summary value tags are generated sequentially as '*tag*/image/0', '*tag*/image/1', etc.

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.

segmentSum Source

Arguments

:: (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

data

-> Tensor v2 tindices

segment_ids: A 1-D tensor whose rank is equal to the rank of `data`'s first dimension. Values should be sorted and can be repeated.

-> Tensor Value t

output: Has same shape as data, except for dimension 0 which has size k, the number of segments.

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

encodeJpeg Source

Arguments

:: Tensor v1 Word8

image: 3-D with shape `[height, width, channels]`.

-> Tensor Value ByteString

contents: 0-D. JPEG-encoded image.

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:

  • `''`: Use a default format based on the number of channels in the image.
  • grayscale: Output a grayscale JPEG image. The channels dimension of image must be 1.
  • rgb: Output an RGB JPEG image. The channels dimension of image must be 3.

If format is not specified or is the empty string, a default format is picked in function of the number of channels in image:

  • 1: Output a grayscale image.
  • 3: Output an RGB image.

batchNormWithGlobalNormalizationGrad Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Bool

scale_after_normalization: A bool indicating whether the resulted tensor needs to be multiplied with gamma.

-> Float

variance_epsilon: A small float number to avoid dividing by 0.

-> Tensor v1 t

t: A 4D input Tensor.

-> Tensor v2 t

m: A 1D mean Tensor with size matching the last dimension of t. This is the first output from tf.nn.moments, or a saved moving average thereof.

-> Tensor v3 t

v: A 1D variance Tensor with size matching the last dimension of t. This is the second output from tf.nn.moments, or a saved moving average thereof.

-> Tensor v4 t

gamma: A 1D gamma Tensor with size matching the last dimension of t. If "scale_after_normalization" is true, this Tensor will be multiplied with the normalized Tensor.

-> Tensor v5 t

backprop: 4D backprop Tensor.

-> (Tensor Value t, Tensor Value t, Tensor Value t, Tensor Value t, Tensor Value t)

(dx, dm, dv, db, dg)

  • dx: 4D backprop tensor for input.
  • dm: 1D backprop tensor for mean.
  • dv: 1D backprop tensor for variance.
  • db: 1D backprop tensor for beta.
  • dg: 1D backprop tensor for gamma.

Gradients for batch normalization.

This op is deprecated. See `tf.nn.batch_normalization`.

biasAddV1 Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

value: Any number of dimensions.

-> Tensor v2 t

bias: 1-D with size the last dimension of value.

-> Tensor Value t

output: Broadcasted sum of value and bias.

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.

invertPermutation Source

Arguments

:: (TensorType t, OneOf `[Int32, Int64]` t) 
=> Tensor v1 t

x: 1-D.

-> Tensor Value t

y: 1-D.

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] ```

mirrorPadGrad Source

Arguments

:: (TensorType t, TensorType tpaddings, OneOf `[Int32, Int64]` tpaddings) 
=> Tensor v1 t

input: The input tensor to be folded.

-> Tensor v2 tpaddings

paddings: A two-column matrix specifying the padding sizes. The number of rows must be the same as the rank of input.

-> Tensor Value t

output: The folded tensor.

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]] ```

reverse Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Bool, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

tensor: Up to 8-D.

-> Tensor v2 Bool

dims: 1-D. The dimensions to reverse.

-> Tensor Value t

output: The same shape as tensor.

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]]]] ```

conv2D Source

Arguments

:: (TensorType t, OneOf `[Word16, Double, Float]` t) 
=> Tensor v1 t

input

-> Tensor v2 t

filter

-> Tensor Value t

output

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. 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]`.
  3. For each patch, right-multiplies the filter matrix and the image patch vector.

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]`.

conv2DBackpropInput Source

Arguments

:: (TensorType t, OneOf `[Word16, Double, Float]` t) 
=> Tensor v1 Int32

input_sizes: An integer vector representing the shape of input, where input is a 4-D `[batch, height, width, channels]` tensor.

-> Tensor v2 t

filter: 4-D with shape `[filter_height, filter_width, in_channels, out_channels]`.

-> Tensor v3 t

out_backprop: 4-D with shape `[batch, out_height, out_width, out_channels]`. Gradients w.r.t. the output of the convolution.

-> Tensor Value t

output: 4-D with shape `[batch, in_height, in_width, in_channels]`. Gradient w.r.t. the input of the convolution.

Computes the gradients of convolution with respect to the input.

readerSerializeState Source

Arguments

:: Tensor v1 ByteString

reader_handle: Handle to a Reader.

-> Tensor Value ByteString

state

Produce a string tensor that encodes the state of a Reader.

Not all Readers support being serialized, so this can produce an Unimplemented error.

temporaryVariable Source

Arguments

:: TensorType dtype 
=> Tensor Value dtype

ref: A reference to the variable tensor.

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)

cropAndResize Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

image: A 4-D tensor of shape `[batch, image_height, image_width, depth]`. Both image_height and image_width need to be positive.

-> Tensor v2 Float

boxes: A 2-D tensor of shape `[num_boxes, 4]`. The i-th row of the tensor specifies the coordinates of a box in the `box_ind[i]` image and is specified in normalized coordinates `[y1, x1, y2, x2]`. A normalized coordinate value of y is mapped to the image coordinate at `y * (image_height - 1)`, so as the `[0, 1]` interval of normalized image height is mapped to `[0, image_height - 1] in image height coordinates. We do allow y1 > y2, in which case the sampled crop is an up-down flipped version of the original image. The width dimension is treated similarly. Normalized coordinates outside the `[0, 1]` range are allowed, in which case we use extrapolation_value to extrapolate the input image values.

-> Tensor v3 Int32

box_ind: A 1-D tensor of shape `[num_boxes]` with int32 values in `[0, batch)`. The value of `box_ind[i]` specifies the image that the i-th box refers to.

-> Tensor v4 Int32

crop_size: A 1-D tensor of 2 elements, `size = [crop_height, crop_width]`. All cropped image patches are resized to this size. The aspect ratio of the image content is not preserved. Both crop_height and crop_width need to be positive.

-> Tensor Value Float

crops: A 4-D tensor of shape `[num_boxes, crop_height, crop_width, depth]`.

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]`.

maxPoolGrad Source

Arguments

:: (TensorType t, OneOf `[Word16, Float]` t) 
=> Tensor v1 t

orig_input: The original input tensor.

-> Tensor v2 t

orig_output: The original output tensor.

-> Tensor v3 t

grad: 4-D. Gradients w.r.t. the output of max_pool.

-> Tensor Value t

output: Gradients w.r.t. the input to max_pool.

Computes gradients of the maxpooling function.

fusedResizeAndPadConv2D Source

Arguments

:: (TensorType t, OneOf `[Word16, Double, Float]` t) 
=> Tensor v1 t

input: 4-D with shape `[batch, in_height, in_width, in_channels]`.

-> Tensor v2 Int32

size: A 1-D int32 Tensor of 2 elements: `new_height, new_width`. The new size for the images.

-> Tensor v3 Int32

paddings: A two-column matrix specifying the padding sizes. The number of rows must be the same as the rank of input.

-> Tensor v4 t

filter: 4-D with shape `[filter_height, filter_width, in_channels, out_channels]`.

-> Tensor Value t

output

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.

randomUniform Source

Arguments

:: (TensorType t, OneOf `[Int32, Int64]` t, TensorType dtype, OneOf `[Word16, Double, Float]` dtype) 
=> Tensor v1 t

shape: The shape of the output tensor.

-> Tensor Value dtype

output: A tensor of the specified shape filled with uniform random values.

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.

depthwiseConv2dNative Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t) 
=> Tensor v1 t

input

-> Tensor v2 t

filter

-> Tensor Value t

output

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]`.

sparseApplyAdadelta Source

Arguments

:: (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

var

-> Tensor v2 t

accum: Should be from a Variable().

-> Tensor v3 t

accum_update: : Should be from a Variable().

-> Tensor v4 t

lr: Learning rate. Must be a scalar.

-> Tensor v5 t

rho: Decay factor. Must be a scalar.

-> Tensor v6 t

epsilon: Constant factor. Must be a scalar.

-> Tensor v7 t

grad: The gradient.

-> Tensor v8 tindices

indices: A vector of indices into the first dimension of var and accum.

-> Tensor Value t

out: Same as "var".

var: Should be from a Variable().

depthwiseConv2dNativeBackpropFilter Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t) 
=> Tensor v1 t

input: 4-D with shape `[batch, in_height, in_width, in_channels]`.

-> Tensor v2 Int32

filter_sizes: An integer vector representing the tensor shape of filter, where filter is a 4-D `[filter_height, filter_width, in_channels, depthwise_multiplier]` tensor.

-> Tensor v3 t

out_backprop: 4-D with shape `[batch, out_height, out_width, out_channels]`. Gradients w.r.t. the output of the convolution.

-> Tensor Value t

output: 4-D with shape `[filter_height, filter_width, in_channels, out_channels]`. Gradient w.r.t. the filter input of the convolution.

Computes the gradients of depthwise convolution with respect to the filter.

conv3D Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

input: Shape `[batch, in_depth, in_height, in_width, in_channels]`.

-> Tensor v2 t

filter: Shape `[filter_depth, filter_height, filter_width, in_channels, out_channels]`. in_channels must match between input and filter.

-> Tensor Value t

output

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.

greaterEqual Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor v2 t

y

-> Tensor Value Bool

z

Returns the truth value of (x >= y) element-wise.

  • NOTE*: GreaterEqual supports broadcasting. More about broadcasting here

sparseDenseCwiseAdd Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 Int64

sp_indices: 2-D. `N x R` matrix with the indices of non-empty values in a SparseTensor, possibly not in canonical ordering.

-> Tensor v2 t

sp_values: 1-D. N non-empty values corresponding to sp_indices.

-> Tensor v3 Int64

sp_shape: 1-D. Shape of the input SparseTensor.

-> Tensor v4 t

dense: R-D. The dense Tensor operand.

-> Tensor Value t

output: 1-D. The N values that are operated on.

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. Then, only the dense values pointed to by the indices of the SparseTensor participate in the cwise addition.

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.

conv3DBackpropFilter Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

input: Shape `[batch, depth, rows, cols, in_channels]`.

-> Tensor v2 t

filter: Shape `[depth, rows, cols, in_channels, out_channels]`. in_channels must match between input and filter.

-> Tensor v3 t

out_backprop: Backprop signal of shape `[batch, out_depth, out_rows, out_cols, out_channels]`.

-> Tensor Value t

output

Computes the gradients of 3-D convolution with respect to the filter.

conv3DBackpropInputV2 Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 Int32

input_sizes: An integer vector representing the tensor shape of input, where input is a 5-D `[batch, depth, rows, cols, in_channels]` tensor.

-> Tensor v2 t

filter: Shape `[depth, rows, cols, in_channels, out_channels]`. in_channels must match between input and filter.

-> Tensor v3 t

out_backprop: Backprop signal of shape `[batch, out_depth, out_rows, out_cols, out_channels]`.

-> Tensor Value t

output

Computes the gradients of 3-D convolution with respect to the input.

mod Source

Arguments

:: (TensorType t, OneOf `[Int32, Int64, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor v2 t

y

-> Tensor Value t

z

Returns element-wise remainder of division.

  • NOTE*: Mod supports broadcasting. More about broadcasting here

refMerge Source

Arguments

:: TensorType t 
=> [Tensor v1 t]

inputs: The input tensors, exactly one of which will become available.

-> (Tensor Value t, Tensor Value Int32)

(output, value_index)

  • output: Will be set to the available input tensor.
  • value_index: The index of the chosen input tensor in inputs.

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.

conv3DBackpropFilterV2 Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

input: Shape `[batch, depth, rows, cols, in_channels]`.

-> Tensor v2 Int32

filter_sizes: An integer vector representing the tensor shape of filter, where filter is a 5-D `[filter_depth, filter_height, filter_width, in_channels, out_channels]` tensor.

-> Tensor v3 t

out_backprop: Backprop signal of shape `[batch, out_depth, out_rows, out_cols, out_channels]`.

-> Tensor Value t

output

Computes the gradients of 3-D convolution with respect to the filter.

serializeManySparse Source

Arguments

:: TensorType t 
=> Tensor v1 Int64

sparse_indices: 2-D. The indices of the minibatch SparseTensor.

-> Tensor v2 t

sparse_values: 1-D. The values of the minibatch SparseTensor.

-> Tensor v3 Int64

sparse_shape: 1-D. The shape of the minibatch SparseTensor.

-> Tensor Value ByteString

serialized_sparse

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]`.

avgPool3DGrad Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 Int32

orig_input_shape: The original input dimensions.

-> Tensor v2 t

grad: Output backprop of shape `[batch, depth, rows, cols, channels]`.

-> Tensor Value t

output: The backprop for input.

Computes gradients of average pooling function.

maxPool3DGrad Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 Float

orig_input: The original input tensor.

-> Tensor v2 Float

orig_output: The original output tensor.

-> Tensor v3 t

grad: Output backprop of shape `[batch, depth, rows, cols, channels]`.

-> Tensor Value t

output

Computes gradients of max pooling function.

sparseReduceSum Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 Int64

input_indices: 2-D. `N x R` matrix with the indices of non-empty values in a SparseTensor, possibly not in canonical ordering.

-> Tensor v2 t

input_values: 1-D. N non-empty values corresponding to input_indices.

-> Tensor v3 Int64

input_shape: 1-D. Shape of the input SparseTensor.

-> Tensor v4 Int32

reduction_axes: 1-D. Length-K vector containing the reduction axes.

-> Tensor Value t

output: `R-K`-D. The reduced Tensor.

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.

relu Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

features

-> Tensor Value t

activations

Computes rectified linear: `max(features, 0)`.

l2Loss Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

t: Typically 2-D, but may have any dimensions.

-> Tensor Value t

output: 0-D.

L2 Loss.

Computes half the L2 norm of a tensor without the sqrt:

output = sum(t ** 2) / 2

readerRestoreState Source

Arguments

:: Tensor v1 ByteString

reader_handle: Handle to a Reader.

-> Tensor v2 ByteString

state: Result of a ReaderSerializeState of a Reader with type matching reader_handle.

-> ControlNode 

Restore a reader to a previously saved state.

Not all Readers support being restored, so this can produce an Unimplemented error.

shape Source

Arguments

:: (TensorType t, TensorType out_type, OneOf `[Int32, Int64]` out_type) 
=> Tensor v1 t

input

-> Tensor Value out_type

output

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] ```

softmaxCrossEntropyWithLogits Source

Arguments

:: (TensorType t, OneOf `[Word16, Double, Float]` t) 
=> Tensor v1 t

features: batch_size x num_classes matrix

-> Tensor v2 t

labels: batch_size x num_classes matrix The caller must ensure that each batch of labels represents a valid probability distribution.

-> (Tensor Value t, Tensor Value t)

(loss, backprop)

  • loss: Per example loss (batch_size vector).
  • backprop: backpropagated gradients (batch_size x num_classes matrix).

Computes softmax cross entropy cost and gradients to backpropagate.

Inputs are the logits, not probabilities.

maxPool Source

Arguments

:: (TensorType t, OneOf `[Word16, Float]` t) 
=> Tensor v1 t

input: 4-D input to pool over.

-> Tensor Value t

output: The max pooled output tensor.

Performs max pooling on the input.

dilation2DBackpropInput Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

input: 4-D with shape `[batch, in_height, in_width, depth]`.

-> Tensor v2 t

filter: 3-D with shape `[filter_height, filter_width, depth]`.

-> Tensor v3 t

out_backprop: 4-D with shape `[batch, out_height, out_width, depth]`.

-> Tensor Value t

in_backprop: 4-D with shape `[batch, in_height, in_width, depth]`.

Computes the gradient of morphological 2-D dilation with respect to the input.

equal Source

Returns the truth value of (x == y) element-wise.

  • NOTE*: Equal supports broadcasting. More about broadcasting here

dilation2DBackpropFilter Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

input: 4-D with shape `[batch, in_height, in_width, depth]`.

-> Tensor v2 t

filter: 3-D with shape `[filter_height, filter_width, depth]`.

-> Tensor v3 t

out_backprop: 4-D with shape `[batch, out_height, out_width, depth]`.

-> Tensor Value t

filter_backprop: 3-D with shape `[filter_height, filter_width, depth]`.

Computes the gradient of morphological 2-D dilation with respect to the filter.

reluGrad Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

gradients: The backpropagated gradients to the corresponding Relu operation.

-> Tensor v2 t

features: The features passed as input to the corresponding Relu operation, OR the outputs of that operation (both work equivalently).

-> Tensor Value t

backprops: `gradients * (features > 0)`.

Computes rectified linear gradients for a Relu operation.

relu6 Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

features

-> Tensor Value t

activations

Computes rectified linear 6: `min(max(features, 0), 6)`.

resizeBicubic Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

images: 4-D with shape `[batch, height, width, channels]`.

-> Tensor v2 Int32

size: = A 1-D int32 Tensor of 2 elements: `new_height, new_width`. The new size for the images.

-> Tensor Value Float

resized_images: 4-D with shape `[batch, new_height, new_width, channels]`.

Resize images to size using bicubic interpolation.

Input images can be of different types but output images are always float.

relu6Grad Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

gradients: The backpropagated gradients to the corresponding Relu6 operation.

-> Tensor v2 t

features: The features passed as input to the corresponding Relu6 operation.

-> Tensor Value t

backprops: The gradients: `gradients * features * (features > 0) * (features < 6)`.

Computes rectified linear 6 gradients for a Relu6 operation.

sparseTensorDenseMatMul Source

Arguments

:: TensorType t 
=> Tensor v1 Int64

a_indices: 2-D. The indices of the SparseTensor, size `[nnz, 2]` Matrix.

-> Tensor v2 t

a_values: 1-D. The values of the SparseTensor, size `[nnz]` Vector.

-> Tensor v3 Int64

a_shape: 1-D. The shape of the SparseTensor, size `[2]` Vector.

-> Tensor v4 t

b: 2-D. A dense Matrix.

-> Tensor Value t

product

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).

softplus Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

features

-> Tensor Value t

activations

Computes softplus: `log(exp(features) + 1)`.

batchMatMul Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int32, Word16, Double, Float]` t) 
=> Tensor v1 t

x: 3-D or higher with shape `[..., r_x, c_x]`.

-> Tensor v2 t

y: 3-D or higher with shape `[..., r_y, c_y]`.

-> Tensor Value t

output: 3-D or higher with shape `[..., r_o, c_o]`

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[..., :, :])

softsignGrad Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

gradients: The backpropagated gradients to the corresponding softsign operation.

-> Tensor v2 t

features: The features passed as input to the corresponding softsign operation.

-> Tensor Value t

backprops: The gradients: `gradients / (1 + abs(-features)) ** 2`.

Computes softsign gradients for a softsign operation.

lessEqual Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor v2 t

y

-> Tensor Value Bool

z

Returns the truth value of (x <= y) element-wise.

  • NOTE*: LessEqual supports broadcasting. More about broadcasting here

logSoftmax Source

Arguments

:: (TensorType t, OneOf `[Word16, Double, Float]` t) 
=> Tensor v1 t

logits: 2-D with shape `[batch_size, num_classes]`.

-> Tensor Value t

logsoftmax: Same shape as logits.

Computes log softmax activations.

For each batch i and class j we have

logsoftmax[i, j] = logits[i, j] - log(sum(exp(logits[i])))

inTopK Source

Arguments

:: (TensorType t, OneOf `[Int32, Int64]` t) 
=> Int64

k: Number of top elements to look at for computing precision.

-> Tensor v1 Float

predictions: A batch_size x classes tensor.

-> Tensor v2 t

targets: A batch_size vector of class ids.

-> Tensor Value Bool

precision: Computed Precision at k as a `bool Tensor`.

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)$$

matrixDiag Source

Arguments

:: TensorType t 
=> Tensor v1 t

diagonal: Rank k, where `k >= 1`.

-> Tensor Value t

output: Rank `k+1`, with `output.shape = diagonal.shape + [diagonal.shape[-1]]`.

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) ```

maxPool3D Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

input: Shape `[batch, depth, rows, cols, channels]` tensor to pool over.

-> Tensor Value t

output: The max pooled output tensor.

Performs 3D max pooling on the input.

topK Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Int64

k: Number of top elements to look for along the last dimension (along each row for matrices).

-> Tensor v1 t

input: 1-D or higher with last dimension at least k.

-> (Tensor Value t, Tensor Value Int32)

(values, indices)

  • values: The k largest elements along each last dimensional slice.
  • indices: The indices of values within the last dimension of input.

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.

topKV2 Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

input: 1-D or higher with last dimension at least k.

-> Tensor v2 Int32

k: 0-D. Number of top elements to look for along the last dimension (along each row for matrices).

-> (Tensor Value t, Tensor Value Int32)

(values, indices)

  • values: The k largest elements along each last dimensional slice.
  • indices: The indices of values within the last dimension of input.

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.

fractionalMaxPool Source

Arguments

:: (TensorType t, OneOf `[Int32, Int64, Double, Float]` t) 
=> Tensor v1 t

value: 4-D with shape `[batch, height, width, channels]`.

-> (Tensor Value t, Tensor Value Int64, Tensor Value Int64)

(output, row_pooling_sequence, col_pooling_sequence)

  • output: output tensor after fractional max pooling.
  • row_pooling_sequence: row pooling sequence, needed to calculate gradient.
  • col_pooling_sequence: column pooling sequence, needed to calculate gradient.

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. output_row_length : which will be smaller than the input
  3. alpha = input_row_length / output_row_length : our reduction ratio
  4. K = floor(alpha)
  5. row_pooling_sequence : this is the result list of pool boundary rows

Then, row_pooling_sequence should satisfy:

  1. a[0] = 0 : the first value of the sequence is 0
  2. a[end] = input_row_length : the last value of the sequence is the size
  3. K <= (a[i+1] - a[i]) <= K+1 : all intervals are K or K+1 size
  4. length(row_pooling_sequence) = output_row_length+1

For more details on fractional max pooling, see this paper: Benjamin Graham, Fractional Max-Pooling

matrixBandPart Source

Arguments

:: TensorType t 
=> Tensor v1 t

input: Rank k tensor.

-> Tensor v2 Int64

num_lower: 0-D tensor. Number of subdiagonals to keep. If negative, keep entire lower triangle.

-> Tensor v3 Int64

num_upper: 0-D tensor. Number of superdiagonals to keep. If negative, keep entire upper triangle.

-> Tensor Value t

band: Rank k tensor of the same shape as input. The extracted banded tensor.

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. ```

decodeRaw Source

Arguments

:: (TensorType out_type, OneOf `[Int16, Int32, Int64, Int8, Word8, Double, Float]` out_type) 
=> Tensor v1 ByteString

bytes: All the elements must have the same length.

-> Tensor Value out_type

output: A Tensor with one more dimension than the input bytes. The added dimension will have size equal to the length of the elements of bytes divided by the number of bytes to represent out_type.

Reinterpret the bytes of a string as a vector of numbers.

decodeJSONExample Source

Arguments

:: Tensor v1 ByteString

json_examples: Each string is a JSON object serialized according to the JSON mapping of the Example proto.

-> Tensor Value ByteString

binary_examples: Each string is a binary Example protocol buffer corresponding to the respective element of json_examples.

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.

truncatedNormal Source

Arguments

:: (TensorType t, OneOf `[Int32, Int64]` t, TensorType dtype, OneOf `[Word16, Double, Float]` dtype) 
=> Tensor v1 t

shape: The shape of the output tensor.

-> Tensor Value dtype

output: A tensor of the specified shape filled with random truncated normal values.

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.

randomShuffle Source

Arguments

:: TensorType t 
=> Tensor v1 t

value: The tensor to be shuffled.

-> Tensor Value t

output: A tensor of same shape and type as value, shuffled along its first dimension.

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]] ```

multinomial Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

logits: 2-D Tensor with shape `[batch_size, num_classes]`. Each slice `[i, :]` represents the unnormalized log probabilities for all classes.

-> Tensor v2 Int32

num_samples: 0-D. Number of independent samples to draw for each row slice.

-> Tensor Value Int64

output: 2-D Tensor with shape `[batch_size, num_samples]`. Each slice `[i, :]` contains the drawn class labels with range `[0, num_classes)`.

Draws samples from a multinomial distribution.

randomGamma Source

Arguments

:: (TensorType s, OneOf `[Int32, Int64]` s, TensorType t, OneOf `[Word16, Double, Float]` t) 
=> Tensor v1 s

shape: 1-D integer tensor. Shape of independent samples to draw from each distribution described by the shape parameters given in alpha.

-> Tensor v2 t

alpha: A tensor in which each scalar is a "shape" parameter describing the associated gamma distribution.

-> Tensor Value t

output: A tensor with shape `shape + shape(alpha)`. Each slice `[:, ..., :, i0, i1, ...iN]` contains the samples drawn for `alpha[i0, i1, ...iN]`. The dtype of the output matches the dtype of alpha.

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

addN Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> [Tensor v1 t]

inputs: Must all be the same size and shape.

-> Tensor Value t

sum

Add all input tensors element wise.

max Source

Arguments

:: (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

input: The tensor to reduce.

-> Tensor v2 tidx

reduction_indices: The dimensions to reduce.

-> Tensor Value t

output: The reduced tensor.

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.

_Retval Source

Arguments

:: TensorType t 
=> Int64

index: This return value is the index-th return value of the function.

-> Tensor v1 t

input: The return value.

-> ControlNode 

A graph node which represents a return value of a function.

destroyTemporaryVariable Source

Arguments

:: TensorType t 
=> Tensor v1 t

ref: A reference to the temporary variable tensor.

-> Tensor Value t

value

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.

cast Source

Arguments

:: (TensorType dstT, TensorType srcT) 
=> Tensor v1 srcT

x

-> Tensor Value dstT

y

Cast x of type SrcT to y of DstT.

countUpTo Source

Arguments

:: (TensorType t, OneOf `[Int32, Int64]` t) 
=> Int64

limit: If incrementing ref would bring it above limit, instead generates an OutOfRange error.

-> Tensor v1 t

ref: Should be from a scalar Variable node.

-> Tensor Value t

output: A copy of the input before increment. If nothing else modifies the input, the values produced will all be distinct.

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.

abs Source

Arguments

:: (TensorType t, OneOf `[Int32, Int64, Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor Value t

y

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|\).

neg Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int32, Int64, Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor Value t

y

Computes numerical negative value element-wise.

I.e., \(y = -x\).

sparseSparseMaximum Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 Int64

a_indices: 2-D. `N x R` matrix with the indices of non-empty values in a SparseTensor, in the canonical lexicographic ordering.

-> Tensor v2 t

a_values: 1-D. N non-empty values corresponding to a_indices.

-> Tensor v3 Int64

a_shape: 1-D. Shape of the input SparseTensor.

-> Tensor v4 Int64

b_indices: counterpart to a_indices for the other operand.

-> Tensor v5 t

b_values: counterpart to a_values for the other operand; must be of the same dtype.

-> Tensor v6 Int64

b_shape: counterpart to a_shape for the other operand; the two shapes must be equal.

-> (Tensor Value Int64, Tensor Value t)

(output_indices, output_values)

  • output_indices: 2-D. The indices of the output SparseTensor.
  • output_values: 1-D. The values of the output SparseTensor.

Returns the element-wise max of two SparseTensors.

Assumes the two SparseTensors have the same shape, i.e., no broadcasting.

invGrad Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor v2 t

y

-> Tensor Value t

z

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.

sqrt Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor Value t

y

Computes square root of x element-wise.

I.e., \(y = sqrt{x} = x^{1/2}\).

matrixInverse Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t) 
=> Tensor v1 t

input: Shape is `[..., M, M]`.

-> Tensor Value t

output: Shape is `[..., M, M]`.

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.

sqrtGrad Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor v2 t

y

-> Tensor Value t

z

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.

expandDims Source

Arguments

:: (TensorType t, TensorType tdim, OneOf `[Int32, Int64]` tdim) 
=> Tensor v1 t

input

-> Tensor v2 tdim

dim: 0-D (scalar). Specifies the dimension index at which to expand the shape of input.

-> Tensor Value t

output: Contains the same data as input, but its shape has an additional dimension of size 1 added.

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.

all Source

Arguments

:: (TensorType tidx, OneOf `[Int32, Int64]` tidx) 
=> Tensor v1 Bool

input: The tensor to reduce.

-> Tensor v2 tidx

reduction_indices: The dimensions to reduce.

-> Tensor Value Bool

output: The reduced tensor.

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.

cTCBeamSearchDecoder Source

Arguments

:: Int64

beam_width: A scalar >= 0 (beam search beam width).

-> Int64

top_paths: A scalar >= 0, <= beam_width (controls output size).

-> Tensor v1 Float

inputs: 3-D, shape: `(max_time x batch_size x num_classes)`, the logits.

-> Tensor v2 Int32

sequence_length: A vector containing sequence lengths, size `(batch)`.

-> ([Tensor Value Int64], [Tensor Value Int64], [Tensor Value Int64], Tensor Value Float)

(decoded_indices, decoded_values, decoded_shape, log_probability)

  • decoded_indices: A list (length: top_paths) of indices matrices. Matrix j, size `(total_decoded_outputs[j] x 2)`, has indices of a `SparseTensor2`. The rows store: [batch, time].
  • decoded_values: A list (length: top_paths) of values vectors. Vector j, size `(length total_decoded_outputs[j])`, has the values of a `SparseTensor2`. The vector stores the decoded classes for beam j.
  • decoded_shape: A list (length: top_paths) of shape vector. Vector j, size `(2)`, stores the shape of the decoded `SparseTensor[j]`. Its values are: `[batch_size, max_decoded_length[j]]`.
  • log_probability: A matrix, shaped: `(batch_size x top_paths)`. The sequence log-probabilities.

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.

rsqrt Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor Value t

y

Computes reciprocal of square root of x element-wise.

I.e., \(y = 1 / sqrt{x}\).

tanhGrad Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor v2 t

y

-> Tensor Value t

z

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.

sin Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor Value t

y

Computes sin of x element-wise.

matrixDeterminant Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t) 
=> Tensor v1 t

input: Shape is `[..., M, M]`.

-> Tensor Value t

output: Shape is `[...]`.

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 `[..., :, :]`.

cos Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor Value t

y

Computes cos of x element-wise.

batchToSpace Source

Arguments

:: (TensorType t, TensorType tidx, OneOf `[Int32, Int64]` tidx) 
=> Int64

block_size

-> Tensor v1 t

input: 4-D tensor with shape `[batch*block_size*block_size, height_padblock_size, width_padblock_size, depth]`. Note that the batch size of the input tensor must be divisible by `block_size * block_size`.

-> Tensor v2 tidx

crops: 2-D tensor of non-negative integers with shape `[2, 2]`. It specifies how many elements to crop from the intermediate result across the spatial dimensions as follows:

crops = [[crop_top, crop_bottom], [crop_left, crop_right]]

-> Tensor Value t

output: 4-D with shape `[batch, height, width, depth]`, where:

height = height_pad - crop_top - crop_bottom width = width_pad - crop_left - crop_right

The attr block_size must be greater than one. It indicates the block size.

Some examples:

  1. For the following input of shape `[4, 1, 1, 1]` and block_size of 2:

```prettyprint [[[[1]]], [[[2]]], [[[3]]], [[[4]]]] ```

The output tensor has shape `[1, 2, 2, 1]` and value:

```prettyprint x = [[[[1], [2]], [[3], [4]]]] ```

  1. For the following input of shape `[4, 1, 1, 3]` and block_size of 2:

```prettyprint [[[1, 2, 3]], [[4, 5, 6]], [[7, 8, 9]], [[10, 11, 12]]] ```

The output tensor has shape `[1, 2, 2, 3]` and value:

```prettyprint x = [[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]] ```

  1. For the following input of shape `[4, 2, 2, 1]` and block_size of 2:

```prettyprint x = [[[[1], [3]], [[5], [7]]], [[[2], [4]], [[10], [12]]], [[[5], [7]], [[13], [15]]], [[[6], [8]], [[14], [16]]]] ```

The output tensor has shape `[1, 4, 4, 1]` and value:

```prettyprint x = [[[1], [2], [3], [4]], [[5], [6], [7], [8]], [[9], [10], [11], [12]], [[13], [14], [15], [16]]] ```

  1. For the following input of shape `[8, 1, 2, 1]` and block_size of 2:

```prettyprint x = [[[[1], [3]]], [[[9], [11]]], [[[2], [4]]], [[[10], [12]]], [[[5], [7]]], [[[13], [15]]], [[[6], [8]]], [[[14], [16]]]] ```

The output tensor has shape `[2, 2, 4, 1]` and value:

```prettyprint x = [[[[1], [3]], [[5], [7]]], [[[2], [4]], [[10], [12]]], [[[5], [7]], [[13], [15]]], [[[6], [8]], [[14], [16]]]] ```

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.

sparseToDense Source

Arguments

:: (TensorType t, TensorType tindices, OneOf `[Int32, Int64]` tindices) 
=> Tensor v1 tindices

sparse_indices: 0-D, 1-D, or 2-D. `sparse_indices[i]` contains the complete index where `sparse_values[i]` will be placed.

-> Tensor v2 tindices

output_shape: 1-D. Shape of the dense output tensor.

-> Tensor v3 t

sparse_values: 1-D. Values corresponding to each row of sparse_indices, or a scalar value to be used for all sparse indices.

-> Tensor v4 t

default_value: Scalar value to set for indices not specified in sparse_indices.

-> Tensor Value t

dense: Dense output tensor of shape output_shape.

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.

asin Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int32, Int64, Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor Value t

y

Computes asin of x element-wise.

argMin Source

Arguments

:: (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

input

-> Tensor v2 tidx

dimension: int32, 0 <= dimension < rank(input). Describes which dimension of the input Tensor to reduce across. For vectors, use dimension = 0.

-> Tensor Value Int64

output

Returns the index with the smallest value across dimensions of a tensor.

isInf Source

Arguments

:: (TensorType t, OneOf `[Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor Value Bool

y

Returns which elements of x are Inf.

sign Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int32, Int64, Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor Value t

y

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`.

add Source

Returns x + y element-wise.

  • NOTE*: Add supports broadcasting. AddN does not. More about broadcasting here

sparseApplyFtrl Source

Arguments

:: (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

var: Should be from a Variable().

-> Tensor v2 t

accum: Should be from a Variable().

-> Tensor v3 t

linear: Should be from a Variable().

-> Tensor v4 t

grad: The gradient.

-> Tensor v5 tindices

indices: A vector of indices into the first dimension of var and accum.

-> Tensor v6 t

lr: Scaling factor. Must be a scalar.

-> Tensor v7 t

l1: L1 regularization. Must be a scalar.

-> Tensor v8 t

l2: L2 regularization. Must be a scalar.

-> Tensor v9 t

lr_power: Scaling factor. Must be a scalar.

-> Tensor Value t

out: Same as "var".

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

sub Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int32, Int64, Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor v2 t

y

-> Tensor Value t

z

Returns x - y element-wise.

  • NOTE*: Sub supports broadcasting. More about broadcasting here

batchFFT3D Source

Arguments

:: Tensor v1 (Complex Float)

input

-> Tensor Value (Complex Float)

output

sparseReduceSumSparse Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 Int64

input_indices: 2-D. `N x R` matrix with the indices of non-empty values in a SparseTensor, possibly not in canonical ordering.

-> Tensor v2 t

input_values: 1-D. N non-empty values corresponding to input_indices.

-> Tensor v3 Int64

input_shape: 1-D. Shape of the input SparseTensor.

-> Tensor v4 Int32

reduction_axes: 1-D. Length-K vector containing the reduction axes.

-> (Tensor Value Int64, Tensor Value t, Tensor Value Int64)

(output_indices, output_values, output_shape)

  • output_indices
  • output_values
  • output_shape

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.

biasAdd Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

value: Any number of dimensions.

-> Tensor v2 t

bias: 1-D with size the last dimension of value.

-> Tensor Value t

output: Broadcasted sum of value and bias.

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.

mul Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor v2 t

y

-> Tensor Value t

z

Returns x * y element-wise.

  • NOTE*: Mul supports broadcasting. More about broadcasting here

div Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor v2 t

y

-> Tensor Value t

z

Returns x / y element-wise.

  • NOTE*: Div supports broadcasting. More about broadcasting here

loopCond Source

Arguments

:: Tensor v1 Bool

input: A boolean scalar, representing the branch predicate of the Switch op.

-> Tensor Value Bool

output: The same tensor as input.

Forwards the input to the output.

This operator represents the loop termination condition used by the "pivot" switches of a loop.

squaredDifference Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int32, Int64, Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor v2 t

y

-> Tensor Value t

z

Returns (x - y)(x - y) element-wise.

  • NOTE*: SquaredDifference supports broadcasting. More about broadcasting here

maximum Source

Arguments

:: (TensorType t, OneOf `[Int32, Int64, Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor v2 t

y

-> Tensor Value t

z

Returns the max of x and y (i.e. x > y ? x : y) element-wise.

  • NOTE*: Maximum supports broadcasting. More about broadcasting here

logUniformCandidateSampler Source

Arguments

:: Int64

num_sampled: Number of candidates to randomly sample per batch.

-> Int64

num_true: Number of true labels per context.

-> Int64

range_max: The sampler will sample integers from the interval [0, range_max).

-> Bool

unique: If unique is true, we sample with rejection, so that all sampled candidates in a batch are unique. This requires some approximation to estimate the post-rejection sampling probabilities.

-> Tensor v1 Int64

true_classes: A batch_size * num_true matrix, in which each row contains the IDs of the num_true target_classes in the corresponding original label.

-> (Tensor Value Int64, Tensor Value Float, Tensor Value Float)

(sampled_candidates, true_expected_count, sampled_expected_count)

  • sampled_candidates: A vector of length num_sampled, in which each element is the ID of a sampled candidate.
  • true_expected_count: A batch_size * num_true matrix, representing the number of times each candidate is expected to occur in a batch of sampled candidates. If unique=true, then this is a probability.
  • sampled_expected_count: A vector of length num_sampled, for each sampled candidate representing the number of times the candidate is expected to occur in a batch of sampled candidates. If unique=true, then this is a probability.

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.

less Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor v2 t

y

-> Tensor Value Bool

z

Returns the truth value of (x < y) element-wise.

  • NOTE*: Less supports broadcasting. More about broadcasting here

pow Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int32, Int64, Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor v2 t

y

-> Tensor Value t

z

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]] ```

igammac Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t) 
=> Tensor v1 t

a

-> Tensor v2 t

x

-> Tensor Value t

z

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.

igamma Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t) 
=> Tensor v1 t

a

-> Tensor v2 t

x

-> Tensor Value t

z

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.

zeta Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor v2 t

q

-> Tensor Value t

z

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} ```

imag Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float]` t, TensorType tout, OneOf `[Double, Float]` tout) 
=> Tensor v1 t

input

-> Tensor Value tout

output

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] ```

complex Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t, TensorType tout, OneOf `[Complex Double, Complex Float]` tout) 
=> Tensor v1 t

real

-> Tensor v2 t

imag

-> Tensor Value tout

out

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]] ```

notEqual Source

Returns the truth value of (x != y) element-wise.

  • NOTE*: NotEqual supports broadcasting. More about broadcasting here

complexAbs Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float]` t, TensorType tout, OneOf `[Double, Float]` tout) 
=> Tensor v1 t

x

-> Tensor Value tout

y

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] ```

logicalAnd Source

Arguments

:: Tensor v1 Bool

x

-> Tensor v2 Bool

y

-> Tensor Value Bool

z

Returns the truth value of x AND y element-wise.

  • NOTE*: LogicalAnd supports broadcasting. More about broadcasting here

batchFFT Source

Arguments

:: Tensor v1 (Complex Float)

input

-> Tensor Value (Complex Float)

output

select Source

Arguments

:: TensorType t 
=> Tensor v1 Bool

condition

-> Tensor v2 t

t: = A Tensor which may have the same shape as condition. If condition is rank 1, t may have higher rank, but its first dimension must match the size of condition.

-> Tensor v3 t

e: = A Tensor with the same type and shape as t.

-> Tensor Value t

output: = A Tensor with the same type and shape as t and e.

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]]

```

matMul Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int32, Word16, Double, Float]` t) 
=> Tensor v1 t

a

-> Tensor v2 t

b

-> Tensor Value t

product

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).

  • Note*: The default kernel implementation for MatMul on GPUs uses cublas.

digamma Source

Arguments

:: (TensorType t, OneOf `[Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor Value t

y

Computes Psi, the derivative of Lgamma (the log of the absolute value of

`Gamma(x)`), element-wise.

conv2DBackpropFilter Source

Arguments

:: (TensorType t, OneOf `[Word16, Double, Float]` t) 
=> Tensor v1 t

input: 4-D with shape `[batch, in_height, in_width, in_channels]`.

-> Tensor v2 Int32

filter_sizes: An integer vector representing the tensor shape of filter, where filter is a 4-D `[filter_height, filter_width, in_channels, out_channels]` tensor.

-> Tensor v3 t

out_backprop: 4-D with shape `[batch, out_height, out_width, out_channels]`. Gradients w.r.t. the output of the convolution.

-> Tensor Value t

output: 4-D with shape `[filter_height, filter_width, in_channels, out_channels]`. Gradient w.r.t. the filter input of the convolution.

Computes the gradients of convolution with respect to the filter.

min Source

Arguments

:: (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

input: The tensor to reduce.

-> Tensor v2 tidx

reduction_indices: The dimensions to reduce.

-> Tensor Value t

output: The reduced tensor.

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.

isFinite Source

Arguments

:: (TensorType t, OneOf `[Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor Value Bool

y

Returns which elements of x are finite.

argMax Source

Arguments

:: (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

input

-> Tensor v2 tidx

dimension: int32, 0 <= dimension < rank(input). Describes which dimension of the input Tensor to reduce across. For vectors, use dimension = 0.

-> Tensor Value Int64

output

Returns the index with the largest value across dimensions of a tensor.

segmentMean Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t, TensorType tindices, OneOf `[Int32, Int64]` tindices) 
=> Tensor v1 t

data

-> Tensor v2 tindices

segment_ids: A 1-D tensor whose rank is equal to the rank of `data`'s first dimension. Values should be sorted and can be repeated.

-> Tensor Value t

output: Has same shape as data, except for dimension 0 which has size k, the number of segments.

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

cumprod Source

Arguments

:: (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

x

-> Tensor v2 tidx

axis

-> Tensor Value t

out

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] ```

segmentMin Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t, TensorType tindices, OneOf `[Int32, Int64]` tindices) 
=> Tensor v1 t

data

-> Tensor v2 tindices

segment_ids: A 1-D tensor whose rank is equal to the rank of `data`'s first dimension. Values should be sorted and can be repeated.

-> Tensor Value t

output: Has same shape as data, except for dimension 0 which has size k, the number of segments.

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

unsortedSegmentSum Source

Arguments

:: (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

data

-> Tensor v2 tindices

segment_ids: A tensor whose shape is a prefix of `data.shape`.

-> Tensor v3 Int32

num_segments

-> Tensor Value t

output: Has same shape as data, except for the first `segment_ids.rank` dimensions, which are replaced with a single dimension which has size num_segments.

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

tFRecordReader Source

Arguments

:: Tensor Value ByteString

reader_handle: The handle to reference the Reader.

A Reader that outputs the records from a TensorFlow Records file.

sparseSegmentSum Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t, TensorType tidx, OneOf `[Int32, Int64]` tidx) 
=> Tensor v1 t

data

-> Tensor v2 tidx

indices: A 1-D tensor. Has same rank as segment_ids.

-> Tensor v3 Int32

segment_ids: A 1-D tensor. Values should be sorted and can be repeated.

-> Tensor Value t

output: Has same shape as data, except for dimension 0 which has size k, the number of segments.

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])) ```

sparseSegmentSqrtN Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t, TensorType tidx, OneOf `[Int32, Int64]` tidx) 
=> Tensor v1 t

data

-> Tensor v2 tidx

indices: A 1-D tensor. Has same rank as segment_ids.

-> Tensor v3 Int32

segment_ids: A 1-D tensor. Values should be sorted and can be repeated.

-> Tensor Value t

output: Has same shape as data, except for dimension 0 which has size k, the number of segments.

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.

copyHost Source

Arguments

:: TensorType t 
=> Tensor v1 t

input: Input tensor.

-> Tensor Value t

output: Output tensor, deep-copied from input.

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.

variable Source

Arguments

:: TensorType dtype 
=> Tensor Value dtype

ref: A reference to the variable tensor.

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.

sparseSegmentSqrtNGrad Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t, TensorType tidx, OneOf `[Int32, Int64]` tidx) 
=> Tensor v1 t

grad: gradient propagated to the SparseSegmentSqrtN op.

-> Tensor v2 tidx

indices: indices passed to the corresponding SparseSegmentSqrtN op.

-> Tensor v3 Int32

segment_ids: segment_ids passed to the corresponding SparseSegmentSqrtN op.

-> Tensor v4 Int32

output_dim0: dimension 0 of "data" passed to SparseSegmentSqrtN op.

-> Tensor Value t

output

Computes gradients for SparseSegmentSqrtN.

Returns tensor "output" with same shape as grad, except for dimension 0 whose value is output_dim0.

range Source

Arguments

:: (TensorType tidx, OneOf `[Int32, Int64]` tidx) 
=> Tensor v1 tidx

start: 0-D (scalar). First entry in the sequence.

-> Tensor v2 tidx

limit: 0-D (scalar). Upper limit of sequence, exclusive.

-> Tensor v3 tidx

delta: 0-D (scalar). Optional. Default is 1. Number that increments start.

-> Tensor Value tidx

output: 1-D.

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] ```

any Source

Arguments

:: (TensorType tidx, OneOf `[Int32, Int64]` tidx) 
=> Tensor v1 Bool

input: The tensor to reduce.

-> Tensor v2 tidx

reduction_indices: The dimensions to reduce.

-> Tensor Value Bool

output: The reduced tensor.

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.

linSpace Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t, TensorType tidx, OneOf `[Int32, Int64]` tidx) 
=> Tensor v1 t

start: First entry in the range.

-> Tensor v2 t

stop: Last entry in the range.

-> Tensor v3 tidx

num: Number of values to generate.

-> Tensor Value t

output: 1-D. The generated values.

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] ```

resizeArea Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

images: 4-D with shape `[batch, height, width, channels]`.

-> Tensor v2 Int32

size: = A 1-D int32 Tensor of 2 elements: `new_height, new_width`. The new size for the images.

-> Tensor Value Float

resized_images: 4-D with shape `[batch, new_height, new_width, channels]`.

Resize images to size using area interpolation.

Input images can be of different types but output images are always float.

real Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float]` t, TensorType tout, OneOf `[Double, Float]` tout) 
=> Tensor v1 t

input

-> Tensor Value tout

output

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] ```

iFFT Source

Arguments

:: Tensor v1 (Complex Float)

input: A complex64 tensor.

-> Tensor Value (Complex Float)

output: A complex64 tensor of the same shape as input. The inner-most dimension of input is replaced with its inverse 1D Fourier Transform.

Compute the inverse 1-dimensional discrete Fourier Transform over the inner-most

dimension of input.

iFFT3D Source

Arguments

:: Tensor v1 (Complex Float)

input: A complex64 tensor.

-> Tensor Value (Complex Float)

output: A complex64 tensor of the same shape as input. The inner-most 3 dimensions of input are replaced with their inverse 3D Fourier Transform.

Compute the inverse 3-dimensional discrete Fourier Transform over the inner-most

3 dimensions of input.

cross Source

Arguments

:: (TensorType t, OneOf `[Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

a: A tensor containing 3-element vectors.

-> Tensor v2 t

b: Another tensor, of same type and shape as a.

-> Tensor Value t

product: Pairwise cross product of the vectors in a and b.

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.

cumsum Source

Arguments

:: (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

x

-> Tensor v2 tidx

axis

-> Tensor Value t

out

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] ```

batchIFFT Source

Arguments

:: Tensor v1 (Complex Float)

input

-> Tensor Value (Complex Float)

output

erf Source

Arguments

:: (TensorType t, OneOf `[Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor Value t

y

Computes the Gauss error function of x element-wise.

barrierInsertMany Source

Arguments

:: TensorType t 
=> Int64

component_index: The component of the barrier elements that is being assigned.

-> Tensor v1 ByteString

handle: The handle to a barrier.

-> Tensor v2 ByteString

keys: A one-dimensional tensor of keys, with length n.

-> Tensor v3 t

values: An any-dimensional tensor of values, which are associated with the respective keys. The 0th dimension must have length n.

-> ControlNode 

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.

floor Source

Arguments

:: (TensorType t, OneOf `[Word16, Double, Float]` t) 
=> Tensor v1 t

x

-> Tensor Value t

y

Returns element-wise largest integer not greater than x.

batchFFT2D Source

Arguments

:: Tensor v1 (Complex Float)

input

-> Tensor Value (Complex Float)

output

sparseAddGrad Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 t

backprop_val_grad: 1-D with shape `[nnz(sum)]`. The gradient with respect to the non-empty values of the sum.

-> Tensor v2 Int64

a_indices: 2-D. The indices of the SparseTensor A, size `[nnz(A), ndims]`.

-> Tensor v3 Int64

b_indices: 2-D. The indices of the SparseTensor B, size `[nnz(B), ndims]`.

-> Tensor v4 Int64

sum_indices: 2-D. The indices of the sum SparseTensor, size `[nnz(sum), ndims]`.

-> (Tensor Value t, Tensor Value t)

(a_val_grad, b_val_grad)

  • a_val_grad: 1-D with shape `[nnz(A)]`. The gradient with respect to the non-empty values of A.
  • b_val_grad: 1-D with shape `[nnz(B)]`. The gradient with respect to the non-empty values of B.

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.

sparseAdd Source

Arguments

:: (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

a_indices: 2-D. The indices of the first SparseTensor, size `[nnz, ndims]` Matrix.

-> Tensor v2 t

a_values: 1-D. The values of the first SparseTensor, size `[nnz]` Vector.

-> Tensor v3 Int64

a_shape: 1-D. The shape of the first SparseTensor, size `[ndims]` Vector.

-> Tensor v4 Int64

b_indices: 2-D. The indices of the second SparseTensor, size `[nnz, ndims]` Matrix.

-> Tensor v5 t

b_values: 1-D. The values of the second SparseTensor, size `[nnz]` Vector.

-> Tensor v6 Int64

b_shape: 1-D. The shape of the second SparseTensor, size `[ndims]` Vector.

-> Tensor v7 treal

thresh: 0-D. The magnitude threshold that determines if an output value/index pair takes space.

-> (Tensor Value Int64, Tensor Value t, Tensor Value Int64)

(sum_indices, sum_values, sum_shape)

  • sum_indices
  • sum_values
  • sum_shape

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.

batchCholesky Source

Arguments

:: (TensorType t, OneOf `[Double, Float]` t) 
=> Tensor v1 t

input

-> Tensor Value t

output

dynamicPartition Source

Arguments

:: TensorType t 
=> Int64

num_partitions: The number of partitions to output.

-> Tensor v1 t

data

-> Tensor v2 Int32

partitions: Any shape. Indices in the range `[0, num_partitions)`.

-> [Tensor Value t]

outputs

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

serializeSparse Source

Arguments

:: TensorType t 
=> Tensor v1 Int64

sparse_indices: 2-D. The indices of the SparseTensor.

-> Tensor v2 t

sparse_values: 1-D. The values of the SparseTensor.

-> Tensor v3 Int64

sparse_shape: 1-D. The shape of the SparseTensor.

-> Tensor Value ByteString

serialized_sparse

Serialize a SparseTensor into a string 3-vector (1-D Tensor) object.

sparseConcat Source

Arguments

:: TensorType t 
=> Int64

concat_dim: Dimension to concatenate along. Must be in range [-rank, rank), where rank is the number of dimensions in each input SparseTensor.

-> [Tensor v1 Int64]

indices: 2-D. Indices of each input SparseTensor.

-> [Tensor v2 t]

values: 1-D. Non-empty values of each SparseTensor.

-> [Tensor v3 Int64]

shapes: 1-D. Shapes of each SparseTensor.

-> (Tensor Value Int64, Tensor Value t, Tensor Value Int64)

(output_indices, output_values, output_shape)

  • output_indices: 2-D. Indices of the concatenated SparseTensor.
  • output_values: 1-D. Non-empty values of the concatenated SparseTensor.
  • output_shape: 1-D. Shape of the concatenated SparseTensor.

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

a
concat [ d e ] = [ a d e ]
b c
[ ] [b c ]

segmentProd Source

Arguments

:: (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

data

-> Tensor v2 tindices

segment_ids: A 1-D tensor whose rank is equal to the rank of `data`'s first dimension. Values should be sorted and can be repeated.

-> Tensor Value t

output: Has same shape as data, except for dimension 0 which has size k, the number of segments.

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

sparseReshape Source

Arguments

:: Tensor v1 Int64

input_indices: 2-D. `N x R_in` matrix with the indices of non-empty values in a SparseTensor.

-> Tensor v2 Int64

input_shape: 1-D. R_in vector with the input SparseTensor's dense shape.

-> Tensor v3 Int64

new_shape: 1-D. R_out vector with the requested new dense shape.

-> (Tensor Value Int64, Tensor Value Int64)

(output_indices, output_shape)

  • output_indices: 2-D. `N x R_out` matrix with the updated indices of non-empty values in the output SparseTensor.
  • output_shape: 1-D. R_out vector with the full dense shape of the output SparseTensor. This is the same as new_shape but with any -1 dimensions filled in.

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.

sparseDenseCwiseMul Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 Int64

sp_indices: 2-D. `N x R` matrix with the indices of non-empty values in a SparseTensor, possibly not in canonical ordering.

-> Tensor v2 t

sp_values: 1-D. N non-empty values corresponding to sp_indices.

-> Tensor v3 Int64

sp_shape: 1-D. Shape of the input SparseTensor.

-> Tensor v4 t

dense: R-D. The dense Tensor operand.

-> Tensor Value t

output: 1-D. The N values that are operated on.

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).

  • Limitation*: this Op only broadcasts the dense side to the sparse side, but not the other direction.

sparseDenseCwiseDiv Source

Arguments

:: (TensorType t, OneOf `[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16, Word8, Double, Float]` t) 
=> Tensor v1 Int64

sp_indices: 2-D. `N x R` matrix with the indices of non-empty values in a SparseTensor, possibly not in canonical ordering.

-> Tensor v2 t

sp_values: 1-D. N non-empty values corresponding to sp_indices.

-> Tensor v3 Int64

sp_shape: 1-D. Shape of the input SparseTensor.

-> Tensor v4 t

dense: R-D. The dense Tensor operand.

-> Tensor Value t

output: 1-D. The N values that are operated on.

Component-wise divides a SparseTensor by a dense Tensor.

  • Limitation*: this Op only broadcasts the dense side to the sparse side, but not the other direction.