#include <string_ops.h>
String lengths of input
.
Computes the length of each string given in the input tensor.
strings = tf.constant(['Hello','TensorFlow', '']) 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)
Arguments:
Optional attributes (see Attrs
):
"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
. Constructors and Destructors | |
---|---|
StringLength(const ::tensorflow::Scope & scope, ::tensorflow::Input input) | |
StringLength(const ::tensorflow::Scope & scope, ::tensorflow::Input input, const StringLength::Attrs & attrs) |
Public attributes | |
---|---|
operation | |
output |
Public functions | |
---|---|
node() const | ::tensorflow::Node * |
operator::tensorflow::Input() const | |
operator::tensorflow::Output() const |
Public static functions | |
---|---|
Unit(StringPiece x) |
Structs | |
---|---|
tensorflow::ops::StringLength::Attrs | Optional attribute setters for StringLength. |
Operation operation
::tensorflow::Output output
StringLength( const ::tensorflow::Scope & scope, ::tensorflow::Input input )
StringLength( const ::tensorflow::Scope & scope, ::tensorflow::Input input, const StringLength::Attrs & attrs )
::tensorflow::Node * node() const
operator::tensorflow::Input() const
operator::tensorflow::Output() const
Attrs Unit( StringPiece x )
© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.4/api_docs/cc/class/tensorflow/ops/string-length