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', '']) 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:
- 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 ifunit=UTF8_CHAR
and theinput
strings do not contain structurally valid UTF-8.
Returns:
Output
: Integer tensor that has the same shape asinput
. The output contains the element-wise string lengths ofinput
.
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:: |
Optional attribute setters for StringLength. |
Public attributes
operation
Operation operation
output
::tensorflow::Output output
Public functions
StringLength
StringLength( const ::tensorflow::Scope & scope, ::tensorflow::Input input )
StringLength
StringLength( const ::tensorflow::Scope & scope, ::tensorflow::Input input, const StringLength::Attrs & attrs )
node
::tensorflow::Node * node() const
operator::tensorflow::Input
operator::tensorflow::Input() const
operator::tensorflow::Output
operator::tensorflow::Output() const
Public static functions
Unit
Attrs Unit( StringPiece x )