neulab/docprompting-conala huggingface dataset:
tf.compat.v1.lookup.StaticHashTable A generic hash table that is immutable once initialized. Inherits From: StaticHashTable 
tf.compat.v1.lookup.StaticHashTable(
    initializer, default_value, name=None
)
 When running in graph mode, you must evaluate the tensor returned by tf.tables_initializer() before evaluating the tensor returned by this class's lookup() method. Example usage in graph mode: keys_tensor = tf.constant([1, 2])
vals_tensor = tf.constant([3, 4])
input_tensor = tf.constant([1, 5])
table = tf.lookup.StaticHashTable(
    tf.lookup.KeyValueTensorInitializer(keys_tensor, vals_tensor), -1)
out = table.lookup(input_tensor)
with tf.Session() as sess:
    sess.run(tf.tables_initializer())
    print(sess.run(out))
 In eager mode, no special code is needed to initialize the table. Example usage in eager mode: tf.enable_eager_execution()
keys_tensor = tf.constant([1, 2])
vals_tensor = tf.constant([3, 4])
input_tensor = tf.constant([1, 5])
table = tf.lookup.StaticHashTable(
    tf.lookup.KeyValueTensorInitializer(keys_tensor, vals_tensor), -1)
print(table.lookup(input_tensor))

 


 Args
  initializer   The table initializer to use. See HashTable kernel for supported key and value types.  
  default_value   The value to use if a key is missing in the table.  
  name   A name for the operation (optional).   
 


 Attributes
  default_value   The default value of the table.  
  initializer  
 
  key_dtype   The table key dtype.  
  name   The name of the table.  
  resource_handle   Returns the resource handle associated with this Resource.  
  value_dtype   The table value dtype.    Methods export View source 
export(
    name=None
)
 Returns tensors of all keys and values in the table.
 


 Args
  name   A name for the operation (optional).   
 


 Returns   A pair of tensors with the first tensor containing all keys and the second tensors containing all values in the table.  
 lookup View source 
lookup(
    keys, name=None
)
 Looks up keys in a table, outputs the corresponding values. The default_value is used for keys not present in the table.
 


 Args
  keys   Keys to look up. May be either a SparseTensor or dense Tensor.  
  name   A name for the operation (optional).   
 


 Returns   A SparseTensor if keys are sparse, a RaggedTensor if keys are ragged, otherwise a dense Tensor.  

 


 Raises
  TypeError   when keys or default_value doesn't match the table data types.    size View source 
size(
    name=None
)
 Compute the number of elements in this table.
 


 Args
  name   A name for the operation (optional).   
 


 Returns   A scalar tensor containing the number of elements in this table.  
 __getitem__ View source 
__getitem__(
    keys
)
 Looks up keys in a table, outputs the corresponding values.
Module: tf.compat.v1.losses Loss operations for use in neural networks. 
Note: All the losses are added to the GraphKeys.LOSSES collection by default.
 Classes class Reduction: Types of loss reduction. Functions absolute_difference(...): Adds an Absolute Difference loss to the training procedure. add_loss(...): Adds a externally defined loss to the collection of losses. compute_weighted_loss(...): Computes the weighted loss. cosine_distance(...): Adds a cosine-distance loss to the training procedure. (deprecated arguments) get_losses(...): Gets the list of losses from the loss_collection. get_regularization_loss(...): Gets the total regularization loss. get_regularization_losses(...): Gets the list of regularization losses. get_total_loss(...): Returns a tensor whose value represents the total loss. hinge_loss(...): Adds a hinge loss to the training procedure. huber_loss(...): Adds a Huber Loss term to the training procedure. log_loss(...): Adds a Log Loss term to the training procedure. mean_pairwise_squared_error(...): Adds a pairwise-errors-squared loss to the training procedure. mean_squared_error(...): Adds a Sum-of-Squares loss to the training procedure. sigmoid_cross_entropy(...): Creates a cross-entropy loss using tf.nn.sigmoid_cross_entropy_with_logits. softmax_cross_entropy(...): Creates a cross-entropy loss using tf.nn.softmax_cross_entropy_with_logits_v2. sparse_softmax_cross_entropy(...): Cross-entropy loss using tf.nn.sparse_softmax_cross_entropy_with_logits.
tf.compat.v1.losses.absolute_difference Adds an Absolute Difference loss to the training procedure. 
tf.compat.v1.losses.absolute_difference(
    labels, predictions, weights=1.0, scope=None,
    loss_collection=tf.GraphKeys.LOSSES, reduction=Reduction.SUM_BY_NONZERO_WEIGHTS
)
 weights acts as a coefficient for the loss. If a scalar is provided, then the loss is simply scaled by the given value. If weights is a Tensor of shape [batch_size], then the total loss for each sample of the batch is rescaled by the corresponding element in the weights vector. If the shape of weights matches the shape of predictions, then the loss of each measurable element of predictions is scaled by the corresponding value of weights.
 


 Args
  labels   The ground truth output tensor, same dimensions as 'predictions'.  
  predictions   The predicted outputs.  
  weights   Optional Tensor whose rank is either 0, or the same rank as labels, and must be broadcastable to labels (i.e., all dimensions must be either 1, or the same as the corresponding losses dimension).  
  scope   The scope for the operations performed in computing the loss.  
  loss_collection   collection to which this loss will be added.  
  reduction   Type of reduction to apply to loss.   
 


 Returns   Weighted loss float Tensor. If reduction is NONE, this has the same shape as labels; otherwise, it is scalar.  

 


 Raises
  ValueError   If the shape of predictions doesn't match that of labels or if the shape of weights is invalid or if labels or predictions is None.    Eager Compatibility The loss_collection argument is ignored when executing eagerly. Consider holding on to the return value or collecting losses via a tf.keras.Model.
tf.compat.v1.losses.add_loss Adds a externally defined loss to the collection of losses. 
tf.compat.v1.losses.add_loss(
    loss, loss_collection=tf.GraphKeys.LOSSES
)

 


 Args
  loss   A loss Tensor.  
  loss_collection   Optional collection to add the loss to.
tf.compat.v1.losses.compute_weighted_loss Computes the weighted loss. 
tf.compat.v1.losses.compute_weighted_loss(
    losses, weights=1.0, scope=None, loss_collection=tf.GraphKeys.LOSSES,
    reduction=Reduction.SUM_BY_NONZERO_WEIGHTS
)

 


 Args
  losses   Tensor of shape [batch_size, d1, ... dN].  
  weights   Optional Tensor whose rank is either 0, or the same rank as losses, and must be broadcastable to losses (i.e., all dimensions must be either 1, or the same as the corresponding losses dimension).  
  scope   the scope for the operations performed in computing the loss.  
  loss_collection   the loss will be added to these collections.  
  reduction   Type of reduction to apply to loss.   
 


 Returns   Weighted loss Tensor of the same type as losses. If reduction is NONE, this has the same shape as losses; otherwise, it is scalar.  

 


 Raises
  ValueError   If weights is None or the shape is not compatible with losses, or if the number of dimensions (rank) of either losses or weights is missing.    Note: When calculating the gradient of a weighted loss contributions from both losses and weights are considered. If your weights depend on some model parameters but you do not want this to affect the loss gradient, you need to apply tf.stop_gradient to weights before passing them to compute_weighted_loss. Eager Compatibility The loss_collection argument is ignored when executing eagerly. Consider holding on to the return value or collecting losses via a tf.keras.Model.
