Ejemplo n.º 1
0
def _create_none_optionals(func_graph, template_tensors):
    """Creates none optionals in func_graph to represent template_tensors.

  Args:
    func_graph: FuncGraph.
    template_tensors: a list of tensors in func_graph.

  Returns:
    A list of tensors in func_graph.
  """
    with func_graph.as_default():
        return [gen_dataset_ops.optional_none() for _ in template_tensors]
Ejemplo n.º 2
0
def _create_none_optionals(func_graph, n):
    """Creates `n` `None` optionals in func_graph.

  Args:
    func_graph: FuncGraph.
    n: `int` the number of `None` optionals to make.

  Returns:
    A list of tensors in func_graph.
  """
    with func_graph.as_default():
        return [gen_dataset_ops.optional_none() for _ in range(n)]
Ejemplo n.º 3
0
def _create_none_optionals(func_graph, template_tensors):
  """Creates none optionals in func_graph to represent template_tensors.

  Args:
    func_graph: FuncGraph.
    template_tensors: a list of tensors in func_graph.

  Returns:
    A list of tensors in func_graph.
  """
  with func_graph.as_default():
    return [gen_dataset_ops.optional_none() for _ in template_tensors]
Ejemplo n.º 4
0
    def none_from_structure(value_structure):
        """Returns an `Optional` that has no value.

    NOTE: This method takes an argument that defines the structure of the value
    that would be contained in the returned `Optional` if it had a value.

    Args:
      value_structure: A `Structure` object representing the structure of the
        components of this optional.

    Returns:
      An `Optional` that has no value.
    """
        return _OptionalImpl(gen_dataset_ops.optional_none(), value_structure)
Ejemplo n.º 5
0
  def none_from_structure(value_structure):
    """Returns an `Optional` that has no value.

    NOTE: This method takes an argument that defines the structure of the value
    that would be contained in the returned `Optional` if it had a value.

    Args:
      value_structure: A `Structure` object representing the structure of the
        components of this optional.

    Returns:
      An `Optional` that has no value.
    """
    return _OptionalImpl(gen_dataset_ops.optional_none(), value_structure)
Ejemplo n.º 6
0
  def none_from_structure(output_shapes, output_types, output_classes):
    """Returns an `Optional` that has no value.

    NOTE: This method takes arguments that define the structure of the value
    that would be contained in the returned `Optional` if it had a value.

    Args:
      output_shapes: A nested structure of `tf.TensorShape` objects
        corresponding to each component of this optional.
      output_types: A nested structure of `tf.DType` objects corresponding to
        each component of this optional.
      output_classes: A nested structure of Python `type` objects corresponding
        to each component of this optional.

    Returns:
      An `Optional` that has no value.
    """
    return _OptionalImpl(gen_dataset_ops.optional_none(), output_shapes,
                         output_types, output_classes)
Ejemplo n.º 7
0
    def empty(element_spec):
        """Returns an `Optional` that has no value.

    NOTE: This method takes an argument that defines the structure of the value
    that would be contained in the returned `Optional` if it had a value.

    >>> optional = tf.experimental.Optional.empty(
    ...   tf.TensorSpec(shape=(), dtype=tf.int32, name=None))
    >>> print(optional.has_value())
    tf.Tensor(False, shape=(), dtype=bool)

    Args:
      element_spec: A (nested) structure of `tf.TypeSpec` objects matching the
        structure of an element of this optional.

    Returns:
      A `tf.experimental.Optional` with no value.
    """
        return _OptionalImpl(gen_dataset_ops.optional_none(), element_spec)
Ejemplo n.º 8
0
  def none_from_structure(output_shapes, output_types, output_classes):
    """Returns an `Optional` that has no value.

    NOTE: This method takes arguments that define the structure of the value
    that would be contained in the returned `Optional` if it had a value.

    Args:
      output_shapes: A nested structure of `tf.TensorShape` objects
        corresponding to each component of this optional.
      output_types: A nested structure of `tf.DType` objects corresponding to
        each component of this optional.
      output_classes: A nested structure of Python `type` objects corresponding
        to each component of this optional.

    Returns:
      An `Optional` that has no value.
    """
    return _OptionalImpl(gen_dataset_ops.optional_none(), output_shapes,
                         output_types, output_classes)