Operations

Operations

See the official TensorFlow documentation for a complete description of these operations.

Basic operations

placeholder
constant
concat
stack
split
expand_dims
argmin
argmax
add_n
one_hot
random_uniform
random_normal

Variables

Variable
global_variables_initializer
variable_scope
get_variable
ConstantInitializer
assign
assign_add
assign_sub
scatter_update

Reductions

reduce_sum
reduce_prod
reduce_min
reduce_max
reduce_all
reduce_any
reduce_mean

Comparisons

equal
not_equal
less
less_equal
greater
greater_equal
select
where

Images

image.decode_jpeg
image.encode_jpeg
image.decode_png
image.encode_png
image.resize_images
image.central_crop

Neural networks

Convolutions

TensorFlow.Ops.conv2dFunction.
 conv2d(input, filter; use_cudnn_on_gpu=true, data_format=NHWC)

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

source
 max_pool(input; data_format=NHWC)

Performs max pooling on the input.

source

Embeddings

embedding_lookup(params, ids; partition_strategy="mod", name="", validate_indices=true)

Looks up values of ids in params. Currently only supports one Tensor in params.

Args:

  • params: A list of Tensors of the same type and which can be concatenated along their first dimension.

  • ids: A Tensor of Int32 or Int64 ids to be looked up in params.

  • partition_strategy: If "mod" (default), assign each id to partition p = id % len(params). If "div", assign each id contiguously.

  • name: An optional name for the operation.

  • validate_indices: If true (default), make sure the indices are valid.

source

Recurrent neural nets

nn.rnn
nn.dynamic_rnn
nn.zero_state
nn.output_size
nn.zero_state

Nonlinearities

nn.relu
nn.relu6
nn.elu
nn.softplus
nn.softsign
nn.softmax
nn.sigmoid
nn.tanh

Losses

TensorFlow.nn.l2_lossFunction.

l2_loss(t)

Computes half the L2-norm of a Tensor t, without taking the square root.

source

Regularizations

TensorFlow.nn.dropoutFunction.

dropout(x, keep_prob; noise_shape=nothing, seed=0)

Keeps each element of x with keep_prob, scaled by 1/keep_prob, otherwise outputs 0. This computes dropout.

Args:

  • x: A Tensor.

  • keep_prob: Probability that each element is kept.

  • noise_shape: Shape for randomly generated keep/drop flags.

  • seed: Integer used to seed the RNG. Defaults to 0.

source

Evaluations

TensorFlow.nn.top_kFunction.

top_k(input, k=1; sorted=true)

Finds values and indices of the top k largest entries of input in its last dimension.

Args:

  • input: One or more dimensional Tensor with last dimension at least size k.

  • k: Number of largest elements of input to look for. Defaults to 1.

  • sorted: If true (default), the returned values will be sorted in descending order.

source

in_top_k(predictions, targets, k)

Determines whether the targets are in the top k predictions. Outputs a batch_size (first dimension of predictions) array of boolean values.

Args:

  • predictions: Two dimensional Tensor.

  • targets: A Tensor.

  • k: Number of elements to look at for comparison.

source

Logic

 logical_and(x, y)

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

NOTE: LogicalAnd supports broadcasting. More about broadcasting here

source
 logical_not(x)

Returns the truth value of NOT x element-wise.

source
 logical_or(x, y)

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

NOTE: LogicalOr supports broadcasting. More about broadcasting here

source
logical_xor(x, y; name="LogicalXor")

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

NOTE: LogicalXor supports broadcasting. More about broadcasting here

Args:

  • x: A Tensor of type bool.

  • y: A Tensor of type bool.

  • name: A name for the operation (optional).

Returns: A Tensor of type bool.

source

Control flow

identity
TensorFlow.make_tuple
TensorFlow.group
TensorFlow.no_op
cond