(name=None)
return tf.stack([op_seed, _RANDOM_OFFSET_TENSOR])
Get a deterministic random seed for stateless generators.

  Args:
    name: Name of the operation that will use the seed. If None a unique name
        will be determined.

  Returns:
    An integer`Tensor` of shape (2,) with the seed for this op and the global
    random offset.
Get a deterministic random seed for stateless generators.
Get a deterministic random seed for stateless generators .
def _get_seed(name=None):
  """Get a deterministic random seed for stateless generators.

  Args:
    name: Name of the operation that will use the seed. If None a unique name
        will be determined.

  Returns:
    An integer`Tensor` of shape (2,) with the seed for this op and the global
    random offset.
  """
  if _RANDOM_OFFSET_TENSOR is None:
    raise ValueError("_RANDOM_OFFSET_TENSOR is None. Did you call "
                     "set_random_offset_from_features() in your model_fn?")
  # Get a seed from the hash name of a dummy operation. This seed will only
  # depend on the name of the operation (incl. the scope name). It will be
  # unique within the graph and only change if the name of operation changes.
  with tf.name_scope("dummy_for_seed"):
    dummy_op = tf.no_op(name)
  # Using SHA-512 gives us a non-negative and uniformly distributed seed in the
  # interval [0, 2**512). This is consistent with TensorFlow, as TensorFlow
  # operations internally use the residue of the given seed modulo `2**31 - 1`
  # (see`tensorflow/python/framework/random_seed.py`).
  op_seed = int(hashlib.sha512(dummy_op.name.encode("utf-8")).hexdigest(), 16)
  op_seed = tf.constant(op_seed % (2**31 - 1))
  logging.info("Using op_seed %s for operation %s.", op_seed, dummy_op.name)
  return tf.stack([op_seed, _RANDOM_OFFSET_TENSOR])
def _get_seed ( name = None ) : if _RANDOM_OFFSET_TENSOR is None : raise ValueError ( "_RANDOM_OFFSET_TENSOR is None. Did you call " "set_random_offset_from_features() in your model_fn?" ) # Get a seed from the hash name of a dummy operation. This seed will only # depend on the name of the operation (incl. the scope name). It will be # unique within the graph and only change if the name of operation changes. with tf . name_scope ( "dummy_for_seed" ) : dummy_op = tf . no_op ( name ) # Using SHA-512 gives us a non-negative and uniformly distributed seed in the # interval [0, 2**512). This is consistent with TensorFlow, as TensorFlow # operations internally use the residue of the given seed modulo `2**31 - 1` # (see`tensorflow/python/framework/random_seed.py`). op_seed = int ( hashlib . sha512 ( dummy_op . name . encode ( "utf-8" ) ) . hexdigest ( ) , 16 ) op_seed = tf . constant ( op_seed % ( 2 ** 31 - 1 ) ) logging . info ( "Using op_seed %s for operation %s." , op_seed , dummy_op . name ) return tf . stack ( [ op_seed , _RANDOM_OFFSET_TENSOR ] )