tensorflow::ops::StringLength
#include <string_ops.h> ความยาวของสตริง input
สรุป
คำนวณความยาวของแต่ละสตริงที่ระบุในเทนเซอร์อินพุต
strings = tf.constant(['Hello','TensorFlow', '']) tf.strings.length(strings).numpy() # ค่าเริ่มต้นนับไบต์ array([ 5, 10, 4], dtype=int32) tf.strings.length(strings, unit="UTF8_CHAR").numpy() array([ 5, 10, 1], dtype=int32)
ข้อโต้แย้ง:
- ขอบเขต: วัตถุ ขอบเขต
- อินพุต: สตริงที่จะใช้คำนวณความยาวของแต่ละองค์ประกอบ
คุณลักษณะเสริม (ดูที่ Attrs ):
- หน่วย: หน่วยที่ใช้ในการคำนวณความยาวของสตริง เลือกได้ระหว่าง
"BYTE"(สำหรับจำนวนไบต์ในแต่ละสตริง) หรือ"UTF8_CHAR"(สำหรับจำนวนจุดรหัส Unicode ที่เข้ารหัสแบบ UTF-8 ในแต่ละสตริง) ผลลัพธ์จะไม่แน่นอนหากunit=UTF8_CHARและสตริงinputไม่มีโครงสร้าง UTF-8 ที่ถูกต้อง
การส่งคืนสินค้า:
-
Output: เทนเซอร์จำนวนเต็มที่มีรูปร่างเหมือนกับinputโดยผลลัพธ์จะประกอบด้วยความยาวของสตริงแต่ละองค์ประกอบของinput
ตัวสร้างและตัวทำลาย | |
|---|---|
StringLength (const :: tensorflow::Scope & scope, :: tensorflow::Input input) | |
StringLength (const :: tensorflow::Scope & scope, :: tensorflow::Input input, const StringLength::Attrs & attrs) |
คุณลักษณะสาธารณะ | |
|---|---|
operation | |
output | |
หน้าที่สาธารณะ | |
|---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const | |
ฟังก์ชันคงที่สาธารณะ | |
|---|---|
Unit (StringPiece x) | |
โครงสร้าง | |
|---|---|
| tensorflow::ops::StringLength::Attrs | ตัวเลือกในการตั้งค่าแอตทริบิวต์สำหรับ 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 )