aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'tensorflow/contrib')
-rw-r--r--tensorflow/contrib/losses/python/losses/loss_ops.py9
-rw-r--r--tensorflow/contrib/metrics/python/ops/metric_ops.py20
-rw-r--r--tensorflow/contrib/rate/rate.py4
3 files changed, 16 insertions, 17 deletions
diff --git a/tensorflow/contrib/losses/python/losses/loss_ops.py b/tensorflow/contrib/losses/python/losses/loss_ops.py
index 29f7953c3b..8a0932c376 100644
--- a/tensorflow/contrib/losses/python/losses/loss_ops.py
+++ b/tensorflow/contrib/losses/python/losses/loss_ops.py
@@ -78,8 +78,9 @@ def _safe_mean(losses, num_present):
then zero is returned.
"""
total_loss = math_ops.reduce_sum(losses)
- return math_ops.div_no_nan(total_loss, num_present,
- negative_to_zero=True, name="value")
+ return math_ops.div_no_nan(total_loss,
+ math_ops.maximum(num_present, 0),
+ name="value")
@deprecated("2016-12-30", "Use tf.losses.compute_weighted_loss instead.")
@@ -585,14 +586,12 @@ def mean_pairwise_squared_error(predictions,
num_present_per_batch = _num_present(diffs, weights, per_batch=True)
term1 = 2.0 * math_ops.div_no_nan(sum_squares_diff_per_batch,
- num_present_per_batch,
- negative_to_zero=True,
+ math_ops.maximum(num_present_per_batch),
name="value")
sum_diff = math_ops.reduce_sum(diffs, reduction_indices=reduction_indices)
term2 = 2.0 * math_ops.div_no_nan(math_ops.square(sum_diff),
math_ops.square(num_present_per_batch),
- negative_to_zero=True,
name="value")
loss = _scale_losses(term1 - term2, weights)
diff --git a/tensorflow/contrib/metrics/python/ops/metric_ops.py b/tensorflow/contrib/metrics/python/ops/metric_ops.py
index d972e7da53..bfef0816aa 100644
--- a/tensorflow/contrib/metrics/python/ops/metric_ops.py
+++ b/tensorflow/contrib/metrics/python/ops/metric_ops.py
@@ -3188,12 +3188,12 @@ def streaming_covariance(predictions,
# We update the means by Delta=Error*BatchCount/(BatchCount+PrevCount)
# batch_mean_prediction is E[x_B] in the update equation
batch_mean_prediction = math_ops.div_no_nan(
- math_ops.reduce_sum(weighted_predictions), batch_count,
- negative_to_zero=True,
+ math_ops.reduce_sum(weighted_predictions),
+ math_ops.maximum(batch_count, 0),
name='batch_mean_prediction')
delta_mean_prediction = math_ops.div_no_nan(
- (batch_mean_prediction - mean_prediction) * batch_count, update_count,
- negative_to_zero=True,
+ (batch_mean_prediction - mean_prediction) * batch_count,
+ math_ops.maximum(update_count, 0),
name='delta_mean_prediction')
update_mean_prediction = state_ops.assign_add(mean_prediction,
delta_mean_prediction)
@@ -3202,12 +3202,12 @@ def streaming_covariance(predictions,
# batch_mean_label is E[y_B] in the update equation
batch_mean_label = math_ops.div_no_nan(
- math_ops.reduce_sum(weighted_labels), batch_count,
- negative_to_zero=True,
+ math_ops.reduce_sum(weighted_labels),
+ math_ops.maximum(batch_count, 0),
name='batch_mean_label')
delta_mean_label = math_ops.div_no_nan(
- (batch_mean_label - mean_label) * batch_count, update_count,
- negative_to_zero=True,
+ (batch_mean_label - mean_label) * batch_count,
+ math_ops.maximum(update_count, 0),
name='delta_mean_label')
update_mean_label = state_ops.assign_add(mean_label, delta_mean_label)
# prev_mean_label is E[y_A] in the update equation
@@ -3871,8 +3871,8 @@ def cohen_kappa(labels,
total = math_ops.reduce_sum(pe_row)
pe_sum = math_ops.reduce_sum(
math_ops.div_no_nan(
- pe_row * pe_col, total,
- negative_to_zero=True,
+ pe_row * pe_col,
+ math_ops.maximum(total, 0),
name=None))
po_sum, pe_sum, total = (math_ops.to_double(po_sum),
math_ops.to_double(pe_sum),
diff --git a/tensorflow/contrib/rate/rate.py b/tensorflow/contrib/rate/rate.py
index 68f5a6e58a..489d5cce78 100644
--- a/tensorflow/contrib/rate/rate.py
+++ b/tensorflow/contrib/rate/rate.py
@@ -141,6 +141,6 @@ class Rate(object):
state_ops.assign(self.prev_values, values)
state_ops.assign(self.prev_denominator, denominator)
- return math_ops.div_no_nan(self.numer, self.denom,
- negative_to_zero=True,
+ return math_ops.div_no_nan(self.numer,
+ math_op.maximum(self.denom, 0),
name="safe_rate")