tf.io.RaggedFeature

Configuration for passing a RaggedTensor input feature.

Used in the notebooks

Used in the guide

value_key specifies the feature key for a variable-length list of values; and partitions specifies zero or more feature keys for partitioning those values into higher dimensions. Each element of partitions must be one of the following:

  • tf.io.RaggedFeature.RowSplits(key: string)
  • tf.io.RaggedFeature.RowLengths(key: string)
  • tf.io.RaggedFeature.RowStarts(key: string)
  • tf.io.RaggedFeature.RowLimits(key: string)
  • tf.io.RaggedFeature.ValueRowIds(key: string)
  • tf.io.RaggedFeature.UniformRowLength(length: int).

Where key is a feature key whose values are used to partition the values. Partitions are listed from outermost to innermost.

  • If len(partitions) == 0 (the default), then:

    • A feature from a single tf.Example is parsed into a 1D tf.Tensor.
    • A feature from a batch of tf.Examples is parsed into a 2D tf.RaggedTensor, where the outer dimension is the batch dimension, and the inner (ragged) dimension is the feature length in each example.
  • If len(partitions) == 1, then:

    • A feature from a single tf.Example is parsed into a 2D tf.RaggedTensor, where the values taken from the value_key are separated into rows using the partition key.

    • A feature from a batch of tf.Examples is parsed into a 3D tf.RaggedTensor, where the outer dimension is the batch dimension, the two inner dimensions are formed by separating the value_key values from each example into rows using that example's partition key.

  • If len(partitions) > 1, then:

    • A feature from a single tf.Example is parsed into a tf.RaggedTensor whose rank is len(partitions)+1, and whose ragged_rank is