Stay organized with collections
Save and categorize content based on your preferences.
tensorflow::ops::StringLength
#include <string_ops.h>
String lengths of input
.
Summary
Computes the length of each string given in the input tensor.
strings = tf.constant(['Hello','TensorFlow', '\U0001F642']) tf.strings.length(strings).numpy() # default counts bytes array([ 5, 10, 4], dtype=int32) tf.strings.length(strings, unit="UTF8_CHAR").numpy() array([ 5, 10, 1], dtype=int32)
Args:
- scope: A Scope object
- input: The strings for which to compute the length for each element.
Optional attributes (see Attrs
):
- unit: The unit that is counted to compute string length. One of:
"BYTE"
(for the number of bytes in each string) or "UTF8_CHAR"
(for the number of UTF-8 encoded Unicode code points in each string). Results are undefined if unit=UTF8_CHAR
and the input
strings do not contain structurally valid UTF-8.
Returns:
Output
: Integer tensor that has the same shape as input
. The output contains the element-wise string lengths of input
.
Public static functions
|
Unit(StringPiece x)
|
|
Public attributes
Public functions
node
::tensorflow::Node * node() const
operator::tensorflow::Input() const
operator::tensorflow::Output
operator::tensorflow::Output() const
Public static functions
Unit
Attrs Unit(
StringPiece x
)
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2022-03-14 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2022-03-14 UTC."],[],[],null,["# tensorflow::ops::StringLength Class Reference\n\ntensorflow::ops::StringLength\n=============================\n\n`#include \u003cstring_ops.h\u003e`\n\nString lengths of `input`.\n\nSummary\n-------\n\nComputes the length of each string given in the input tensor.\n\nstrings = tf.constant(\\['Hello','TensorFlow', '\\\\U0001F642'\\]) tf.strings.length(strings).numpy() # default counts bytes array(\\[ 5, 10, 4\\], dtype=int32) tf.strings.length(strings, unit=\"UTF8_CHAR\").numpy() array(\\[ 5, 10, 1\\], dtype=int32)\n\nArgs:\n\n- scope: A [Scope](/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object\n- input: The strings for which to compute the length for each element.\n\n\u003cbr /\u003e\n\nOptional attributes (see [Attrs](/api_docs/cc/struct/tensorflow/ops/string-length/attrs#structtensorflow_1_1ops_1_1_string_length_1_1_attrs)):\n\n- unit: The unit that is counted to compute string length. One of: `\"BYTE\"` (for the number of bytes in each string) or `\"UTF8_CHAR\"` (for the number of UTF-8 encoded Unicode code points in each string). Results are undefined if `unit=UTF8_CHAR` and the `input` strings do not contain structurally valid UTF-8.\n\n\u003cbr /\u003e\n\nReturns:\n\n- [Output](/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output): Integer tensor that has the same shape as `input`. The output contains the element-wise string lengths of `input`.\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| [StringLength](#classtensorflow_1_1ops_1_1_string_length_1a7bf80700ba30572d7c7ca2b6f850eaca)`(const ::`[tensorflow::Scope](/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` input)` ||\n| [StringLength](#classtensorflow_1_1ops_1_1_string_length_1a1a20dc90501bbdb2e17e0b5964a8eff1)`(const ::`[tensorflow::Scope](/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` input, const `[StringLength::Attrs](/api_docs/cc/struct/tensorflow/ops/string-length/attrs#structtensorflow_1_1ops_1_1_string_length_1_1_attrs)` & attrs)` ||\n\n| ### Public attributes ||\n|-------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------|\n| [operation](#classtensorflow_1_1ops_1_1_string_length_1a17a8867ada18bd6238863a038adb4072) | [Operation](/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation) |\n| [output](#classtensorflow_1_1ops_1_1_string_length_1a3c952cda013f2825ee48c9cba19fa974) | `::`[tensorflow::Output](/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n\n| ### Public functions ||\n|-------------------------------------------------------------------------------------------------------------------------|------------------------|\n| [node](#classtensorflow_1_1ops_1_1_string_length_1a8958d29822235046d6f74f45f90f9ee2)`() const ` | `::tensorflow::Node *` |\n| [operator::tensorflow::Input](#classtensorflow_1_1ops_1_1_string_length_1ad02392f74af341966e713678ada76cf3)`() const ` | |\n| [operator::tensorflow::Output](#classtensorflow_1_1ops_1_1_string_length_1a75c524b5ff956f3f681cdebb8135460f)`() const ` | |\n\n| ### Public static functions ||\n|-------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|\n| [Unit](#classtensorflow_1_1ops_1_1_string_length_1af57b9def6e863b9003b3fc809a13d835)`(StringPiece x)` | [Attrs](/api_docs/cc/struct/tensorflow/ops/string-length/attrs#structtensorflow_1_1ops_1_1_string_length_1_1_attrs) |\n\n| ### Structs ||\n|------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------|\n| [tensorflow::ops::StringLength::Attrs](/api_docs/cc/struct/tensorflow/ops/string-length/attrs) | Optional attribute setters for [StringLength](/api_docs/cc/class/tensorflow/ops/string-length#classtensorflow_1_1ops_1_1_string_length). |\n\nPublic attributes\n-----------------\n\n### operation\n\n```text\nOperation operation\n``` \n\n### output\n\n```text\n::tensorflow::Output output\n``` \n\nPublic functions\n----------------\n\n### StringLength\n\n```gdscript\n StringLength(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input input\n)\n``` \n\n### StringLength\n\n```gdscript\n StringLength(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input input,\n const StringLength::Attrs & attrs\n)\n``` \n\n### node\n\n```gdscript\n::tensorflow::Node * node() const \n``` \n\n### operator::tensorflow::Input\n\n```gdscript\n operator::tensorflow::Input() const \n``` \n\n### operator::tensorflow::Output\n\n```gdscript\n operator::tensorflow::Output() const \n``` \n\nPublic static functions\n-----------------------\n\n### Unit\n\n```text\nAttrs Unit(\n StringPiece x\n)\n```"]]