tf.compat.v1.losses.cosine_distance Adds a cosine-distance loss to the training procedure. (deprecated arguments) 
tf.compat.v1.losses.cosine_distance(
    labels, predictions, axis=None, weights=1.0, scope=None,
    loss_collection=tf.GraphKeys.LOSSES, reduction=Reduction.SUM_BY_NONZERO_WEIGHTS,
    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 Note that the function assumes that predictions and labels are already unit-normalized.
 


 Args
  labels   Tensor whose shape matches 'predictions'  
  predictions   An arbitrary matrix.  
  axis   The dimension along which the cosine distance is computed.  
  weights   Optional Tensor whose rank is either 0, or the same rank as labels, and must be broadcastable to labels (i.e., all dimensions must be either 1, or the same as the corresponding losses dimension).  
  scope   The scope for the operations performed in computing the loss.  
  loss_collection   collection to which this loss will be added.  
  reduction   Type of reduction to apply to loss.  
  dim   The old (deprecated) name for axis.   
 


 Returns   Weighted loss float Tensor. If reduction is NONE, this has the same shape as labels; otherwise, it is scalar.  

 


 Raises
  ValueError   If predictions shape doesn't match labels shape, or axis, labels, predictions or weights is None.    Eager Compatibility The loss_collection argument is ignored when executing eagerly. Consider holding on to the return value or collecting losses via a tf.keras.Model.
tf.compat.v1.losses.get_losses Gets the list of losses from the loss_collection. 
tf.compat.v1.losses.get_losses(
    scope=None, loss_collection=tf.GraphKeys.LOSSES
)

 


 Args
  scope   An optional scope name for filtering the losses to return.  
  loss_collection   Optional losses collection.   
 


 Returns   a list of loss tensors.
tf.compat.v1.losses.get_regularization_loss Gets the total regularization loss. 
tf.compat.v1.losses.get_regularization_loss(
    scope=None, name='total_regularization_loss'
)

 


 Args
  scope   An optional scope name for filtering the losses to return.  
  name   The name of the returned tensor.   
 


 Returns   A scalar regularization loss.
tf.compat.v1.losses.get_regularization_losses Gets the list of regularization losses. 
tf.compat.v1.losses.get_regularization_losses(
    scope=None
)

 


 Args
  scope   An optional scope name for filtering the losses to return.   
 


 Returns   A list of regularization losses as Tensors.
tf.compat.v1.losses.get_total_loss Returns a tensor whose value represents the total loss. 
tf.compat.v1.losses.get_total_loss(
    add_regularization_losses=True, name='total_loss', scope=None
)
 In particular, this adds any losses you have added with tf.add_loss() to any regularization losses that have been added by regularization parameters on layers constructors e.g. tf.layers. Be very sure to use this if you are constructing a loss_op manually. Otherwise regularization arguments on tf.layers methods will not function.
 


 Args
  add_regularization_losses   A boolean indicating whether or not to use the regularization losses in the sum.  
  name   The name of the returned tensor.  
  scope   An optional scope name for filtering the losses to return. Note that this filters the losses added with tf.add_loss() as well as the regularization losses to that scope.   
 


 Returns   A Tensor whose value represents the total loss.  

 


 Raises
  ValueError   if losses is not iterable.
tf.compat.v1.losses.hinge_loss Adds a hinge loss to the training procedure. 
tf.compat.v1.losses.hinge_loss(
    labels, logits, weights=1.0, scope=None, loss_collection=tf.GraphKeys.LOSSES,
    reduction=Reduction.SUM_BY_NONZERO_WEIGHTS
)

 


 Args
  labels   The ground truth output tensor. Its shape should match the shape of logits. The values of the tensor are expected to be 0.0 or 1.0. Internally the {0,1} labels are converted to {-1,1} when calculating the hinge loss.  
  logits   The logits, a float tensor. Note that logits are assumed to be unbounded and 0-centered. A value > 0 (resp. < 0) is considered a positive (resp. negative) binary prediction.  
  weights   Optional Tensor whose rank is either 0, or the same rank as labels, and must be broadcastable to labels (i.e., all dimensions must be either 1, or the same as the corresponding losses dimension).  
  scope   The scope for the operations performed in computing the loss.  
  loss_collection   collection to which the loss will be added.  
  reduction   Type of reduction to apply to loss.   
 


 Returns   Weighted loss float Tensor. If reduction is NONE, this has the same shape as labels; otherwise, it is scalar.  

 


 Raises
  ValueError   If the shapes of logits and labels don't match or if labels or logits is None.    Eager Compatibility The loss_collection argument is ignored when executing eagerly. Consider holding on to the return value or collecting losses via a tf.keras.Model.
tf.compat.v1.losses.huber_loss Adds a Huber Loss term to the training procedure. 
tf.compat.v1.losses.huber_loss(
    labels, predictions, weights=1.0, delta=1.0, scope=None,
    loss_collection=tf.GraphKeys.LOSSES, reduction=Reduction.SUM_BY_NONZERO_WEIGHTS
)
 For each value x in error=labels-predictions, the following is calculated: 0.5 * x^2                  if |x| <= d
0.5 * d^2 + d * (|x| - d)  if |x| > d
 where d is delta. weights acts as a coefficient for the loss. If a scalar is provided, then the loss is simply scaled by the given value. If weights is a tensor of size [batch_size], then the total loss for each sample of the batch is rescaled by the corresponding element in the weights vector. If the shape of weights matches the shape of predictions, then the loss of each measurable element of predictions is scaled by the corresponding value of weights.
 


 Args
  labels   The ground truth output tensor, same dimensions as 'predictions'.  
  predictions   The predicted outputs.  
  weights   Optional Tensor whose rank is either 0, or the same rank as labels, and must be broadcastable to labels (i.e., all dimensions must be either 1, or the same as the corresponding losses dimension).  
  delta   float, the point where the huber loss function changes from a quadratic to linear.  
  scope   The scope for the operations performed in computing the loss.  
  loss_collection   collection to which the loss will be added.  
  reduction   Type of reduction to apply to loss.   
 


 Returns   Weighted loss float Tensor. If reduction is NONE, this has the same shape as labels; otherwise, it is scalar.  

 


 Raises
  ValueError   If the shape of predictions doesn't match that of labels or if the shape of weights is invalid. Also if labels or predictions is None.    Eager Compatibility The loss_collection argument is ignored when executing eagerly. Consider holding on to the return value or collecting losses via a tf.keras.Model.
tf.compat.v1.losses.log_loss Adds a Log Loss term to the training procedure. 
tf.compat.v1.losses.log_loss(
    labels, predictions, weights=1.0, epsilon=1e-07, scope=None,
    loss_collection=tf.GraphKeys.LOSSES, reduction=Reduction.SUM_BY_NONZERO_WEIGHTS
)
 weights acts as a coefficient for the loss. If a scalar is provided, then the loss is simply scaled by the given value. If weights is a tensor of size [batch_size], then the total loss for each sample of the batch is rescaled by the corresponding element in the weights vector. If the shape of weights matches the shape of predictions, then the loss of each measurable element of predictions is scaled by the corresponding value of weights.
 


 Args
  labels   The ground truth output tensor, same dimensions as 'predictions'.  
  predictions   The predicted outputs.  
  weights   Optional Tensor whose rank is either 0, or the same rank as labels, and must be broadcastable to labels (i.e., all dimensions must be either 1, or the same as the corresponding losses dimension).  
  epsilon   A small increment to add to avoid taking a log of zero.  
  scope   The scope for the operations performed in computing the loss.  
  loss_collection   collection to which the loss will be added.  
  reduction   Type of reduction to apply to loss.   
 


 Returns   Weighted loss float Tensor. If reduction is NONE, this has the same shape as labels; otherwise, it is scalar.  

 


 Raises
  ValueError   If the shape of predictions doesn't match that of labels or if the shape of weights is invalid. Also if labels or predictions is None.    Eager Compatibility The loss_collection argument is ignored when executing eagerly. Consider holding on to the return value or collecting losses via a tf.keras.Model.
tf.compat.v1.losses.mean_pairwise_squared_error Adds a pairwise-errors-squared loss to the training procedure. 
tf.compat.v1.losses.mean_pairwise_squared_error(
    labels, predictions, weights=1.0, scope=None,
    loss_collection=tf.GraphKeys.LOSSES
)
 Unlike mean_squared_error, which is a measure of the differences between corresponding elements of predictions and labels, mean_pairwise_squared_error is a measure of the differences between pairs of corresponding elements of predictions and labels. For example, if labels=[a, b, c] and predictions=[x, y, z], there are three pairs of differences are summed to compute the loss: loss = [ ((a-b) - (x-y)).^2 + ((a-c) - (x-z)).^2 + ((b-c) - (y-z)).^2 ] / 3 Note that since the inputs are of shape [batch_size, d0, ... dN], the corresponding pairs are computed within each batch sample but not across samples within a batch. For example, if predictions represents a batch of 16 grayscale images of dimension [batch_size, 100, 200], then the set of pairs is drawn from each image, but not across images. weights acts as a coefficient for the loss. If a scalar is provided, then the loss is simply scaled by the given value. If weights is a tensor of size [batch_size], then the total loss for each sample of the batch is rescaled by the corresponding element in the weights vector.
 


 Args
  labels   The ground truth output tensor, whose shape must match the shape of predictions.  
  predictions   The predicted outputs, a tensor of size [batch_size, d0, .. dN] where N+1 is the total number of dimensions in predictions.  
  weights   Coefficients for the loss a scalar, a tensor of shape [batch_size] or a tensor whose shape matches predictions.  
  scope   The scope for the operations performed in computing the loss.  
  loss_collection   collection to which the loss will be added.   
 


 Returns   A scalar Tensor that returns the weighted loss.  

 


 Raises
  ValueError   If the shape of predictions doesn't match that of labels or if the shape of weights is invalid. Also if labels or predictions is None.    Eager Compatibility The loss_collection argument is ignored when executing eagerly. Consider holding on to the return value or collecting losses via a tf.keras.Model.
tf.compat.v1.losses.mean_squared_error Adds a Sum-of-Squares loss to the training procedure. 
tf.compat.v1.losses.mean_squared_error(
    labels, predictions, weights=1.0, scope=None,
    loss_collection=tf.GraphKeys.LOSSES, reduction=Reduction.SUM_BY_NONZERO_WEIGHTS
)
 weights acts as a coefficient for the loss. If a scalar is provided, then the loss is simply scaled by the given value. If weights is a tensor of size [batch_size], then the total loss for each sample of the batch is rescaled by the corresponding element in the weights vector. If the shape of weights matches the shape of predictions, then the loss of each measurable element of predictions is scaled by the corresponding value of weights.
 


 Args
  labels   The ground truth output tensor, same dimensions as 'predictions'.  
  predictions   The predicted outputs.  
  weights   Optional Tensor whose rank is either 0, or the same rank as labels, and must be broadcastable to labels (i.e., all dimensions must be either 1, or the same as the corresponding losses dimension).  
  scope   The scope for the operations performed in computing the loss.  
  loss_collection   collection to which the loss will be added.  
  reduction   Type of reduction to apply to loss.   
 


 Returns   Weighted loss float Tensor. If reduction is NONE, this has the same shape as labels; otherwise, it is scalar.  

 


 Raises
  ValueError   If the shape of predictions doesn't match that of labels or if the shape of weights is invalid. Also if labels or predictions is None.    Eager Compatibility The loss_collection argument is ignored when executing eagerly. Consider holding on to the return value or collecting losses via a tf.keras.Model.
tf.compat.v1.losses.Reduction Types of loss reduction. Contains the following values:  
NONE: Un-reduced weighted losses with the same shape as input. 
SUM: Scalar sum of weighted losses. 
MEAN: Scalar SUM divided by sum of weights. DEPRECATED. 
SUM_OVER_BATCH_SIZE: Scalar SUM divided by number of elements in losses. 
SUM_OVER_NONZERO_WEIGHTS: Scalar SUM divided by number of non-zero weights. DEPRECATED. 
SUM_BY_NONZERO_WEIGHTS: Same as SUM_OVER_NONZERO_WEIGHTS. DEPRECATED.  Methods all View source 
@classmethod
all()
 validate View source 
@classmethod
validate(
    key
)

 


 Class Variables
  MEAN   'weighted_mean'  
  NONE   'none'  
  SUM   'weighted_sum'  
  SUM_BY_NONZERO_WEIGHTS   'weighted_sum_by_nonzero_weights'  
  SUM_OVER_BATCH_SIZE   'weighted_sum_over_batch_size'  
  SUM_OVER_NONZERO_WEIGHTS   'weighted_sum_by_nonzero_weights'
tf.compat.v1.losses.sigmoid_cross_entropy Creates a cross-entropy loss using tf.nn.sigmoid_cross_entropy_with_logits. 
tf.compat.v1.losses.sigmoid_cross_entropy(
    multi_class_labels, logits, weights=1.0, label_smoothing=0, scope=None,
    loss_collection=tf.GraphKeys.LOSSES, reduction=Reduction.SUM_BY_NONZERO_WEIGHTS
)
 weights acts as a coefficient for the loss. If a scalar is provided, then the loss is simply scaled by the given value. If weights is a tensor of shape [batch_size], then the loss weights apply to each corresponding sample. If label_smoothing is nonzero, smooth the labels towards 1/2: new_multiclass_labels = multiclass_labels * (1 - label_smoothing)

                        + 0.5 * label_smoothing

 


 Args
  multi_class_labels   [batch_size, num_classes] target integer labels in {0, 1}.  
  logits   Float [batch_size, num_classes] logits outputs of the network.  
  weights   Optional Tensor whose rank is either 0, or the same rank as multi_class_labels, and must be broadcastable to multi_class_labels (i.e., all dimensions must be either 1, or the same as the corresponding losses dimension).  
  label_smoothing   If greater than 0 then smooth the labels.  
  scope   The scope for the operations performed in computing the loss.  
  loss_collection   collection to which the loss will be added.  
  reduction   Type of reduction to apply to loss.   
 


 Returns   Weighted loss Tensor of the same type as logits. If reduction is NONE, this has the same shape as logits; otherwise, it is scalar.  

 


 Raises
  ValueError   If the shape of logits doesn't match that of multi_class_labels or if the shape of weights is invalid, or if weights is None. Also if multi_class_labels or logits is None.    Eager Compatibility The loss_collection argument is ignored when executing eagerly. Consider holding on to the return value or collecting losses via a tf.keras.Model.