TF 2.0 is out! Get hands-on practice at TF World, Oct 28-31. Use code TF20 for 20% off select passes. Register now

tft.word_count

tft.word_count(
    tokens,
    name=None
)

Find the token count of each document/row.

tokens is either a RaggedTensor or SparseTensor, representing tokenized strings. This function simply returns size of each row, so the dtype is not constrained to string.

Args:

  • tokens: either (1) a two-dimensional SparseTensor, or (2) a RaggedTensor with ragged rank of 1, non-ragged rank of 1 of dtype tf.string containing tokens to be counted
  • name: (Optional) A name for this operation.

Returns:

A one-dimensional Tensor the token counts of each row.

Raises:

  • ValueError: if tokens is neither sparse nor ragged