[TOC]
Ops for building neural network losses.
Adds an Absolute Difference loss to the training procedure. (deprecated)
THIS FUNCTION IS DEPRECATED. It will be removed after 2016-12-30. Instructions for updating: Use tf.losses.absolute_difference instead.
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.
predictions: The predicted outputs.labels: The ground truth output tensor, same dimensions as 'predictions'.weights: Coefficients for the loss a scalar, a tensor of shape [batch_size] or a tensor whose shape matchespredictions.scope: The scope for the operations performed in computing the loss.
A scalar Tensor representing the loss value.
ValueError: If the shape ofpredictionsdoesn't match that oflabelsor if the shape ofweightsis invalid.
Adds a externally defined loss to the collection of losses. (deprecated)
THIS FUNCTION IS DEPRECATED. It will be removed after 2016-12-30. Instructions for updating: Use tf.losses.add_loss instead.
loss: A lossTensor.loss_collection: Optional collection to add the loss to.
Computes the weighted loss. (deprecated)
THIS FUNCTION IS DEPRECATED. It will be removed after 2016-12-30. Instructions for updating: Use tf.losses.compute_weighted_loss instead.
losses: A tensor of size [batch_size, d1, ... dN].weights: A tensor of size [1] or [batch_size, d1, ... dK] where K < N.scope: the scope for the operations performed in computing the loss.
A scalar Tensor that returns the weighted loss.
ValueError: IfweightsisNoneor the shape is not compatible withlosses, or if the number of dimensions (rank) of eitherlossesorweightsis missing.
Adds a cosine-distance loss to the training procedure. (deprecated)
THIS FUNCTION IS DEPRECATED. It will be removed after 2016-12-30. Instructions for updating: Use tf.losses.cosine_distance instead.
Note that the function assumes that predictions and labels are already
unit-normalized.
predictions: An arbitrary matrix.labels: ATensorwhose shape matches 'predictions'dim: The dimension along which the cosine distance is computed.weights: Coefficients for the loss a scalar, a tensor of shape [batch_size] or a tensor whose shape matchespredictions.scope: The scope for the operations performed in computing the loss.
A scalar Tensor representing the loss value.
ValueError: Ifpredictionsshape doesn't matchlabelsshape, orweightsisNone.
Gets the list of losses from the loss_collection. (deprecated)
THIS FUNCTION IS DEPRECATED. It will be removed after 2016-12-30. Instructions for updating: Use tf.losses.get_losses instead.
scope: an optional scope for filtering the losses to return.loss_collection: Optional losses collection.
a list of loss tensors.
Gets the regularization losses. (deprecated)
THIS FUNCTION IS DEPRECATED. It will be removed after 2016-12-30. Instructions for updating: Use tf.losses.get_regularization_losses instead.
scope: an optional scope for filtering the losses to return.
A list of loss variables.
Returns a tensor whose value represents the total loss. (deprecated)
THIS FUNCTION IS DEPRECATED. It will be removed after 2016-12-30. Instructions for updating: Use tf.losses.get_total_loss instead.
Notice that the function adds the given losses to the regularization losses.
add_regularization_losses: A boolean indicating whether or not to use the regularization losses in the sum.name: The name of the returned tensor.
A Tensor whose value represents the total loss.
ValueError: iflossesis not iterable.
Method that returns the loss tensor for hinge loss. (deprecated)
THIS FUNCTION IS DEPRECATED. It will be removed after 2016-12-30. Instructions for updating: Use tf.losses.hinge_loss instead.
logits: The logits, a float tensor.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.scope: The scope for the operations performed in computing the loss.
A Tensor of same shape as logits and labels representing the loss
values across the batch.
ValueError: If the shapes oflogitsandlabelsdon't match.
Adds a Log Loss term to the training procedure. (deprecated)
THIS FUNCTION IS DEPRECATED. It will be removed after 2016-12-30. Instructions for updating: Use tf.losses.log_loss instead.
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.
predictions: The predicted outputs.labels: The ground truth output tensor, same dimensions as 'predictions'.weights: Coefficients for the loss a scalar, a tensor of shape [batch_size] or a tensor whose shape matchespredictions.epsilon: A small increment to add to avoid taking a log of zero.scope: The scope for the operations performed in computing the loss.
A scalar Tensor representing the loss value.
ValueError: If the shape ofpredictionsdoesn't match that oflabelsor if the shape ofweightsis invalid.
Adds a pairwise-errors-squared loss to the training procedure. (deprecated)
THIS FUNCTION IS DEPRECATED. It will be removed after 2016-12-30. Instructions for updating: Use tf.losses.mean_pairwise_squared_error instead.
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 size [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.
predictions: The predicted outputs, a tensor of size [batch_size, d0, .. dN] where N+1 is the total number of dimensions inpredictions.labels: The ground truth output tensor, whose shape must match the shape of thepredictionstensor.weights: Coefficients for the loss a scalar, a tensor of shape [batch_size] or a tensor whose shape matchespredictions.scope: The scope for the operations performed in computing the loss.
A scalar Tensor representing the loss value.
ValueError: If the shape ofpredictionsdoesn't match that oflabelsor if the shape ofweightsis invalid.
Adds a Sum-of-Squares loss to the training procedure. (deprecated)
THIS FUNCTION IS DEPRECATED. It will be removed after 2016-12-30. Instructions for updating: Use tf.losses.mean_squared_error instead.
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.
predictions: The predicted outputs.labels: The ground truth output tensor, same dimensions as 'predictions'.weights: Coefficients for the loss a scalar, a tensor of shape [batch_size] or a tensor whose shape matchespredictions.scope: The scope for the operations performed in computing the loss.
A scalar Tensor representing the loss value.
ValueError: If the shape ofpredictionsdoesn't match that oflabelsor if the shape ofweightsis invalid.
Creates a cross-entropy loss using tf.nn.sigmoid_cross_entropy_with_logits. (deprecated)
THIS FUNCTION IS DEPRECATED. It will be removed after 2016-12-30. Instructions for updating: Use tf.losses.sigmoid_cross_entropy instead.
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 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
logits: [batch_size, num_classes] logits outputs of the network .multi_class_labels: [batch_size, num_classes] labels in (0, 1).weights: Coefficients for the loss. The tensor must be a scalar, a tensor of shape [batch_size] or shape [batch_size, num_classes].label_smoothing: If greater than 0 then smooth the labels.scope: The scope for the operations performed in computing the loss.
A scalar Tensor representing the loss value.
ValueError: If the shape oflogitsdoesn't match that ofmulti_class_labelsor if the shape ofweightsis invalid, or ifweightsis None.
Creates a cross-entropy loss using tf.nn.softmax_cross_entropy_with_logits. (deprecated)
THIS FUNCTION IS DEPRECATED. It will be removed after 2016-12-30. Instructions for updating: Use tf.losses.softmax_cross_entropy instead.
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 loss weights apply to each
corresponding sample.
If label_smoothing is nonzero, smooth the labels towards 1/num_classes:
new_onehot_labels = onehot_labels * (1 - label_smoothing)
+ label_smoothing / num_classes
logits: [batch_size, num_classes] logits outputs of the network .onehot_labels: [batch_size, num_classes] one-hot-encoded labels.weights: Coefficients for the loss. The tensor must be a scalar or a tensor of shape [batch_size].label_smoothing: If greater than 0 then smooth the labels.scope: the scope for the operations performed in computing the loss.
A scalar Tensor representing the mean loss value.
ValueError: If the shape oflogitsdoesn't match that ofonehot_labelsor if the shape ofweightsis invalid or ifweightsis None.
Cross-entropy loss using tf.nn.sparse_softmax_cross_entropy_with_logits. (deprecated)
THIS FUNCTION IS DEPRECATED. It will be removed after 2016-12-30. Instructions for updating: Use tf.losses.sparse_softmax_cross_entropy instead.
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 loss weights apply to each
corresponding sample.
logits: [batch_size, num_classes] logits outputs of the network .labels: [batch_size, 1] or [batch_size] labels of dtypeint32orint64in the range[0, num_classes).weights: Coefficients for the loss. The tensor must be a scalar or a tensor of shape [batch_size] or [batch_size, 1].scope: the scope for the operations performed in computing the loss.
A scalar Tensor representing the mean loss value.
ValueError: If the shapes oflogits,labels, andweightsare incompatible, or ifweightsis None.