()
Validate graph before running distributed training.

  Raises:
    ValueError: If the graph seems invalid for running on device
Validate graph before running distributed training.
Validate graph before running distributed training .
def _validate_tpu_training_graph():
  """Validate graph before running distributed training.

  Raises:
    ValueError: If the graph seems invalid for running on device
  """
  operations = ops.get_default_graph().get_operations()

  # Check if there is atleast one CrossReplicaSum operation in the graph
  # This should be introduced by using the CrossShardOptimizer wrapper
  cross_replica_sum_ops = [
      o for o in operations if o.type == _CROSS_REPLICA_SUM_OP
  ]
  if not cross_replica_sum_ops:
    raise ValueError(
        'CrossShardOptimizer must be used for model training on TPUs.')
def _validate_tpu_training_graph ( ) : operations = ops . get_default_graph ( ) . get_operations ( ) # Check if there is atleast one CrossReplicaSum operation in the graph # This should be introduced by using the CrossShardOptimizer wrapper cross_replica_sum_ops = [ o for o in operations if o . type == _CROSS_REPLICA_SUM_OP ] if not cross_replica_sum_ops : raise ValueError ( 'CrossShardOptimizer must be used for model training on TPUs.' )