tf.compat.v1.nn.fused_batch_norm Batch normalization.
tf.compat.v1.nn.fused_batch_norm(
    x, scale, offset, mean=None, variance=None, epsilon=0.001,
    data_format='NHWC', is_training=True, name=None,
    exponential_avg_factor=1.0
)
 See Source: Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift; S. Ioffe, C. Szegedy.

 Args
  x   Input Tensor of 4 or 5 dimensions.
  scale   A Tensor of 1 dimension for scaling.
  offset   A Tensor of 1 dimension for bias.
  mean   A Tensor of 1 dimension for population mean. The shape and meaning of this argument depends on the value of is_training and exponential_avg_factor as follows: is_trainingFalse (inference): Mean must be a Tensor of the same shape as scale containing the estimated population mean computed during training. is_trainingTrue and exponential_avg_factor == 1.0: Mean must be None. is_trainingTrue and exponential_avg_factor != 1.0: Mean must be a Tensor of the same shape as scale containing the exponential running mean.

  variance   A Tensor of 1 dimension for population variance. The shape and meaning of this argument depends on the value of is_training and exponential_avg_factor as follows: is_trainingFalse (inference): Variance must be a Tensor of the same shape as scale containing the estimated population variance computed during training. is_training==True and exponential_avg_factor == 1.0: Variance must be None. is_training==True and exponential_avg_factor != 1.0: Variance must be a Tensor of the same shape as scale containing the exponential running variance.
  epsilon   A small float number added to the variance of x.
  data_format   The data format for x. Support "NHWC" (default) or "NCHW" for 4D tenors and "NDHWC" or "NCDHW" for 5D tensors.
  is_training   A bool value to specify if the operation is used for training or inference.
  name   A name for this operation (optional).
  exponential_avg_factor   A float number (usually between 0 and 1) used for controlling the decay of the running population average of mean and variance. If set to 1.0, the current batch average is returned.

 Returns
  y   A 4D or 5D Tensor for the normalized, scaled, offsetted x.
  running_mean   A 1D Tensor for the exponential running mean of x. The output value is (1 - exponential_avg_factor) * mean + exponential_avg_factor * batch_mean), where batch_mean is the mean of the current batch in x.
  running_var   A 1D Tensor for the exponential running variance The output value is (1 - exponential_avg_factor) * variance + exponential_avg_factor * batch_variance), where batch_variance is the variance of the current batch in x.    References: Batch Normalization - Accelerating Deep Network Training by Reducing Internal Covariate Shift: Ioffe et al., 2015 (pdf)


tf.compat.v1.nn.max_pool Performs the max pooling on the input.
tf.compat.v1.nn.max_pool(
    value, ksize, strides, padding, data_format='NHWC', name=None,
    input=None
)

 Args
  value   A 4-D Tensor of the format specified by data_format.
  ksize   An int or list of ints that has length 1, 2 or 4. The size of the window for each dimension of the input tensor.
  strides   An int or list of ints that has length 1, 2 or 4. The stride of the sliding window for each dimension of the input tensor.
  padding   Either the string"SAME"or"VALID"indicating the type of padding algorithm to use, or a list indicating the explicit paddings at the start and end of each dimension. When explicit padding is used and data_format is"NHWC", this should be in the form[[0, 0], [pad_top, pad_bottom], [pad_left, pad_right], [0, 0]]. When explicit padding used and data_format is"NCHW", this should be in the form[[0, 0], [0, 0], [pad_top, pad_bottom], [pad_left, pad_right]]. When using explicit padding, the size of the paddings cannot be greater than the sliding window size.

 data_format	  A string. 'NHWC', 'NCHW' and 'NCHW_VECT_C' are supported.

 name	  Optional name for the operation.

 input`   Alias for value.

 Returns   A Tensor of format specified by data_format. The max pooled output tensor.


tf.compat.v1.nn.max_pool_with_argmax Performs max pooling on the input and outputs both max values and indices.
tf.compat.v1.nn.max_pool_with_argmax(
    input, ksize, strides, padding, data_format='NHWC', Targmax=None,
    name=None, output_dtype=None, include_batch_in_index=False
)
 The indices in argmax are flattened, so that a maximum value at position [b, y, x, c] becomes flattened index: (y * width + x) * channels + c if include_batch_in_index is False; ((b * height + y) * width + x) * channels + c if include_batch_in_index is True. The indices returned are always in [0, height) x [0, width) before flattening, even if padding is involved and the mathematically correct answer is outside (either negative or too large). This is a bug, but fixing it is difficult to do in a safe backwards compatible way, especially due to flattening.

 Args
  input   A Tensor. Must be one of the following types: float32, float64, int32, uint8, int16, int8, int64, bfloat16, uint16, half, uint32, uint64. 4-D with shape [batch, height, width, channels]. Input to pool over.
  ksize   A list of ints that has length >= 4. The size of the window for each dimension of the input tensor.
  strides   A list of ints that has length >= 4. The stride of the sliding window for each dimension of the input tensor.
  padding   A string from: "SAME", "VALID". The type of padding algorithm to use.
  Targmax   An optional tf.DType from: tf.int32, tf.int64. Defaults to tf.int64.
  include_batch_in_index   An optional bool. Defaults to False. Whether to include batch dimension in flattened index of argmax.
  name   A name for the operation (optional).

 Returns   A tuple of Tensor objects (output, argmax).     output   A Tensor. Has the same type as input.
  argmax   A Tensor of type Targmax.


tf.compat.v1.nn.moments Calculate the mean and variance of x.
tf.compat.v1.nn.moments(
    x, axes, shift=None, name=None, keep_dims=None, keepdims=None
)
 The mean and variance are calculated by aggregating the contents of x across axes. If x is 1-D and axes = [0] this is just the mean and variance of a vector.
Note: shift is currently not used; the true mean is computed and used.
 When using these moments for batch normalization (see tf.nn.batch_normalization):  for so-called "global normalization", used with convolutional filters with shape [batch, height, width, depth], pass axes=[0, 1, 2]. for simple batch normalization pass axes=[0] (batch only).

 Args
  x   A Tensor.
  axes   Array of ints. Axes along which to compute mean and variance.
  shift   Not used in the current implementation
  name   Name used to scope the operations that compute the moments.
  keep_dims   produce moments with the same dimensionality as the input.
  keepdims   Alias to keep_dims.

 Returns   Two Tensor objects: mean and variance.


tf.compat.v1.nn.nce_loss Computes and returns the noise-contrastive estimation training loss.
tf.compat.v1.nn.nce_loss(
    weights, biases, labels, inputs, num_sampled, num_classes, num_true=1,
    sampled_values=None, remove_accidental_hits=False,
    partition_strategy='mod', name='nce_loss'
)
 A common use case is to use this method for training, and calculate the full sigmoid loss for evaluation or inference. In this case, you must set partition_strategy="div" for the two losses to be consistent, as in the following example: if mode == "train":
  loss = tf.nn.nce_loss(
      weights=weights,
      biases=biases,
      labels=labels,
      inputs=inputs,
      ...,
      partition_strategy="div")
elif mode == "eval":
  logits = tf.matmul(inputs, tf.transpose(weights))
  logits = tf.nn.bias_add(logits, biases)
  labels_one_hot = tf.one_hot(labels, n_classes)
  loss = tf.nn.sigmoid_cross_entropy_with_logits(
      labels=labels_one_hot,
      logits=logits)
  loss = tf.reduce_sum(loss, axis=1)

Note: By default this uses a log-uniform (Zipfian) distribution for sampling, so your labels must be sorted in order of decreasing frequency to achieve good results. For more details, see tf.random.log_uniform_candidate_sampler.

Note: In the case where num_true > 1, we assign to each target class the target probability 1 / num_true so that the target probabilities sum to 1 per-example.

Note: It would be useful to allow a variable number of target classes per example. We hope to provide this functionality in a future release. For now, if you have a variable number of target classes, you can pad them out to a constant number by either repeating them or by padding with an otherwise unused class.

 Args
  weights   A Tensor of shape [num_classes, dim], or a list of Tensor objects whose concatenation along dimension 0 has shape [num_classes, dim]. The (possibly-partitioned) class embeddings.
  biases   A Tensor of shape [num_classes]. The class biases.
  labels   A Tensor of type int64 and shape [batch_size, num_true]. The target classes.
  inputs   A Tensor of shape [batch_size, dim]. The forward activations of the input network.
  num_sampled   An int. The number of negative classes to randomly sample per batch. This single sample of negative classes is evaluated for each element in the batch.
  num_classes   An int. The number of possible classes.
  num_true   An int. The number of target classes per training example.
  sampled_values   a tuple of (sampled_candidates, true_expected_count, sampled_expected_count) returned by a *_candidate_sampler function. (if None, we default to log_uniform_candidate_sampler)
  remove_accidental_hits   A bool. Whether to remove "accidental hits" where a sampled class equals one of the target classes. If set to True, this is a "Sampled Logistic" loss instead of NCE, and we are learning to generate log-odds instead of log probabilities. See our Candidate Sampling Algorithms Reference (pdf). Default is False.
  partition_strategy   A string specifying the partitioning strategy, relevant if len(weights) > 1. Currently "div" and "mod" are supported. Default is "mod". See tf.nn.embedding_lookup for more details.
  name   A name for the operation (optional).

 Returns   A batch_size 1-D tensor of per-example NCE losses.
 References: Noise-contrastive estimation - A new estimation principle for unnormalized statistical models: Gutmann et al., 2010 (pdf)


tf.compat.v1.nn.pool Performs an N-D pooling operation.
tf.compat.v1.nn.pool(
    input, window_shape, pooling_type, padding, dilation_rate=None, strides=None,
    name=None, data_format=None, dilations=None
)
 In the case that data_format does not start with "NC", computes for 0 <= b < batch_size, 0 <= x[i] < output_spatial_shape[i], 0 <= c < num_channels: output[b, x[0], ..., x[N-1], c] =
  REDUCE_{z[0], ..., z[N-1]}
    input[b,
          x[0] * strides[0] - pad_before[0] + dilation_rate[0]*z[0],
          ...
          x[N-1]*strides[N-1] - pad_before[N-1] + dilation_rate[N-1]*z[N-1],
          c],
 where the reduction function REDUCE depends on the value of pooling_type, and pad_before is defined based on the value of padding as described in the "returns" section of tf.nn.convolution for details. The reduction never includes out-of-bounds positions. In the case that data_format starts with "NC", the input and output are simply transposed as follows: pool(input, data_format, **kwargs) =
  tf.transpose(pool(tf.transpose(input, [0] + range(2,N+2) + [1]),
                    **kwargs),
               [0, N+1] + range(1, N+1))

 Args
  input   Tensor of rank N+2, of shape [batch_size] + input_spatial_shape + [num_channels] if data_format does not start with "NC" (default), or [batch_size, num_channels] + input_spatial_shape if data_format starts with "NC". Pooling happens over the spatial dimensions only.
  window_shape   Sequence of N ints >= 1.
  pooling_type   Specifies pooling operation, must be "AVG" or "MAX".
  padding   The padding algorithm, must be "SAME" or "VALID". See the "returns" section of tf.nn.convolution for details.
  dilation_rate   Optional. Dilation rate. List of N ints >= 1. Defaults to [1]N. If any value of dilation_rate is > 1, then all values of strides must be 1.

  strides   Optional. Sequence of N ints >= 1. Defaults to [1]N. If any value of strides is > 1, then all values of dilation_rate must be 1.
  name   Optional. Name of the op.
  data_format   A string or None. Specifies whether the channel dimension of the input and output is the last dimension (default, or if data_format does not start with "NC"), or the second dimension (if data_format starts with "NC"). For N=1, the valid values are "NWC" (default) and "NCW". For N=2, the valid values are "NHWC" (default) and "NCHW". For N=3, the valid values are "NDHWC" (default) and "NCDHW".
  dilations   Alias for dilation_rate

 Returns   Tensor of rank N+2, of shape [batch_size] + output_spatial_shape + [num_channels] if data_format is None or does not start with "NC", or [batch_size, num_channels] + output_spatial_shape if data_format starts with "NC", where output_spatial_shape depends on the value of padding: If padding = "SAME": output_spatial_shape[i] = ceil(input_spatial_shape[i] / strides[i]) If padding = "VALID": output_spatial_shape[i] = ceil((input_spatial_shape[i] - (window_shape[i] - 1) * dilation_rate[i]) / strides[i]).

 Raises
  ValueError   if arguments are invalid.


tf.compat.v1.nn.quantized_avg_pool Produces the average pool of the input tensor for quantized types.
tf.compat.v1.nn.quantized_avg_pool(
    input, min_input, max_input, ksize, strides, padding, name=None
)

 Args
  input   A Tensor. Must be one of the following types: qint8, quint8, qint32, qint16, quint16. 4-D with shape [batch, height, width, channels].
  min_input   A Tensor of type float32. The float value that the lowest quantized input value represents.
  max_input   A Tensor of type float32. The float value that the highest quantized input value represents.
  ksize   A list of ints. The size of the window for each dimension of the input tensor. The length must be 4 to match the number of dimensions of the input.
  strides   A list of ints. The stride of the sliding window for each dimension of the input tensor. The length must be 4 to match the number of dimensions of the input.
  padding   A string from: "SAME", "VALID". The type of padding algorithm to use.
  name   A name for the operation (optional).

 Returns   A tuple of Tensor objects (output, min_output, max_output).     output   A Tensor. Has the same type as input.
  min_output   A Tensor of type float32.
  max_output   A Tensor of type float32.


tf.compat.v1.nn.quantized_conv2d Computes a 2D convolution given quantized 4D input and filter tensors.
tf.compat.v1.nn.quantized_conv2d(
    input, filter, min_input, max_input, min_filter, max_filter, strides, padding,
    out_type=tf.dtypes.qint32, dilations=[1, 1, 1, 1], name=None
)
 The inputs are quantized tensors where the lowest value represents the real number of the associated minimum, and the highest represents the maximum. This means that you can only interpret the quantized output in the same way, by taking the returned minimum and maximum values into account.

 Args
  input   A Tensor. Must be one of the following types: qint8, quint8, qint32, qint16, quint16.
  filter   A Tensor. Must be one of the following types: qint8, quint8, qint32, qint16, quint16. filter's input_depth dimension must match input's depth dimensions.
  min_input   A Tensor of type float32. The float value that the lowest quantized input value represents.
  max_input   A Tensor of type float32. The float value that the highest quantized input value represents.
  min_filter   A Tensor of type float32. The float value that the lowest quantized filter value represents.
  max_filter   A Tensor of type float32. The float value that the highest quantized filter value represents.
  strides   A list of ints. The stride of the sliding window for each dimension of the input tensor.
  padding   A string from: "SAME", "VALID". The type of padding algorithm to use.
  out_type   An optional tf.DType from: tf.qint8, tf.quint8, tf.qint32, tf.qint16, tf.quint16. Defaults to tf.qint32.
  dilations   An optional list of ints. Defaults to [1, 1, 1, 1]. 1-D tensor of length 4. The dilation factor for each dimension of input. If set to k > 1, there will be k-1 skipped cells between each filter element on that dimension. The dimension order is determined by the value of data_format, see above for details. Dilations in the batch and depth dimensions must be 1.
  name   A name for the operation (optional).

 Returns   A tuple of Tensor objects (output, min_output, max_output).     output   A Tensor of type out_type.
  min_output   A Tensor of type float32.
  max_output   A Tensor of type float32.


tf.compat.v1.nn.quantized_max_pool Produces the max pool of the input tensor for quantized types.
tf.compat.v1.nn.quantized_max_pool(
    input, min_input, max_input, ksize, strides, padding, name=None
)

 Args
  input   A Tensor. Must be one of the following types: qint8, quint8, qint32, qint16, quint16. The 4D (batch x rows x cols x depth) Tensor to MaxReduce over.
  min_input   A Tensor of type float32. The float value that the lowest quantized input value represents.
  max_input   A Tensor of type float32. The float value that the highest quantized input value represents.
  ksize   A list of ints. The size of the window for each dimension of the input tensor. The length must be 4 to match the number of dimensions of the input.
  strides   A list of ints. The stride of the sliding window for each dimension of the input tensor. The length must be 4 to match the number of dimensions of the input.
  padding   A string from: "SAME", "VALID". The type of padding algorithm to use.
  name   A name for the operation (optional).

 Returns   A tuple of Tensor objects (output, min_output, max_output).     output   A Tensor. Has the same type as input.
  min_output   A Tensor of type float32.
  max_output   A Tensor of type float32.


tf.compat.v1.nn.quantized_relu_x Computes Quantized Rectified Linear X: min(max(features, 0), max_value)
tf.compat.v1.nn.quantized_relu_x(
    features, max_value, min_features, max_features, out_type=tf.dtypes.quint8,
    name=None
)

 Args
  features   A Tensor. Must be one of the following types: qint8, quint8, qint32, qint16, quint16.
  max_value   A Tensor of type float32.
  min_features   A Tensor of type float32. The float value that the lowest quantized value represents.
  max_features   A Tensor of type float32. The float value that the highest quantized value represents.
  out_type   An optional tf.DType from: tf.qint8, tf.quint8, tf.qint32, tf.qint16, tf.quint16. Defaults to tf.quint8.
  name   A name for the operation (optional).

 Returns   A tuple of Tensor objects (activations, min_activations, max_activations).     activations   A Tensor of type out_type.
  min_activations   A Tensor of type float32.
  max_activations   A Tensor of type float32.


tf.compat.v1.nn.raw_rnn Creates an RNN specified by RNNCell cell and loop function loop_fn.
tf.compat.v1.nn.raw_rnn(
    cell, loop_fn, parallel_iterations=None, swap_memory=False, scope=None
)

Note: This method is still in testing, and the API may change.**
 This function is a more primitive version of dynamic_rnn that provides more direct access to the inputs each iteration. It also provides more control over when to start and finish reading the sequence, and what to emit for the output. For example, it can be used to implement the dynamic decoder of a seq2seq model. Instead of working with Tensor objects, most operations work with TensorArray objects directly. The operation of raw_rnn, in pseudo-code, is basically the following: time = tf.constant(0, dtype=tf.int32)
(finished, next_input, initial_state, emit_structure, loop_state) = loop_fn(
    time=time, cell_output=None, cell_state=None, loop_state=None)
emit_ta = TensorArray(dynamic_size=True, dtype=initial_state.dtype)
state = initial_state
while not all(finished):
  (output, cell_state) = cell(next_input, state)
  (next_finished, next_input, next_state, emit, loop_state) = loop_fn(
      time=time + 1, cell_output=output, cell_state=cell_state,
      loop_state=loop_state)
  # Emit zeros and copy forward state for minibatch entries that are finished.
  state = tf.where(finished, state, next_state)
  emit = tf.where(finished, tf.zeros_like(emit_structure), emit)
  emit_ta = emit_ta.write(time, emit)
  # If any new minibatch entries are marked as finished, mark these.
  finished = tf.logical_or(finished, next_finished)
  time += 1
return (emit_ta, state, loop_state)
 with the additional properties that output and state may be (possibly nested) tuples, as determined by cell.output_size and cell.state_size, and as a result the final state and emit_ta may themselves be tuples. A simple implementation of dynamic_rnn via raw_rnn looks like this: inputs = tf.compat.v1.placeholder(shape=(max_time, batch_size, input_depth),
                        dtype=tf.float32)
sequence_length = tf.compat.v1.placeholder(shape=(batch_size,),
dtype=tf.int32)
inputs_ta = tf.TensorArray(dtype=tf.float32, size=max_time)
inputs_ta = inputs_ta.unstack(inputs)

cell = tf.compat.v1.nn.rnn_cell.LSTMCell(num_units)

def loop_fn(time, cell_output, cell_state, loop_state):
  emit_output = cell_output  # == None for time == 0
  if cell_output is None:  # time == 0
    next_cell_state = cell.zero_state(batch_size, tf.float32)
  else:
    next_cell_state = cell_state
  elements_finished = (time >= sequence_length)
  finished = tf.reduce_all(elements_finished)
  next_input = tf.cond(
      finished,
      lambda: tf.zeros([batch_size, input_depth], dtype=tf.float32),
      lambda: inputs_ta.read(time))
  next_loop_state = None
  return (elements_finished, next_input, next_cell_state,
          emit_output, next_loop_state)

outputs_ta, final_state, _ = raw_rnn(cell, loop_fn)
outputs = outputs_ta.stack()

 Args
  cell   An instance of RNNCell.
  loop_fn   A callable that takes inputs (time, cell_output, cell_state, loop_state) and returns the tuple (finished, next_input, next_cell_state, emit_output, next_loop_state). Here time is an int32 scalar Tensor, cell_output is a Tensor or (possibly nested) tuple of tensors as determined by cell.output_size, and cell_state is a Tensor or (possibly nested) tuple of tensors, as determined by the loop_fn on its first call (and should match cell.state_size). The outputs are: finished, a boolean Tensor of shape [batch_size], next_input: the next input to feed to cell, next_cell_state: the next state to feed to cell, and emit_output: the output to store for this iteration. Note that emit_output should be a Tensor or (possibly nested) tuple of tensors which is aggregated in the emit_ta inside the while_loop. For the first call to loop_fn, the emit_output corresponds to the emit_structure which is then used to determine the size of the zero_tensor for the emit_ta (defaults to cell.output_size). For the subsequent calls to the loop_fn, the emit_output corresponds to the actual output tensor that is to be aggregated in the emit_ta. The parameter cell_state and output next_cell_state may be either a single or (possibly nested) tuple of tensors. The parameter loop_state and output next_loop_state may be either a single or (possibly nested) tuple of Tensor and TensorArray objects. This last parameter may be ignored by loop_fn and the return value may be None. If it is not None, then the loop_state will be propagated through the RNN loop, for use purely by loop_fn to keep track of its own state. The next_loop_state parameter returned may be None. The first call to loop_fn will be time = 0, cell_output = None, cell_state = None, and loop_state = None. For this call: The next_cell_state value should be the value with which to initialize the cell's state. It may be a final state from a previous RNN or it may be the output of cell.zero_state(). It should be a (possibly nested) tuple structure of tensors. If cell.state_size is an integer, this must be a Tensor of appropriate type and shape [batch_size, cell.state_size]. If cell.state_size is a TensorShape, this must be a Tensor of appropriate type and shape [batch_size] + cell.state_size. If cell.state_size is a (possibly nested) tuple of ints or TensorShape, this will be a tuple having the corresponding shapes. The emit_output value may be either None or a (possibly nested) tuple structure of tensors, e.g., (tf.zeros(shape_0, dtype=dtype_0), tf.zeros(shape_1, dtype=dtype_1)). If this first emit_output return value is None, then the emit_ta result of raw_rnn will have the same structure and dtypes as cell.output_size. Otherwise emit_ta will have the same structure, shapes (prepended with a batch_size dimension), and dtypes as emit_output. The actual values returned for emit_output at this initializing call are ignored. Note, this emit structure must be consistent across all time steps.
  parallel_iterations   (Default: 32). The number of iterations to run in parallel. Those operations which do not have any temporal dependency and can be run in parallel, will be. This parameter trades off time for space. Values >> 1 use more memory but take less time, while smaller values use less memory but computations take longer.
  swap_memory   Transparently swap the tensors produced in forward inference but needed for back prop from GPU to CPU. This allows training RNNs which would typically not fit on a single GPU, with very minimal (or no) performance penalty.
  scope   VariableScope for the created subgraph; defaults to "rnn".

 Returns   A tuple (emit_ta, final_state, final_loop_state) where: emit_ta: The RNN output TensorArray. If loop_fn returns a (possibly nested) set of Tensors for emit_output during initialization, (inputs time = 0, cell_output = None, and loop_state = None), then emit_ta will have the same structure, dtypes, and shapes as emit_output instead. If loop_fn returns emit_output = None during this call, the structure of cell.output_size is used: If cell.output_size is a (possibly nested) tuple of integers or TensorShape objects, then emit_ta will be a tuple having the same structure as cell.output_size, containing TensorArrays whose elements' shapes correspond to the shape data in cell.output_size. final_state: The final cell state. If cell.state_size is an int, this will be shaped [batch_size, cell.state_size]. If it is a TensorShape, this will be shaped [batch_size] + cell.state_size. If it is a (possibly nested) tuple of ints or TensorShape, this will be a tuple having the corresponding shapes. final_loop_state: The final loop state as returned by loop_fn.

 Raises
  TypeError   If cell is not an instance of RNNCell, or loop_fn is not a callable.


tf.compat.v1.nn.relu_layer Computes Relu(x * weight + biases).
tf.compat.v1.nn.relu_layer(
    x, weights, biases, name=None
)

 Args
  x   a 2D tensor. Dimensions typically: batch, in_units
  weights   a 2D tensor. Dimensions typically: in_units, out_units
  biases   a 1D tensor. Dimensions: out_units
  name   A name for the operation (optional). If not specified "nn_relu_layer" is used.

 Returns   A 2-D Tensor computing relu(matmul(x, weights) + biases). Dimensions typically: batch, out_units.


Module: tf.compat.v1.nn.rnn_cell Module for constructing RNN Cells. Classes class BasicLSTMCell: DEPRECATED: Please use tf.compat.v1.nn.rnn_cell.LSTMCell instead. class BasicRNNCell: The most basic RNN cell. class DeviceWrapper: Operator that ensures an RNNCell runs on a particular device. class DropoutWrapper: Operator adding dropout to inputs and outputs of the given cell. class GRUCell: Gated Recurrent Unit cell. class LSTMCell: Long short-term memory unit (LSTM) recurrent network cell. class LSTMStateTuple: Tuple used by LSTM Cells for state_size, zero_state, and output state. class MultiRNNCell: RNN cell composed sequentially of multiple simple cells. class RNNCell: Abstract object representing an RNN cell. class ResidualWrapper: RNNCell wrapper that ensures cell inputs are added to the outputs.


tf.compat.v1.nn.rnn_cell.BasicLSTMCell DEPRECATED: Please use tf.compat.v1.nn.rnn_cell.LSTMCell instead. Inherits From: RNNCell, Layer, Layer, Module
tf.compat.v1.nn.rnn_cell.BasicLSTMCell(
    num_units, forget_bias=1.0, state_is_tuple=True, activation=None, reuse=None,
    name=None, dtype=None, **kwargs
)
 Basic LSTM recurrent network cell. The implementation is based on We add forget_bias (default: 1) to the biases of the forget gate in order to reduce the scale of forgetting in the beginning of the training. It does not allow cell clipping, a projection layer, and does not use peep-hole connections: it is the basic baseline. For advanced models, please use the full tf.compat.v1.nn.rnn_cell.LSTMCell that follows. Note that this cell is not optimized for performance. Please use tf.contrib.cudnn_rnn.CudnnLSTM for better performance on GPU, or tf.contrib.rnn.LSTMBlockCell and tf.contrib.rnn.LSTMBlockFusedCell for better performance on CPU.

 Args
  num_units   int, The number of units in the LSTM cell.
  forget_bias   float, The bias added to forget gates (see above). Must set to 0.0 manually when restoring from CudnnLSTM-trained checkpoints.
  state_is_tuple   If True, accepted and returned states are 2-tuples of the c_state and m_state. If False, they are concatenated along the column axis. The latter behavior will soon be deprecated.
  activation   Activation function of the inner states. Default: tanh. It could also be string that is within Keras activation function names.
  reuse   (optional) Python boolean describing whether to reuse variables in an existing scope. If not True, and the existing scope already has the given variables, an error is raised.
  name   String, the name of the layer. Layers with the same name will share weights, but to avoid mistakes we require reuse=True in such cases.
  dtype   Default dtype of the layer (default of None means use the type of the first input). Required when build is called before call.
  **kwargs   Dict, keyword named properties for common layer attributes, like trainable etc when constructing the cell from configs of get_config(). When restoring from CudnnLSTM-trained checkpoints, must use CudnnCompatibleLSTMCell instead.

 Attributes
  graph

  output_size   Integer or TensorShape: size of outputs produced by this cell.
  scope_name

  state_size   size(s) of state(s) used by this cell. It can be represented by an Integer, a TensorShape or a tuple of Integers or TensorShapes.
   Methods get_initial_state View source
get_initial_state(
    inputs=None, batch_size=None, dtype=None
)
 zero_state View source
zero_state(
    batch_size, dtype
)
 Return zero-filled state tensor(s).

 Args
  batch_size   int, float, or unit Tensor representing the batch size.
  dtype   the data type to use for the state.

 Returns   If state_size is an int or TensorShape, then the return value is a N-D tensor of shape [batch_size, state_size] filled with zeros. If state_size is a nested list or tuple, then the return value is a nested list or tuple (of the same structure) of 2-D tensors with the shapes [batch_size, s] for each s in state_size.


tf.compat.v1.nn.rnn_cell.BasicRNNCell The most basic RNN cell. Inherits From: RNNCell, Layer, Layer, Module
tf.compat.v1.nn.rnn_cell.BasicRNNCell(
    num_units, activation=None, reuse=None, name=None, dtype=None, **kwargs
)
 Note that this cell is not optimized for performance. Please use tf.contrib.cudnn_rnn.CudnnRNNTanh for better performance on GPU.

 Args
  num_units   int, The number of units in the RNN cell.
  activation   Nonlinearity to use. Default: tanh. It could also be string that is within Keras activation function names.
  reuse   (optional) Python boolean describing whether to reuse variables in an existing scope. If not True, and the existing scope already has the given variables, an error is raised.
  name   String, the name of the layer. Layers with the same name will share weights, but to avoid mistakes we require reuse=True in such cases.
  dtype   Default dtype of the layer (default of None means use the type of the first input). Required when build is called before call.
  **kwargs   Dict, keyword named properties for common layer attributes, like trainable etc when constructing the cell from configs of get_config().

 Attributes
  graph

  output_size   Integer or TensorShape: size of outputs produced by this cell.
  scope_name

  state_size   size(s) of state(s) used by this cell. It can be represented by an Integer, a TensorShape or a tuple of Integers or TensorShapes.
   Methods get_initial_state View source
get_initial_state(
    inputs=None, batch_size=None, dtype=None
)
 zero_state View source
zero_state(
    batch_size, dtype
)
 Return zero-filled state tensor(s).

 Args
  batch_size   int, float, or unit Tensor representing the batch size.
  dtype   the data type to use for the state.

 Returns   If state_size is an int or TensorShape, then the return value is a N-D tensor of shape [batch_size, state_size] filled with zeros. If state_size is a nested list or tuple, then the return value is a nested list or tuple (of the same structure) of 2-D tensors with the shapes [batch_size, s] for each s in state_size.


tf.compat.v1.nn.rnn_cell.DeviceWrapper Operator that ensures an RNNCell runs on a particular device. Inherits From: RNNCell, Layer, Layer, Module
tf.compat.v1.nn.rnn_cell.DeviceWrapper(
    *args, **kwargs
)

 Args
  cell   An instance of RNNCell.
  device   A device string or function, for passing to tf.device.
  **kwargs   dict of keyword arguments for base layer.

 Attributes
  graph

  output_size

  scope_name

  state_size
   Methods get_initial_state View source
get_initial_state(
    inputs=None, batch_size=None, dtype=None
)
 zero_state View source
zero_state(
    batch_size, dtype
)


tf.compat.v1.nn.rnn_cell.DropoutWrapper Operator adding dropout to inputs and outputs of the given cell. Inherits From: RNNCell, Layer, Layer, Module
tf.compat.v1.nn.rnn_cell.DropoutWrapper(
    *args, **kwargs
)

 Args
  cell   an RNNCell, a projection to output_size is added to it.
  input_keep_prob   unit Tensor or float between 0 and 1, input keep probability; if it is constant and 1, no input dropout will be added.
  output_keep_prob   unit Tensor or float between 0 and 1, output keep probability; if it is constant and 1, no output dropout will be added.
  state_keep_prob   unit Tensor or float between 0 and 1, output keep probability; if it is constant and 1, no output dropout will be added. State dropout is performed on the outgoing states of the cell. Note the state components to which dropout is applied when state_keep_prob is in (0, 1) are also determined by the argument dropout_state_filter_visitor (e.g. by default dropout is never applied to the c component of an LSTMStateTuple).
  variational_recurrent   Python bool. If True, then the same dropout pattern is applied across all time steps per run call. If this parameter is set, input_size must be provided.
  input_size   (optional) (possibly nested tuple of) TensorShape objects containing the depth(s) of the input tensors expected to be passed in to the DropoutWrapper. Required and used iff variational_recurrent = True and input_keep_prob < 1.
  dtype   (optional) The dtype of the input, state, and output tensors. Required and used iff variational_recurrent = True.
  seed   (optional) integer, the randomness seed.
  dropout_state_filter_visitor   (optional), default: (see below). Function that takes any hierarchical level of the state and returns a scalar or depth=1 structure of Python booleans describing which terms in the state should be dropped out. In addition, if the function returns True, dropout is applied across this sublevel. If the function returns False, dropout is not applied across this entire sublevel. Default behavior: perform dropout on all terms except the memory (c) state of LSTMCellState objects, and don't try to apply dropout to TensorArray objects: def dropout_state_filter_visitor(s): if isinstance(s, LSTMCellState): # Never perform dropout on the c state. return LSTMCellState(c=False, h=True) elif isinstance(s, TensorArray): return False return True
  **kwargs   dict of keyword arguments for base layer.

 Raises
  TypeError   if cell is not an RNNCell, or keep_state_fn is provided but not callable.
  ValueError   if any of the keep_probs are not between 0 and 1.

 Attributes
  graph

  output_size

  scope_name

  state_size

  wrapped_cell
   Methods get_initial_state View source
get_initial_state(
    inputs=None, batch_size=None, dtype=None
)
 zero_state View source
zero_state(
    batch_size, dtype
)


tf.compat.v1.nn.rnn_cell.GRUCell Gated Recurrent Unit cell. Inherits From: RNNCell, Layer, Layer, Module
tf.compat.v1.nn.rnn_cell.GRUCell(
    num_units, activation=None, reuse=None, kernel_initializer=None,
    bias_initializer=None, name=None, dtype=None, **kwargs
)
 Note that this cell is not optimized for performance. Please use tf.contrib.cudnn_rnn.CudnnGRU for better performance on GPU, or tf.contrib.rnn.GRUBlockCellV2 for better performance on CPU.

 Args
  num_units   int, The number of units in the GRU cell.
  activation   Nonlinearity to use. Default: tanh.
  reuse   (optional) Python boolean describing whether to reuse variables in an existing scope. If not True, and the existing scope already has the given variables, an error is raised.
  kernel_initializer   (optional) The initializer to use for the weight and projection matrices.
  bias_initializer   (optional) The initializer to use for the bias.
  name   String, the name of the layer. Layers with the same name will share weights, but to avoid mistakes we require reuse=True in such cases.
  dtype   Default dtype of the layer (default of None means use the type of the first input). Required when build is called before call.
  **kwargs   Dict, keyword named properties for common layer attributes, like trainable etc when constructing the cell from configs of get_config(). References: Learning Phrase Representations using RNN Encoder Decoder for Statistical Machine Translation: Cho et al., 2014 (pdf)

 Attributes
  graph

  output_size   Integer or TensorShape: size of outputs produced by this cell.
  scope_name

  state_size   size(s) of state(s) used by this cell. It can be represented by an Integer, a TensorShape or a tuple of Integers or TensorShapes.
   Methods get_initial_state View source
get_initial_state(
    inputs=None, batch_size=None, dtype=None
)
 zero_state View source
zero_state(
    batch_size, dtype
)
 Return zero-filled state tensor(s).

 Args
  batch_size   int, float, or unit Tensor representing the batch size.
  dtype   the data type to use for the state.

 Returns   If state_size is an int or TensorShape, then the return value is a N-D tensor of shape [batch_size, state_size] filled with zeros. If state_size is a nested list or tuple, then the return value is a nested list or tuple (of the same structure) of 2-D tensors with the shapes [batch_size, s] for each s in state_size.


tf.compat.v1.nn.rnn_cell.LSTMCell Long short-term memory unit (LSTM) recurrent network cell. Inherits From: RNNCell, Layer, Layer, Module
tf.compat.v1.nn.rnn_cell.LSTMCell(
    num_units, use_peepholes=False, cell_clip=None, initializer=None, num_proj=None,
    proj_clip=None, num_unit_shards=None, num_proj_shards=None, forget_bias=1.0,
    state_is_tuple=True, activation=None, reuse=None, name=None, dtype=None,
    **kwargs
)
 The default non-peephole implementation is based on (Gers et al., 1999). The peephole implementation is based on (Sak et al., 2014). The class uses optional peep-hole connections, optional cell clipping, and an optional projection layer. Note that this cell is not optimized for performance. Please use tf.contrib.cudnn_rnn.CudnnLSTM for better performance on GPU, or tf.contrib.rnn.LSTMBlockCell and tf.contrib.rnn.LSTMBlockFusedCell for better performance on CPU. References: Long short-term memory recurrent neural network architectures for large scale acoustic modeling: Sak et al., 2014 (pdf) Learning to forget: Gers et al., 1999 (pdf) Long Short-Term Memory: Hochreiter et al., 1997 (pdf)

 Args
  num_units   int, The number of units in the LSTM cell.
  use_peepholes   bool, set True to enable diagonal/peephole connections.
  cell_clip   (optional) A float value, if provided the cell state is clipped by this value prior to the cell output activation.
  initializer   (optional) The initializer to use for the weight and projection matrices.
  num_proj   (optional) int, The output dimensionality for the projection matrices. If None, no projection is performed.
  proj_clip   (optional) A float value. If num_proj > 0 and proj_clip is provided, then the projected values are clipped elementwise to within [-proj_clip, proj_clip].
  num_unit_shards   Deprecated, will be removed by Jan. 2017. Use a variable_scope partitioner instead.
  num_proj_shards   Deprecated, will be removed by Jan. 2017. Use a variable_scope partitioner instead.
  forget_bias   Biases of the forget gate are initialized by default to 1 in order to reduce the scale of forgetting at the beginning of the training. Must set it manually to 0.0 when restoring from CudnnLSTM trained checkpoints.
  state_is_tuple   If True, accepted and returned states are 2-tuples of the c_state and m_state. If False, they are concatenated along the column axis. This latter behavior will soon be deprecated.
  activation   Activation function of the inner states. Default: tanh. It could also be string that is within Keras activation function names.
  reuse   (optional) Python boolean describing whether to reuse variables in an existing scope. If not True, and the existing scope already has the given variables, an error is raised.
  name   String, the name of the layer. Layers with the same name will share weights, but to avoid mistakes we require reuse=True in such cases.
  dtype   Default dtype of the layer (default of None means use the type of the first input). Required when build is called before call.
  **kwargs   Dict, keyword named properties for common layer attributes, like trainable etc when constructing the cell from configs of get_config(). When restoring from CudnnLSTM-trained checkpoints, use CudnnCompatibleLSTMCell instead.

 Attributes
  graph

  output_size   Integer or TensorShape: size of outputs produced by this cell.
  scope_name

  state_size   size(s) of state(s) used by this cell. It can be represented by an Integer, a TensorShape or a tuple of Integers or TensorShapes.
   Methods get_initial_state View source
get_initial_state(
    inputs=None, batch_size=None, dtype=None
)
 zero_state View source
zero_state(
    batch_size, dtype
)
 Return zero-filled state tensor(s).

 Args
  batch_size   int, float, or unit Tensor representing the batch size.
  dtype   the data type to use for the state.

 Returns   If state_size is an int or TensorShape, then the return value is a N-D tensor of shape [batch_size, state_size] filled with zeros. If state_size is a nested list or tuple, then the return value is a nested list or tuple (of the same structure) of 2-D tensors with the shapes [batch_size, s] for each s in state_size.


tf.compat.v1.nn.rnn_cell.LSTMStateTuple Tuple used by LSTM Cells for state_size, zero_state, and output state.
tf.compat.v1.nn.rnn_cell.LSTMStateTuple(
    c, h
)
 Stores two elements: (c, h), in that order. Where c is the hidden state and h is the output. Only used when state_is_tuple=True.

 Attributes
  c

  h

  dtype


tf.compat.v1.nn.rnn_cell.MultiRNNCell RNN cell composed sequentially of multiple simple cells. Inherits From: RNNCell, Layer, Layer, Module
tf.compat.v1.nn.rnn_cell.MultiRNNCell(
    cells, state_is_tuple=True
)
 Example: num_units = [128, 64]
cells = [BasicLSTMCell(num_units=n) for n in num_units]
stacked_rnn_cell = MultiRNNCell(cells)

 Args
  cells   list of RNNCells that will be composed in this order.
  state_is_tuple   If True, accepted and returned states are n-tuples, where n = len(cells). If False, the states are all concatenated along the column axis. This latter behavior will soon be deprecated.

 Raises
  ValueError   if cells is empty (not allowed), or at least one of the cells returns a state tuple but the flag state_is_tuple is False.

 Attributes
  graph

  output_size   Integer or TensorShape: size of outputs produced by this cell.
  scope_name

  state_size   size(s) of state(s) used by this cell. It can be represented by an Integer, a TensorShape or a tuple of Integers or TensorShapes.
   Methods get_initial_state View source
get_initial_state(
    inputs=None, batch_size=None, dtype=None
)
 zero_state View source
zero_state(
    batch_size, dtype
)
 Return zero-filled state tensor(s).

 Args
  batch_size   int, float, or unit Tensor representing the batch size.
  dtype   the data type to use for the state.

 Returns   If state_size is an int or TensorShape, then the return value is a N-D tensor of shape [batch_size, state_size] filled with zeros. If state_size is a nested list or tuple, then the return value is a nested list or tuple (of the same structure) of 2-D tensors with the shapes [batch_size, s] for each s in state_size.


tf.compat.v1.nn.rnn_cell.ResidualWrapper RNNCell wrapper that ensures cell inputs are added to the outputs. Inherits From: RNNCell, Layer, Layer, Module
tf.compat.v1.nn.rnn_cell.ResidualWrapper(
    *args, **kwargs
)

 Args
  cell   An instance of RNNCell.
  residual_fn   (Optional) The function to map raw cell inputs and raw cell outputs to the actual cell outputs of the residual network. Defaults to calling nest.map_structure on (lambda i, o: i + o), inputs and outputs.
  **kwargs   dict of keyword arguments for base layer.

 Attributes
  graph

  output_size

  scope_name

  state_size
   Methods get_initial_state View source
get_initial_state(
    inputs=None, batch_size=None, dtype=None
)
 zero_state View source
zero_state(
    batch_size, dtype
)


tf.compat.v1.nn.rnn_cell.RNNCell Abstract object representing an RNN cell. Inherits From: Layer, Layer, Module
tf.compat.v1.nn.rnn_cell.RNNCell(
    trainable=True, name=None, dtype=None, **kwargs
)
 Every RNNCell must have the properties below and implement call with the signature (output, next_state) = call(input, state). The optional third input argument, scope, is allowed for backwards compatibility purposes; but should be left off for new subclasses. This definition of cell differs from the definition used in the literature. In the literature, 'cell' refers to an object with a single scalar output. This definition refers to a horizontal array of such units. An RNN cell, in the most abstract setting, is anything that has a state and performs some operation that takes a matrix of inputs. This operation results in an output matrix with self.output_size columns. If self.state_size is an integer, this operation also results in a new state matrix with self.state_size columns. If self.state_size is a (possibly nested tuple of) TensorShape object(s), then it should return a matching structure of Tensors having shape [batch_size].concatenate(s) for each s in self.batch_size.

 Attributes
  graph

  output_size   Integer or TensorShape: size of outputs produced by this cell.
  scope_name

  state_size   size(s) of state(s) used by this cell. It can be represented by an Integer, a TensorShape or a tuple of Integers or TensorShapes.
   Methods get_initial_state View source
get_initial_state(
    inputs=None, batch_size=None, dtype=None
)
 zero_state View source
zero_state(
    batch_size, dtype
)
 Return zero-filled state tensor(s).

 Args
  batch_size   int, float, or unit Tensor representing the batch size.
  dtype   the data type to use for the state.

 Returns   If state_size is an int or TensorShape, then the return value is a N-D tensor of shape [batch_size, state_size] filled with zeros. If state_size is a nested list or tuple, then the return value is a nested list or tuple (of the same structure) of 2-D tensors with the shapes [batch_size, s] for each s in state_size.


tf.compat.v1.nn.safe_embedding_lookup_sparse Lookup embedding results, accounting for invalid IDs and empty features.
tf.compat.v1.nn.safe_embedding_lookup_sparse(
    embedding_weights, sparse_ids, sparse_weights=None, combiner='mean',
    default_id=None, name=None, partition_strategy='div', max_norm=None
)
 The partitioned embedding in embedding_weights must all be the same shape except for the first dimension. The first dimension is allowed to vary as the vocabulary size is not necessarily a multiple of P. embedding_weights may be a PartitionedVariable as returned by using tf.compat.v1.get_variable() with a partitioner. Invalid IDs (< 0) are pruned from input IDs and weights, as well as any IDs with non-positive weight. For an entry with no features, the embedding vector for default_id is returned, or the 0-vector if default_id is not supplied. The ids and weights may be multi-dimensional. Embeddings are always aggregated along the last dimension.

 Args
  embedding_weights   A single tensor representing the complete embedding tensor, or a list tensors all of same shape except for the first dimension, representing sharded embedding tensors. Alternatively, a PartitionedVariable, created by partitioning along dimension 0. Each element must be appropriately sized for the given partition_strategy.
  sparse_ids   SparseTensor of shape [d_0, d_1, ..., d_n] containing the ids. d_0 is typically batch size.
  sparse_weights   SparseTensor of same shape as sparse_ids, containing float weights corresponding to sparse_ids, or None if all weights are be assumed to be 1.0.
  combiner   A string specifying how to combine embedding results for each entry. Currently "mean", "sqrtn" and "sum" are supported, with "mean" the default.
  default_id   The id to use for an entry with no features.
  name   A name for this operation (optional).
  partition_strategy   A string specifying the partitioning strategy. Currently "div" and "mod" are supported. Default is "div".
  max_norm   If not None, all embeddings are l2-normalized to max_norm before combining.

 Returns   A dense tensor representing the combined embeddings for the sparse ids. For each row in the dense tensor represented by sp_ids, the op looks up the embeddings for all ids in that row, multiplies them by the corresponding weight, and combines these embeddings as specified. In other words, if shape(combined embedding_weights) = [p0, p1, ..., pm] and shape(sparse_ids) = shape(sparse_weights) = [d0, d1, ..., dn] then shape(output) = [d0, d1, ... dn-1, p1, ..., pm]. For instance, if params is a 10x20 matrix, and sp_ids / sp_weights are [0, 0]: id 1, weight 2.0
[0, 1]: id 3, weight 0.5
[1, 0]: id -1, weight 1.0
[2, 3]: id 1, weight 3.0
 default_id is 0. with combiner="mean", then the output will be a 3x20 matrix where output[0, :] = (params[1, :] * 2.0 + params[3, :] * 0.5) / (2.0 + 0.5)
output[1, :] = (params[0, :] * 1.0) / 1.0
output[2, :] = (params[1, :] * 3.0) / 3.0

 Raises
  ValueError   if embedding_weights is empty.


tf.compat.v1.nn.sampled_softmax_loss Computes and returns the sampled softmax training loss.
tf.compat.v1.nn.sampled_softmax_loss(
    weights, biases, labels, inputs, num_sampled, num_classes, num_true=1,
    sampled_values=None, remove_accidental_hits=True,
    partition_strategy='mod', name='sampled_softmax_loss',
    seed=None
)
 This is a faster way to train a softmax classifier over a huge number of classes. This operation is for training only. It is generally an underestimate of the full softmax loss. A common use case is to use this method for training, and calculate the full softmax loss for evaluation or inference. In this case, you must set partition_strategy="div" for the two losses to be consistent, as in the following example: if mode == "train":
  loss = tf.nn.sampled_softmax_loss(
      weights=weights,
      biases=biases,
      labels=labels,
      inputs=inputs,
      ...,
      partition_strategy="div")
elif mode == "eval":
  logits = tf.matmul(inputs, tf.transpose(weights))
  logits = tf.nn.bias_add(logits, biases)
  labels_one_hot = tf.one_hot(labels, n_classes)
  loss = tf.nn.softmax_cross_entropy_with_logits(
      labels=labels_one_hot,
      logits=logits)
 See our Candidate Sampling Algorithms Reference (pdf). Also see Section 3 of (Jean et al., 2014) for the math.

 Args
  weights   A Tensor of shape [num_classes, dim], or a list of Tensor objects whose concatenation along dimension 0 has shape [num_classes, dim]. The (possibly-sharded) class embeddings.
  biases   A Tensor of shape [num_classes]. The class biases.
  labels   A Tensor of type int64 and shape [batch_size, num_true]. The target classes. Note that this format differs from the labels argument of nn.softmax_cross_entropy_with_logits.
  inputs   A Tensor of shape [batch_size, dim]. The forward activations of the input network.
  num_sampled   An int. The number of classes to randomly sample per batch.
  num_classes   An int. The number of possible classes.
  num_true   An int. The number of target classes per training example.
  sampled_values   a tuple of (sampled_candidates, true_expected_count, sampled_expected_count) returned by a *_candidate_sampler function. (if None, we default to log_uniform_candidate_sampler)
  remove_accidental_hits   A bool. whether to remove "accidental hits" where a sampled class equals one of the target classes. Default is True.
  partition_strategy   A string specifying the partitioning strategy, relevant if len(weights) > 1. Currently "div" and "mod" are supported. Default is "mod". See tf.nn.embedding_lookup for more details.
  name   A name for the operation (optional).
  seed   random seed for candidate sampling. Default to None, which doesn't set the op-level random seed for candidate sampling.

 Returns   A batch_size 1-D tensor of per-example sampled softmax losses.
 References: On Using Very Large Target Vocabulary for Neural Machine Translation: Jean et al., 2014 (pdf)


tf.compat.v1.nn.separable_conv2d 2-D convolution with separable filters.
tf.compat.v1.nn.separable_conv2d(
    input, depthwise_filter, pointwise_filter, strides, padding, rate=None,
    name=None, data_format=None, dilations=None
)
 Performs a depthwise convolution that acts separately on channels followed by a pointwise convolution that mixes channels. Note that this is separability between dimensions [1, 2] and 3, not spatial separability between dimensions 1 and 2. In detail, with the default NHWC format, output[b, i, j, k] = sum_{di, dj, q, r}
    input[b, strides[1] * i + di, strides[2] * j + dj, q] *
    depthwise_filter[di, dj, q, r] *
    pointwise_filter[0, 0, q * channel_multiplier + r, k]
 strides controls the strides for the depthwise convolution only, since the pointwise convolution has implicit strides of [1, 1, 1, 1]. Must have strides[0] = strides[3] = 1. For the most common case of the same horizontal and vertical strides, strides = [1, stride, stride, 1]. If any value in rate is greater than 1, we perform atrous depthwise convolution, in which case all values in the strides tensor must be equal to 1.

 Args
  input   4-D Tensor with shape according to data_format.
  depthwise_filter   4-D Tensor with shape [filter_height, filter_width, in_channels, channel_multiplier]. Contains in_channels convolutional filters of depth 1.
  pointwise_filter   4-D Tensor with shape [1, 1, channel_multiplier * in_channels, out_channels]. Pointwise filter to mix channels after depthwise_filter has convolved spatially.
  strides   1-D of size 4. The strides for the depthwise convolution for each dimension of input.
  padding   Controls how to pad the image before applying the depthwise convolution. Can be the string "SAME" or "VALID" indicating the type of padding algorithm to use, or a Python list indicating the explicit paddings at the start and end of each dimension. When explicit padding is used and data_format is "NHWC", this should be in the form [[0, 0], [pad_top, pad_bottom], [pad_left, pad_right], [0, 0]]. When explicit padding used and data_format is "NCHW", this should be in the form [[0, 0], [0, 0], [pad_top, pad_bottom], [pad_left, pad_right]].
  rate   1-D of size 2. The dilation rate in which we sample input values across the height and width dimensions in atrous convolution. If it is greater than 1, then all values of strides must be 1.
  name   A name for this operation (optional).
  data_format   The data format for input. Either "NHWC" (default) or "NCHW".
  dilations   Alias of rate.

 Returns   A 4-D Tensor with shape according to 'data_format'. For example, with data_format="NHWC", shape is [batch, out_height, out_width, out_channels].


tf.compat.v1.nn.sigmoid_cross_entropy_with_logits Computes sigmoid cross entropy given logits.
tf.compat.v1.nn.sigmoid_cross_entropy_with_logits(
    _sentinel=None, labels=None, logits=None, name=None
)
 Measures the probability error in discrete classification tasks in which each class is independent and not mutually exclusive. For instance, one could perform multilabel classification where a picture can contain both an elephant and a dog at the same time. For brevity, let x = logits, z = labels. The logistic loss is   z * -log(sigmoid(x)) + (1 - z) * -log(1 - sigmoid(x))
= z * -log(1 / (1 + exp(-x))) + (1 - z) * -log(exp(-x) / (1 + exp(-x)))
= z * log(1 + exp(-x)) + (1 - z) * (-log(exp(-x)) + log(1 + exp(-x)))
= z * log(1 + exp(-x)) + (1 - z) * (x + log(1 + exp(-x))
= (1 - z) * x + log(1 + exp(-x))
= x - x * z + log(1 + exp(-x))
 For x < 0, to avoid overflow in exp(-x), we reformulate the above   x - x * z + log(1 + exp(-x))
= log(exp(x)) - x * z + log(1 + exp(-x))
= - x * z + log(1 + exp(x))
 Hence, to ensure stability and avoid overflow, the implementation uses this equivalent formulation max(x, 0) - x * z + log(1 + exp(-abs(x)))
 logits and labels must have the same type and shape.

 Args
  _sentinel   Used to prevent positional parameters. Internal, do not use.
  labels   A Tensor of the same type and shape as logits.
  logits   A Tensor of type float32 or float64.
  name   A name for the operation (optional).

 Returns   A Tensor of the same shape as logits with the componentwise logistic losses.

 Raises
  ValueError   If logits and labels do not have the same shape.


tf.compat.v1.nn.softmax_cross_entropy_with_logits Computes softmax cross entropy between logits and labels. (deprecated)
tf.compat.v1.nn.softmax_cross_entropy_with_logits(
    _sentinel=None, labels=None, logits=None, dim=-1, name=None, axis=None
)
 Warning: THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Future major versions of TensorFlow will allow gradients to flow into the labels input on backprop by default. See tf.nn.softmax_cross_entropy_with_logits_v2. Measures the probability error in discrete classification tasks in which the classes are mutually exclusive (each entry is in exactly one class). For example, each CIFAR-10 image is labeled with one and only one label: an image can be a dog or a truck, but not both.
Note: While the classes are mutually exclusive, their probabilities need not be. All that is required is that each row of labels is a valid probability distribution. If they are not, the computation of the gradient will be incorrect.
 If using exclusive labels (wherein one and only one class is true at a time), see sparse_softmax_cross_entropy_with_logits. Warning: This op expects unscaled logits, since it performs a softmax on logits internally for efficiency. Do not call this op with the output of softmax, as it will produce incorrect results. A common use case is to have logits and labels of shape [batch_size, num_classes], but higher dimensions are supported, with the dim argument specifying the class dimension. Backpropagation will happen only into logits. To calculate a cross entropy loss that allows backpropagation into both logits and labels, see tf.nn.softmax_cross_entropy_with_logits_v2. Note that to avoid confusion, it is required to pass only named arguments to this function.

 Args
  _sentinel   Used to prevent positional parameters. Internal, do not use.
  labels   Each vector along the class dimension should hold a valid probability distribution e.g. for the case in which labels are of shape [batch_size, num_classes], each row of labels[i] must be a valid probability distribution.
  logits   Per-label activations, typically a linear output. These activation energies are interpreted as unnormalized log probabilities.
  dim   The class dimension. Defaulted to -1 which is the last dimension.
  name   A name for the operation (optional).
  axis   Alias for dim.

 Returns   A Tensor that contains the softmax cross entropy loss. Its type is the same as logits and its shape is the same as labels except that it does not have the last dimension of labels.


tf.compat.v1.nn.softmax_cross_entropy_with_logits_v2 Computes softmax cross entropy between logits and labels. (deprecated arguments)
tf.compat.v1.nn.softmax_cross_entropy_with_logits_v2(
    labels, logits, axis=None, name=None, dim=None
)
 Warning: SOME ARGUMENTS ARE DEPRECATED: (dim). They will be removed in a future version. Instructions for updating: dim is deprecated, use axis instead Measures the probability error in discrete classification tasks in which the classes are mutually exclusive (each entry is in exactly one class). For example, each CIFAR-10 image is labeled with one and only one label: an image can be a dog or a truck, but not both.
Note: While the classes are mutually exclusive, their probabilities need not be. All that is required is that each row of labels is a valid probability distribution. If they are not, the computation of the gradient will be incorrect.
 If using exclusive labels (wherein one and only one class is true at a time), see sparse_softmax_cross_entropy_with_logits. Warning: This op expects unscaled logits, since it performs a softmax on logits internally for efficiency. Do not call this op with the output of softmax, as it will produce incorrect results. A common use case is to have logits and labels of shape [batch_size, num_classes], but higher dimensions are supported, with the axis argument specifying the class dimension. logits and labels must have the same dtype (either float16, float32, or float64). Backpropagation will happen into both logits and labels. To disallow backpropagation into labels, pass label tensors through tf.stop_gradient before feeding it to this function. Note that to avoid confusion, it is required to pass only named arguments to this function.

 Args
  labels   Each vector along the class dimension should hold a valid probability distribution e.g. for the case in which labels are of shape [batch_size, num_classes], each row of labels[i] must be a valid probability distribution.
  logits   Unscaled log probabilities.
  axis   The class dimension. Defaulted to -1 which is the last dimension.
  name   A name for the operation (optional).
  dim   Deprecated alias for axis.

 Returns   A Tensor that contains the softmax cross entropy loss. Its type is the same as logits and its shape is the same as labels except that it does not have the last dimension of labels.


tf.compat.v1.nn.sparse_softmax_cross_entropy_with_logits Computes sparse softmax cross entropy between logits and labels.
tf.compat.v1.nn.sparse_softmax_cross_entropy_with_logits(
    _sentinel=None, labels=None, logits=None, name=None
)
 Measures the probability error in discrete classification tasks in which the classes are mutually exclusive (each entry is in exactly one class). For example, each CIFAR-10 image is labeled with one and only one label: an image can be a dog or a truck, but not both.
Note: For this operation, the probability of a given label is considered exclusive. That is, soft classes are not allowed, and the labels vector must provide a single specific index for the true class for each row of logits (each minibatch entry). For soft softmax classification with a probability distribution for each entry, see softmax_cross_entropy_with_logits_v2.

Warning: This op expects unscaled logits, since it performs a softmax on logits internally for efficiency. Do not call this op with the output of softmax, as it will produce incorrect results. A common use case is to have logits of shape [batch_size, num_classes] and have labels of shape [batch_size], but higher dimensions are supported, in which case the dim-th dimension is assumed to be of size num_classes. logits must have the dtype of float16, float32, or float64, and labels must have the dtype of int32 or int64. Note that to avoid confusion, it is required to pass only named arguments to this function.

 Args
  _sentinel   Used to prevent positional parameters. Internal, do not use.
  labels   Tensor of shape [d_0, d_1, ..., d_{r-1}] (where r is rank of labels and result) and dtype int32 or int64. Each entry in labels must be an index in [0, num_classes). Other values will raise an exception when this op is run on CPU, and return NaN for corresponding loss and gradient rows on GPU.
  logits   Per-label activations (typically a linear output) of shape [d_0, d_1, ..., d_{r-1}, num_classes] and dtype float16, float32, or float64. These activation energies are interpreted as unnormalized log probabilities.
  name   A name for the operation (optional).

 Returns   A Tensor of the same shape as labels and of the same type as logits with the softmax cross entropy loss.

 Raises
  ValueError   If logits are scalars (need to have rank >= 1) or if the rank of the labels is not equal to the rank of the logits minus one.


tf.compat.v1.nn.static_bidirectional_rnn Creates a bidirectional recurrent neural network. (deprecated)
tf.compat.v1.nn.static_bidirectional_rnn(
    cell_fw, cell_bw, inputs, initial_state_fw=None, initial_state_bw=None,
    dtype=None, sequence_length=None, scope=None
)
 Warning: THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Please use keras.layers.Bidirectional(keras.layers.RNN(cell, unroll=True)), which is equivalent to this API Similar to the unidirectional case above (rnn) but takes input and builds independent forward and backward RNNs with the final forward and backward outputs depth-concatenated, such that the output will have the format [time][batch][cell_fw.output_size + cell_bw.output_size]. The input_size of forward and backward cell must match. The initial state for both directions is zero by default (but can be set optionally) and no intermediate states are ever returned -- the network is fully unrolled for the given (passed in) length(s) of the sequence(s) or completely unrolled if length(s) is not given.

 Args
  cell_fw   An instance of RNNCell, to be used for forward direction.
  cell_bw   An instance of RNNCell, to be used for backward direction.
  inputs   A length T list of inputs, each a tensor of shape [batch_size, input_size], or a nested tuple of such elements.
  initial_state_fw   (optional) An initial state for the forward RNN. This must be a tensor of appropriate type and shape [batch_size, cell_fw.state_size]. If cell_fw.state_size is a tuple, this should be a tuple of tensors having shapes [batch_size, s] for s in cell_fw.state_size.
  initial_state_bw   (optional) Same as for initial_state_fw, but using the corresponding properties of cell_bw.
  dtype   (optional) The data type for the initial state. Required if either of the initial states are not provided.
  sequence_length   (optional) An int32/int64 vector, size [batch_size], containing the actual lengths for each of the sequences.
  scope   VariableScope for the created subgraph; defaults to "bidirectional_rnn"

 Returns   A tuple (outputs, output_state_fw, output_state_bw) where: outputs is a length T list of outputs (one for each input), which are depth-concatenated forward and backward outputs. output_state_fw is the final state of the forward rnn. output_state_bw is the final state of the backward rnn.

 Raises
  TypeError   If cell_fw or cell_bw is not an instance of RNNCell.
  ValueError   If inputs is None or an empty list.


tf.compat.v1.nn.static_rnn Creates a recurrent neural network specified by RNNCell cell. (deprecated)
tf.compat.v1.nn.static_rnn(
    cell, inputs, initial_state=None, dtype=None, sequence_length=None, scope=None
)
 Warning: THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Please use keras.layers.RNN(cell, unroll=True), which is equivalent to this API The simplest form of RNN network generated is: state = cell.zero_state(...)
outputs = []
for input_ in inputs:
  output, state = cell(input_, state)
  outputs.append(output)
return (outputs, state)
 However, a few other options are available: An initial state can be provided. If the sequence_length vector is provided, dynamic calculation is performed. This method of calculation does not compute the RNN steps past the maximum sequence length of the minibatch (thus saving computational time), and properly propagates the state at an example's sequence length to the final state output. The dynamic calculation performed is, at time t for batch row b, (output, state)(b, t) =
  (t >= sequence_length(b))
    ? (zeros(cell.output_size), states(b, sequence_length(b) - 1))
    : cell(input(b, t), state(b, t - 1))

 Args
  cell   An instance of RNNCell.
  inputs   A length T list of inputs, each a Tensor of shape [batch_size, input_size], or a nested tuple of such elements.
  initial_state   (optional) An initial state for the RNN. If cell.state_size is an integer, this must be a Tensor of appropriate type and shape [batch_size, cell.state_size]. If cell.state_size is a tuple, this should be a tuple of tensors having shapes [batch_size, s] for s in cell.state_size.
  dtype   (optional) The data type for the initial state and expected output. Required if initial_state is not provided or RNN state has a heterogeneous dtype.
  sequence_length   Specifies the length of each sequence in inputs. An int32 or int64 vector (tensor) size [batch_size], values in [0, T).
  scope   VariableScope for the created subgraph; defaults to "rnn".

 Returns   A pair (outputs, state) where:  outputs is a length T list of outputs (one for each input), or a nested tuple of such elements. state is the final state

 Raises
  TypeError   If cell is not an instance of RNNCell.
  ValueError   If inputs is None or an empty list, or if the input depth (column size) cannot be inferred from inputs via shape inference.


tf.compat.v1.nn.static_state_saving_rnn RNN that accepts a state saver for time-truncated RNN calculation. (deprecated)
tf.compat.v1.nn.static_state_saving_rnn(
    cell, inputs, state_saver, state_name, sequence_length=None, scope=None
)
 Warning: THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Please use keras.layers.RNN(cell, stateful=True), which is equivalent to this API

 Args
  cell   An instance of RNNCell.
  inputs   A length T list of inputs, each a Tensor of shape [batch_size, input_size].
  state_saver   A state saver object with methods state and save_state.
  state_name   Python string or tuple of strings. The name to use with the state_saver. If the cell returns tuples of states (i.e., cell.state_size is a tuple) then state_name should be a tuple of strings having the same length as cell.state_size. Otherwise it should be a single string.
  sequence_length   (optional) An int32/int64 vector size [batch_size]. See the documentation for rnn() for more details about sequence_length.
  scope   VariableScope for the created subgraph; defaults to "rnn".

 Returns   A pair (outputs, state) where: outputs is a length T list of outputs (one for each input) states is the final state

 Raises
  TypeError   If cell is not an instance of RNNCell.
  ValueError   If inputs is None or an empty list, or if the arity and type of state_name does not match that of cell.state_size.


tf.compat.v1.nn.sufficient_statistics Calculate the sufficient statistics for the mean and variance of x.
tf.compat.v1.nn.sufficient_statistics(
    x, axes, shift=None, keep_dims=None, name=None, keepdims=None
)
 These sufficient statistics are computed using the one pass algorithm on an input that's optionally shifted. See: https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Computing_shifted_data For example:
t = [[1, 2, 3], [4, 5, 6]]
sufficient_statistics(t, [1])
(<tf.Tensor: shape=(), dtype=int32, numpy=3>, <tf.Tensor: shape=(2,),
dtype=int32, numpy=array([ 6, 15], dtype=int32)>, <tf.Tensor: shape=(2,),
dtype=int32, numpy=array([14, 77], dtype=int32)>, None)
sufficient_statistics(t, [-1])
(<tf.Tensor: shape=(), dtype=int32, numpy=3>, <tf.Tensor: shape=(2,),
dtype=int32, numpy=array([ 6, 15], dtype=int32)>, <tf.Tensor: shape=(2,),
dtype=int32, numpy=array([14, 77], dtype=int32)>, None)

 Args
  x   A Tensor.
  axes   Array of ints. Axes along which to compute mean and variance. As in Python, the axes can also be negative numbers. A negative axis is interpreted as counting from the end of the rank, i.e., axis + rank(values)-th dimension.
  shift   A Tensor containing the value by which to shift the data for numerical stability, or None if no shift is to be performed. A shift close to the true mean provides the most numerically stable results.
  keep_dims   produce statistics with the same dimensionality as the input.
  name   Name used to scope the operations that compute the sufficient stats.
  keepdims   Alias for keep_dims.

 Returns   Four Tensor objects of the same type as x:  the count (number of elements to average over). the (possibly shifted) sum of the elements in the array. the (possibly shifted) sum of squares of the elements in the array. the shift by which the mean must be corrected or None if shift is None.


tf.compat.v1.nn.weighted_cross_entropy_with_logits Computes a weighted cross entropy. (deprecated arguments)
tf.compat.v1.nn.weighted_cross_entropy_with_logits(
    labels=None, logits=None, pos_weight=None, name=None, targets=None
)
 Warning: SOME ARGUMENTS ARE DEPRECATED: (targets). They will be removed in a future version. Instructions for updating: targets is deprecated, use labels instead This is like sigmoid_cross_entropy_with_logits() except that pos_weight, allows one to trade off recall and precision by up- or down-weighting the cost of a positive error relative to a negative error. The usual cross-entropy cost is defined as: labels * -log(sigmoid(logits)) +
    (1 - labels) * -log(1 - sigmoid(logits))
 A value pos_weight > 1 decreases the false negative count, hence increasing the recall. Conversely setting pos_weight < 1 decreases the false positive count and increases the precision. This can be seen from the fact that pos_weight is introduced as a multiplicative coefficient for the positive labels term in the loss expression: labels * -log(sigmoid(logits)) * pos_weight +
    (1 - labels) * -log(1 - sigmoid(logits))
 For brevity, let x = logits, z = labels, q = pos_weight. The loss is:   qz * -log(sigmoid(x)) + (1 - z) * -log(1 - sigmoid(x))
= qz * -log(1 / (1 + exp(-x))) + (1 - z) * -log(exp(-x) / (1 + exp(-x)))
= qz * log(1 + exp(-x)) + (1 - z) * (-log(exp(-x)) + log(1 + exp(-x)))
= qz * log(1 + exp(-x)) + (1 - z) * (x + log(1 + exp(-x))
= (1 - z) * x + (qz +  1 - z) * log(1 + exp(-x))
= (1 - z) * x + (1 + (q - 1) * z) * log(1 + exp(-x))
 Setting l = (1 + (q - 1) * z), to ensure stability and avoid overflow, the implementation uses (1 - z) * x + l * (log(1 + exp(-abs(x))) + max(-x, 0))
 logits and labels must have the same type and shape.

 Args
  labels   A Tensor of the same type and shape as logits.
  logits   A Tensor of type float32 or float64.
  pos_weight   A coefficient to use on the positive examples.
  name   A name for the operation (optional).
  targets   Deprecated alias for labels.

 Returns   A Tensor of the same shape as logits with the componentwise weighted logistic losses.

 Raises
  ValueError   If logits and labels do not have the same shape.


tf.compat.v1.nn.weighted_moments Returns the frequency-weighted mean and variance of x.
tf.compat.v1.nn.weighted_moments(
    x, axes, frequency_weights, name=None, keep_dims=None, keepdims=None
)

 Args
  x   A tensor.
  axes   1-d tensor of int32 values; these are the axes along which to compute mean and variance.
  frequency_weights   A tensor of positive weights which can be broadcast with x.
  name   Name used to scope the operation.
  keep_dims   Produce moments with the same dimensionality as the input.
  keepdims   Alias of keep_dims.

 Returns   Two tensors: weighted_mean and weighted_variance.


tf.compat.v1.nn.xw_plus_b Computes matmul(x, weights) + biases.
tf.compat.v1.nn.xw_plus_b(
    x, weights, biases, name=None
)

 Args
  x   a 2D tensor. Dimensions typically: batch, in_units
  weights   a 2D tensor. Dimensions typically: in_units, out_units
  biases   a 1D tensor. Dimensions: out_units
  name   A name for the operation (optional). If not specified "xw_plus_b" is used.

 Returns   A 2-D Tensor computing matmul(x, weights) + biases. Dimensions typically: batch, out_units.


tf.compat.v1.NodeDef A ProtocolMessage

 Attributes
  attr   repeated AttrEntry attr
  device   string device
  experimental_debug_info   ExperimentalDebugInfo experimental_debug_info
  input   repeated string input
  name   string name
  op   string op    Child Classes class AttrEntry class ExperimentalDebugInfo


tf.compat.v1.NodeDef.AttrEntry A ProtocolMessage

 Attributes
  key   string key
  value   AttrValue value


tf.compat.v1.NodeDef.ExperimentalDebugInfo A ProtocolMessage

 Attributes
  original_func_names   repeated string original_func_names
  original_node_names   repeated string original_node_names


tf.compat.v1.norm Computes the norm of vectors, matrices, and tensors. (deprecated arguments)  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.linalg.norm
tf.compat.v1.norm(
    tensor, ord='euclidean', axis=None, keepdims=None, name=None,
    keep_dims=None
)
 Warning: SOME ARGUMENTS ARE DEPRECATED: (keep_dims). They will be removed in a future version. Instructions for updating: keep_dims is deprecated, use keepdims instead This function can compute several different vector norms (the 1-norm, the Euclidean or 2-norm, the inf-norm, and in general the p-norm for p > 0) and matrix norms (Frobenius, 1-norm, 2-norm and inf-norm).

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

 Returns
  output   A Tensor of the same type as tensor, containing the vector or matrix norms. If keepdims is True then the rank of output is equal to the rank of tensor. Otherwise, if axis is none the output is a scalar, if axis is an integer, the rank of output is one less than the rank of tensor, if axis is a 2-tuple the rank of output is two less than the rank of tensor.

 Raises
  ValueError   If ord or axis is invalid.    Numpy Compatibility Mostly equivalent to numpy.linalg.norm. Not supported: ord <= 0, 2-norm for matrices, nuclear norm. Other differences: a) If axis is None, treats the flattened tensor as a vector regardless of rank. b) Explicitly supports 'euclidean' norm as the default, including for higher order tensors.


tf.compat.v1.no_regularizer Use this function to prevent regularization of variables.
tf.compat.v1.no_regularizer(
    _
)


tf.compat.v1.ones_like Creates a tensor with all elements set to 1.
tf.compat.v1.ones_like(
    tensor, dtype=None, name=None, optimize=True
)
 See also tf.ones. Given a single tensor (tensor), this operation returns a tensor of the same type and shape as tensor with all elements set to 1. Optionally, you can specify a new type (dtype) for the returned tensor. For example: tensor = tf.constant([[1, 2, 3], [4, 5, 6]])
tf.ones_like(tensor)  # [[1, 1, 1], [1, 1, 1]]

 Args
  tensor   A Tensor.
  dtype   A type for the returned Tensor. Must be float32, float64, int8, uint8, int16, uint16, int32, int64, complex64, complex128 or bool.
  name   A name for the operation (optional).
  optimize   if true, attempt to statically determine the shape of 'tensor' and encode it as a constant.

 Returns   A Tensor with all elements set to 1.


tf.compat.v1.OptimizerOptions A ProtocolMessage

 Attributes
  do_common_subexpression_elimination   bool do_common_subexpression_elimination
  do_constant_folding   bool do_constant_folding
  do_function_inlining   bool do_function_inlining
  global_jit_level   GlobalJitLevel global_jit_level
  max_folded_constant_in_bytes   int64 max_folded_constant_in_bytes
  opt_level   Level opt_level

 Class Variables
  DEFAULT   0
  GlobalJitLevel

  L0   -1
  L1   0
  Level

  OFF   -1
  ON_1   1
  ON_2   2


tf.compat.v1.op_scope DEPRECATED. Same as name_scope above, just different argument order.
@tf_contextlib.contextmanager
tf.compat.v1.op_scope(
    values, name, default_name=None
)


tf.compat.v1.pad Pads a tensor.
tf.compat.v1.pad(
    tensor, paddings, mode='CONSTANT', name=None, constant_values=0
)
 This operation pads a tensor according to the paddings you specify. paddings is an integer tensor with shape [n, 2], where n is the rank of tensor. For each dimension D of input, paddings[D, 0] indicates how many values to add before the contents of tensor in that dimension, and paddings[D, 1] indicates how many values to add after the contents of tensor in that dimension. If mode is "REFLECT" then both paddings[D, 0] and paddings[D, 1] must be no greater than tensor.dim_size(D) - 1. If mode is "SYMMETRIC" then both paddings[D, 0] and paddings[D, 1] must be no greater than tensor.dim_size(D). The padded size of each dimension D of the output is: paddings[D, 0] + tensor.dim_size(D) + paddings[D, 1] For example: t = tf.constant([[1, 2, 3], [4, 5, 6]])
paddings = tf.constant([[1, 1,], [2, 2]])
# 'constant_values' is 0.
# rank of 't' is 2.
tf.pad(t, paddings, "CONSTANT")  # [[0, 0, 0, 0, 0, 0, 0],
                                 #  [0, 0, 1, 2, 3, 0, 0],
                                 #  [0, 0, 4, 5, 6, 0, 0],
                                 #  [0, 0, 0, 0, 0, 0, 0]]

tf.pad(t, paddings, "REFLECT")  # [[6, 5, 4, 5, 6, 5, 4],
                                #  [3, 2, 1, 2, 3, 2, 1],
                                #  [6, 5, 4, 5, 6, 5, 4],
                                #  [3, 2, 1, 2, 3, 2, 1]]

tf.pad(t, paddings, "SYMMETRIC")  # [[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]]

 Args
  tensor   A Tensor.
  paddings   A Tensor of type int32.
  mode   One of "CONSTANT", "REFLECT", or "SYMMETRIC" (case-insensitive)
  name   A name for the operation (optional).
  constant_values   In "CONSTANT" mode, the scalar pad value to use. Must be same type as tensor.

 Returns   A Tensor. Has the same type as tensor.

 Raises
  ValueError   When mode is not one of "CONSTANT", "REFLECT", or "SYMMETRIC".


tf.compat.v1.parse_example Parses Example protos into a dict of tensors.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.io.parse_example
tf.compat.v1.parse_example(
    serialized, features, name=None, example_names=None
)
 Parses a number of serialized Example protos given in serialized. We refer to serialized as a batch with batch_size many entries of individual Example protos. example_names may contain descriptive names for the corresponding serialized protos. These may be useful for debugging purposes, but they have no effect on the output. If not None, example_names must be the same length as serialized. This op parses serialized examples into a dictionary mapping keys to Tensor SparseTensor, and RaggedTensor objects. features is a dict from keys to VarLenFeature, SparseFeature, RaggedFeature, and FixedLenFeature objects. Each VarLenFeature and SparseFeature is mapped to a SparseTensor; each FixedLenFeature is mapped to a Tensor; and each RaggedFeature is mapped to a RaggedTensor. Each VarLenFeature maps to a SparseTensor of the specified type representing a ragged matrix. Its indices are [batch, index] where batch identifies the example in serialized, and index is the value's index in the list of values associated with that feature and example. Each SparseFeature maps to a SparseTensor of the specified type representing a Tensor of dense_shape [batch_size] + SparseFeature.size. Its values come from the feature in the examples with key value_key. A values[i] comes from a position k in the feature of an example at batch entry batch. This positional information is recorded in indices[i] as [batch, index_0, index_1, ...] where index_j is the k-th value of the feature in the example at with key SparseFeature.index_key[j]. In other words, we split the indices (except the first index indicating the batch entry) of a SparseTensor by dimension into different features of the Example. Due to its complexity a VarLenFeature should be preferred over a SparseFeature whenever possible. Each FixedLenFeature df maps to a Tensor of the specified type (or tf.float32 if not specified) and shape (serialized.size(),) + df.shape. FixedLenFeature entries with a default_value are optional. With no default value, we will fail if that Feature is missing from any example in serialized. Each FixedLenSequenceFeature df maps to a Tensor of the specified type (or tf.float32 if not specified) and shape (serialized.size(), None) + df.shape. All examples in serialized will be padded with default_value along the second dimension. Each RaggedFeature maps to a RaggedTensor of the specified type. It is formed by stacking the RaggedTensor for each example, where the RaggedTensor for each individual example is constructed using the tensors specified by RaggedTensor.values_key and RaggedTensor.partition. See the tf.io.RaggedFeature documentation for details and examples. Examples: For example, if one expects a tf.float32 VarLenFeature ft and three serialized Examples are provided: serialized = [
  features
    { feature { key: "ft" value { float_list { value: [1.0, 2.0] } } } },
  features
    { feature []},
  features
    { feature { key: "ft" value { float_list { value: [3.0] } } }
]
 then the output will look like: {"ft": SparseTensor(indices=[[0, 0], [0, 1], [2, 0]],
                    values=[1.0, 2.0, 3.0],
                    dense_shape=(3, 2)) }
 If instead a FixedLenSequenceFeature with default_value = -1.0 and shape=[] is used then the output will look like: {"ft": [[1.0, 2.0], [3.0, -1.0]]}
 Given two Example input protos in serialized: [
  features {
    feature { key: "kw" value { bytes_list { value: [ "knit", "big" ] } } }
    feature { key: "gps" value { float_list { value: [] } } }
  },
  features {
    feature { key: "kw" value { bytes_list { value: [ "emmy" ] } } }
    feature { key: "dank" value { int64_list { value: [ 42 ] } } }
    feature { key: "gps" value { } }
  }
]
 And arguments example_names: ["input0", "input1"],
features: {
    "kw": VarLenFeature(tf.string),
    "dank": VarLenFeature(tf.int64),
    "gps": VarLenFeature(tf.float32),
}
 Then the output is a dictionary: {
  "kw": SparseTensor(
      indices=[[0, 0], [0, 1], [1, 0]],
      values=["knit", "big", "emmy"]
      dense_shape=[2, 2]),
  "dank": SparseTensor(
      indices=[[1, 0]],
      values=[42],
      dense_shape=[2, 1]),
  "gps": SparseTensor(
      indices=[],
      values=[],
      dense_shape=[2, 0]),
}
 For dense results in two serialized Examples: [
  features {
    feature { key: "age" value { int64_list { value: [ 0 ] } } }
    feature { key: "gender" value { bytes_list { value: [ "f" ] } } }
   },
   features {
    feature { key: "age" value { int64_list { value: [] } } }
    feature { key: "gender" value { bytes_list { value: [ "f" ] } } }
  }
]
 We can use arguments: example_names: ["input0", "input1"],
features: {
    "age": FixedLenFeature([], dtype=tf.int64, default_value=-1),
    "gender": FixedLenFeature([], dtype=tf.string),
}
 And the expected output is: {
  "age": [[0], [-1]],
  "gender": [["f"], ["f"]],
}
 An alternative to VarLenFeature to obtain a SparseTensor is SparseFeature. For example, given two Example input protos in serialized: [
  features {
    feature { key: "val" value { float_list { value: [ 0.5, -1.0 ] } } }
    feature { key: "ix" value { int64_list { value: [ 3, 20 ] } } }
  },
  features {
    feature { key: "val" value { float_list { value: [ 0.0 ] } } }
    feature { key: "ix" value { int64_list { value: [ 42 ] } } }
  }
]
 And arguments example_names: ["input0", "input1"],
features: {
    "sparse": SparseFeature(
        index_key="ix", value_key="val", dtype=tf.float32, size=100),
}
 Then the output is a dictionary: {
  "sparse": SparseTensor(
      indices=[[0, 3], [0, 20], [1, 42]],
      values=[0.5, -1.0, 0.0]
      dense_shape=[2, 100]),
}
 See the tf.io.RaggedFeature documentation for examples showing how RaggedFeature can be used to obtain RaggedTensors.

 Args
  serialized   A vector (1-D Tensor) of strings, a batch of binary serialized Example protos.
  features   A dict mapping feature keys to FixedLenFeature, VarLenFeature, SparseFeature, and RaggedFeature values.
  example_names   A vector (1-D Tensor) of strings (optional), the names of the serialized protos in the batch.
  name   A name for this operation (optional).

 Returns   A dict mapping feature keys to Tensor, SparseTensor, and RaggedTensor values.

 Raises
  ValueError   if any feature is invalid.


tf.compat.v1.parse_single_example Parses a single Example proto.  View aliases  Compat aliases for migration
See Migration guide for more details. tf.compat.v1.io.parse_single_example
tf.compat.v1.parse_single_example(
    serialized, features, name=None, example_names=None
)
 Similar to parse_example, except: For dense tensors, the returned Tensor is identical to the output of parse_example, except there is no batch dimension, the output shape is the same as the shape given in dense_shape. For SparseTensors, the first (batch) column of the indices matrix is removed (the indices matrix is a column vector), the values vector is unchanged, and the first (batch_size) entry of the shape vector is removed (it is now a single element vector). One might see performance advantages by batching Example protos with parse_example instead of using this function directly.

 Args
  serialized   A scalar string Tensor, a single serialized Example.
  features   A dict mapping feature keys to FixedLenFeature or VarLenFeature values.
  name   A name for this operation (optional).
  example_names   (Optional) A scalar string Tensor, the associated name.

 Returns   A dict mapping feature keys to Tensor and SparseTensor values.

 Raises
  ValueError   if any feature is invalid.


tf.compat.v1.placeholder Inserts a placeholder for a tensor that will be always fed.
tf.compat.v1.placeholder(
    dtype, shape=None, name=None
)
 Key Point: This tensor will produce an error if evaluated. Its value must be fed using the feed_dict optional argument to Session.run(), Tensor.eval(), or Operation.run(). For example: x = tf.compat.v1.placeholder(tf.float32, shape=(1024, 1024))
y = tf.matmul(x, x)

with tf.compat.v1.Session() as sess:
  print(sess.run(y))  # ERROR: will fail because x was not fed.

  rand_array = np.random.rand(1024, 1024)
  print(sess.run(y, feed_dict={x: rand_array}))  # Will succeed.

 Args
  dtype   The type of elements in the tensor to be fed.
  shape   The shape of the tensor to be fed (optional). If the shape is not specified, you can feed a tensor of any shape.
  name   A name for the operation (optional).

 Returns   A Tensor that may be used as a handle for feeding a value, but not evaluated directly.

 Raises
  RuntimeError   if eager execution is enabled    Eager Compatibility Placeholders are not compatible with eager execution.


tf.compat.v1.placeholder_with_default A placeholder op that passes through input when its output is not fed.
tf.compat.v1.placeholder_with_default(
    input, shape, name=None
)

 Args
  input   A Tensor. The default value to produce when output is not fed.
  shape   A tf.TensorShape or list of ints. The (possibly partial) shape of the tensor.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type as input.


tf.compat.v1.Print Prints a list of tensors. (deprecated)
tf.compat.v1.Print(
    input_, data, message=None, first_n=None, summarize=None, name=None
)
 Warning: THIS FUNCTION IS DEPRECATED. It will be removed after 2018-08-20. Instructions for updating: Use tf.print instead of tf.Print. Note that tf.print returns a no-output operator that directly prints the output. Outside of defuns or eager mode, this operator will not be executed unless it is directly specified in session.run or used as a control dependency for other operators. This is only a concern in graph mode. Below is an example of how to ensure tf.print executes in graph mode: This is an identity op (behaves like tf.identity) with the side effect of printing data when evaluating.
Note: This op prints to the standard error. It is not currently compatible with jupyter notebook (printing to the notebook server's output, not into the notebook).

 Args
  input_   A tensor passed through this op.
  data   A list of tensors to print out when op is evaluated.
  message   A string, prefix of the error message.
  first_n   Only log first_n number of times. Negative numbers log always; this is the default.
  summarize   Only print this many entries of each tensor. If None, then a maximum of 3 elements are printed per input tensor.
  name   A name for the operation (optional).

 Returns   A Tensor. Has the same type and contents as input_. sess = tf.compat.v1.Session()
with sess.as_default():
tensor = tf.range(10)
print_op = tf.print(tensor)
with tf.control_dependencies([print_op]):
out = tf.add(tensor, tensor)
sess.run(out)


Module: tf.compat.v1.profiler Public API for tf.profiler namespace. Classes class AdviceProto: A ProtocolMessage class GraphNodeProto: A ProtocolMessage class MultiGraphNodeProto: A ProtocolMessage class OpLogProto: A ProtocolMessage class ProfileOptionBuilder: Option Builder for Profiling API. class Profiler: TensorFlow multi-step profiler. Functions advise(...): Auto profile and advise. profile(...): Profile model. write_op_log(...): Log provided 'op_log', and add additional model information below.


tf.compat.v1.profiler.AdviceProto A ProtocolMessage

 Attributes
  checkers   repeated CheckersEntry checkers    Child Classes class Checker class CheckersEntry


tf.compat.v1.profiler.AdviceProto.Checker A ProtocolMessage

 Attributes
  reports   repeated string reports


tf.compat.v1.profiler.AdviceProto.CheckersEntry A ProtocolMessage

 Attributes
  key   string key
  value   Checker value


tf.compat.v1.profiler.advise Auto profile and advise.
tf.compat.v1.profiler.advise(
    graph=None, run_meta=None, options=_DEFAULT_ADVISE_OPTIONS
)
 Builds profiles and automatically check anomalies of various aspects. For more details: https://github.com/tensorflow/tensorflow/tree/master/tensorflow/core/profiler/README.md

 Args
  graph   tf.Graph. If None and eager execution is not enabled, use default graph.
  run_meta   optional tensorflow.RunMetadata proto. It is necessary to to support run time information profiling, such as time and memory.
  options   see ALL_ADVICE example above. Default checks everything.

 Returns   Returns AdviceProto proto


tf.compat.v1.profiler.GraphNodeProto A ProtocolMessage

 Attributes
  accelerator_exec_micros   int64 accelerator_exec_micros
  children   repeated GraphNodeProto children
  cpu_exec_micros   int64 cpu_exec_micros
  devices   repeated string devices
  exec_micros   int64 exec_micros
  float_ops   int64 float_ops
  input_shapes   repeated InputShapesEntry input_shapes
  name   string name
  output_bytes   int64 output_bytes
  parameters   int64 parameters
  peak_bytes   int64 peak_bytes
  requested_bytes   int64 requested_bytes
  residual_bytes   int64 residual_bytes
  run_count   int64 run_count
  shapes   repeated TensorShapeProto shapes
  tensor_value   TFProfTensorProto tensor_value
  total_accelerator_exec_micros   int64 total_accelerator_exec_micros
  total_cpu_exec_micros   int64 total_cpu_exec_micros
  total_definition_count   int64 total_definition_count
  total_exec_micros   int64 total_exec_micros
  total_float_ops   int64 total_float_ops
  total_output_bytes   int64 total_output_bytes
  total_parameters   int64 total_parameters
  total_peak_bytes   int64 total_peak_bytes
  total_requested_bytes   int64 total_requested_bytes
  total_residual_bytes   int64 total_residual_bytes
  total_run_count   int64 total_run_count    Child Classes class InputShapesEntry


tf.compat.v1.profiler.GraphNodeProto.InputShapesEntry A ProtocolMessage

 Attributes
  key   int32 key
  value   TensorShapeProto value


tf.compat.v1.profiler.MultiGraphNodeProto A ProtocolMessage

 Attributes
  accelerator_exec_micros   int64 accelerator_exec_micros
  children   repeated MultiGraphNodeProto children
  cpu_exec_micros   int64 cpu_exec_micros
  exec_micros   int64 exec_micros
  float_ops   int64 float_ops
  graph_nodes   repeated GraphNodeProto graph_nodes
  name   string name
  output_bytes   int64 output_bytes
  parameters   int64 parameters
  peak_bytes   int64 peak_bytes
  requested_bytes   int64 requested_bytes
  residual_bytes   int64 residual_bytes
  total_accelerator_exec_micros   int64 total_accelerator_exec_micros
  total_cpu_exec_micros   int64 total_cpu_exec_micros
  total_exec_micros   int64 total_exec_micros
  total_float_ops   int64 total_float_ops
  total_output_bytes   int64 total_output_bytes
  total_parameters   int64 total_parameters
  total_peak_bytes   int64 total_peak_bytes
  total_requested_bytes   int64 total_requested_bytes
  total_residual_bytes   int64 total_residual_bytes