เทนเซอร์โฟลว์:: ปฏิบัติการ:: ส่วนย่อย
#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
):
- unit: หน่วยที่ใช้สร้างสตริงย่อย หนึ่งใน:
"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) |
งานสาธารณะ | |
---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const |
โครงสร้าง | |
---|---|
เทนเซอร์โฟลว์ :: 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
ตัวดำเนินการ::tensorflow::อินพุต
operator::tensorflow::Input() const
ตัวดำเนินการ::tensorflow::เอาต์พุต
operator::tensorflow::Output() const
ฟังก์ชันคงที่สาธารณะ
หน่วย
Attrs Unit(
StringPiece x
)