tensorflow::ops::Substr
#include <string_ops.h> ส่งคืนสตริงย่อยจาก Tensor ของสตริง
สรุป
สำหรับแต่ละสตริงใน Tensor จะสร้างสตริงย่อยโดยเริ่มต้นที่ดัชนี pos และมีความยาวรวม len
หาก len กำหนดสตริงย่อยที่มีความยาวเกินความยาวของสตริงอินพุต ระบบจะใช้จำนวนอักขระมากที่สุดเท่าที่จะเป็นไปได้
pos ติดลบ แสดงถึงระยะทางภายในสตริงที่วัดย้อนกลับจากปลายสุด
หาก pos ระบุค่าดัชนีที่อยู่นอกช่วงของสตริงอินพุตใดๆ จะเกิดข้อผิดพลาด InvalidArgumentError ขึ้น
pos และ len ต้องมีรูปร่างเหมือนกัน มิเช่นนั้นจะเกิด ValueError ขึ้นขณะสร้าง Op
หมายเหตุ : Substr รองรับการกระจายภาพได้สูงสุดสองมิติ ดูรายละเอียดเพิ่มเติมเกี่ยวกับการกระจายภาพได้ ที่นี่
ตัวอย่าง
โดยใช้ pos และ len แบบสเกลาร์:
input = [b'Hello', b'World'] position = 1 length = 3
output = [b'ell', b'orl']
ใช้ค่า pos และ len ที่มีรูปร่างเหมือนกับ input :
input = [[b'ten', b'eleven', b'twelve'],
[b'thirteen', b'fourteen', b'fifteen'],
[b'sixteen', b'seventeen', b'eighteen']]
position = [[1, 2, 3],
[1, 2, 3],
[1, 2, 3]]
length = [[2, 3, 4],
[4, 3, 2],
[5, 5, 5]]output = [[b'en', b'eve', b'lve'],
[b'hirt', b'urt', b'te'],
[b'ixtee', b'vente', b'hteen']] กระจายค่า pos และ len ไปยัง input :
input = [[b'ten', b'eleven', b'twelve'],
[b'thirteen', b'fourteen', b'fifteen'],
[b'sixteen', b'seventeen', b'eighteen'],
[b'nineteen', b'twenty', b'twentyone']]
position = [1, 2, 3]
length = [1, 2, 3]output = [[b'e', b'ev', b'lve'],
[b'h', b'ur', b'tee'],
[b'i', b've', b'hte'],
[b'i', b'en', b'nty']] ส่ง input ไปยัง pos และ len :
input = b'thirteen' position = [1, 5, 7] length = [3, 2, 1]
output = [b'hir', b'ee', b'n']
ข้อโต้แย้ง:
- ขอบเขต: วัตถุ ขอบเขต
- อินพุต: เทนเซอร์ ของสตริง
- pos: ค่าสเกลาร์ที่กำหนดตำแหน่งของอักขระตัวแรกในแต่ละสตริงย่อย
- len: ค่าสเกลาร์ที่กำหนดจำนวนอักขระที่จะรวมอยู่ในแต่ละสตริงย่อย
คุณลักษณะเสริม (ดูที่ Attrs ):
- หน่วย: หน่วยที่ใช้ในการสร้างสตริงย่อย หนึ่งในตัวเลือก:
"BYTE"(สำหรับการกำหนดตำแหน่งและความยาวด้วยไบต์) หรือ"UTF8_CHAR"(สำหรับจุดรหัส Unicode ที่เข้ารหัสแบบ UTF-8) ค่าเริ่มต้นคือ"BYTE"ผลลัพธ์จะไม่แน่นอนหากunit=UTF8_CHARและสตริงinputไม่มีโครงสร้าง UTF-8 ที่ถูกต้อง
การส่งคืนสินค้า:
ตัวสร้างและตัวทำลาย | |
|---|---|
Substr (const :: tensorflow::Scope & scope, :: tensorflow::Input input, :: tensorflow::Input pos, :: tensorflow::Input len) | |
Substr (const :: tensorflow::Scope & scope, :: tensorflow::Input input, :: tensorflow::Input pos, :: tensorflow::Input len, const Substr::Attrs & attrs) |
คุณลักษณะสาธารณะ | |
|---|---|
operation | |
output | |
หน้าที่สาธารณะ | |
|---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const | |
ฟังก์ชันคงที่สาธารณะ | |
|---|---|
Unit (StringPiece x) | |
โครงสร้าง | |
|---|---|
| tensorflow::ops::Substr::Attrs | ตัวเลือกในการตั้งค่าแอตทริบิวต์สำหรับ Substr |
คุณลักษณะสาธารณะ
การดำเนินการ
Operation operation
เอาต์พุต
::tensorflow::Output output
หน้าที่สาธารณะ
ซับสตร
Substr( const ::tensorflow::Scope & scope, ::tensorflow::Input input, ::tensorflow::Input pos, ::tensorflow::Input len )
ซับสตร
Substr( const ::tensorflow::Scope & scope, ::tensorflow::Input input, ::tensorflow::Input pos, ::tensorflow::Input len, const Substr::Attrs & attrs )
โหนด
::tensorflow::Node * node() const
ตัวดำเนินการ::เทนเซอร์โฟลว์::อินพุต
operator::tensorflow::Input() const
ตัวดำเนินการ::เทนเซอร์โฟลว์::เอาต์พุต
operator::tensorflow::Output() const
ฟังก์ชันคงที่สาธารณะ
หน่วย
Attrs Unit( StringPiece x )