Commit c8a12135 authored by A. Unique TensorFlower's avatar A. Unique TensorFlower
Browse files

Merge pull request #9020 from srihari-humbarwadi:master

PiperOrigin-RevId: 324245883
parents 4ebcdbf0 0e9d5840
...@@ -63,8 +63,8 @@ def metrics_as_dict(metric): ...@@ -63,8 +63,8 @@ def metrics_as_dict(metric):
"""Puts input metric(s) into a list. """Puts input metric(s) into a list.
Args: Args:
metric: metric(s) to be put into the list. `metric` could be a object, a metric: metric(s) to be put into the list. `metric` could be an object, a
list or a dict of tf.keras.metrics.Metric or has the `required_method`. list, or a dict of tf.keras.metrics.Metric or has the `required_method`.
Returns: Returns:
A dictionary of valid metrics. A dictionary of valid metrics.
...@@ -351,7 +351,8 @@ class DistributedExecutor(object): ...@@ -351,7 +351,8 @@ class DistributedExecutor(object):
train_input_fn: (params: dict) -> tf.data.Dataset training data input train_input_fn: (params: dict) -> tf.data.Dataset training data input
function. function.
eval_input_fn: (Optional) same type as train_input_fn. If not None, will eval_input_fn: (Optional) same type as train_input_fn. If not None, will
trigger evaluting metric on eval data. If None, will not run eval step. trigger evaluating metric on eval data. If None, will not run the eval
step.
model_dir: the folder path for model checkpoints. model_dir: the folder path for model checkpoints.
total_steps: total training steps. total_steps: total training steps.
iterations_per_loop: train steps per loop. After each loop, this job will iterations_per_loop: train steps per loop. After each loop, this job will
...@@ -672,7 +673,7 @@ class DistributedExecutor(object): ...@@ -672,7 +673,7 @@ class DistributedExecutor(object):
raise ValueError('if `eval_metric_fn` is specified, ' raise ValueError('if `eval_metric_fn` is specified, '
'eval_metric_fn must be a callable.') 'eval_metric_fn must be a callable.')
old_phrase = tf.keras.backend.learning_phase() old_phase = tf.keras.backend.learning_phase()
tf.keras.backend.set_learning_phase(0) tf.keras.backend.set_learning_phase(0)
params = self._params params = self._params
strategy = self._strategy strategy = self._strategy
...@@ -710,7 +711,7 @@ class DistributedExecutor(object): ...@@ -710,7 +711,7 @@ class DistributedExecutor(object):
summary_writer(metrics=eval_metric_result, step=current_step) summary_writer(metrics=eval_metric_result, step=current_step)
reset_states(eval_metric) reset_states(eval_metric)
tf.keras.backend.set_learning_phase(old_phrase) tf.keras.backend.set_learning_phase(old_phase)
return eval_metric_result, current_step return eval_metric_result, current_step
def predict(self): def predict(self):
...@@ -760,7 +761,7 @@ class ExecutorBuilder(object): ...@@ -760,7 +761,7 @@ class ExecutorBuilder(object):
Args: Args:
strategy_type: string. One of 'tpu', 'mirrored', 'multi_worker_mirrored'. strategy_type: string. One of 'tpu', 'mirrored', 'multi_worker_mirrored'.
If None. User is responsible to set the strategy before calling If None, the user is responsible to set the strategy before calling
build_executor(...). build_executor(...).
strategy_config: necessary config for constructing the proper Strategy. strategy_config: necessary config for constructing the proper Strategy.
Check strategy_flags_dict() for examples of the structure. Check strategy_flags_dict() for examples of the structure.
......
...@@ -449,7 +449,7 @@ class RetinanetBoxLoss(object): ...@@ -449,7 +449,7 @@ class RetinanetBoxLoss(object):
num_positives: number of positive examples in the minibatch. num_positives: number of positive examples in the minibatch.
Returns: Returns:
an integar tensor representing total box regression loss. an integer tensor representing total box regression loss.
""" """
# Sums all positives in a batch for normalization and avoids zero # Sums all positives in a batch for normalization and avoids zero
# num_positives_sum, which would lead to inf loss during training # num_positives_sum, which would lead to inf loss during training
...@@ -457,7 +457,6 @@ class RetinanetBoxLoss(object): ...@@ -457,7 +457,6 @@ class RetinanetBoxLoss(object):
box_losses = [] box_losses = []
for level in box_outputs.keys(): for level in box_outputs.keys():
# Onehot encoding for classification labels.
box_targets_l = labels[level] box_targets_l = labels[level]
box_losses.append( box_losses.append(
self.box_loss(box_outputs[level], box_targets_l, num_positives_sum)) self.box_loss(box_outputs[level], box_targets_l, num_positives_sum))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment