tensorflow:: ops:: Substr

#include <string_ops.h>

החזרת תת-מחרוזות Tensor של מחרוזות.

תַקצִיר

עבור כל מחרוזת בקלט Tensor , הפונקציה יוצרת תת-מחרוזת שמתחילה pos האינדקס באורך כולל של len .

אם הפונקציה 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 

אופרטור::tensorflow::קלט

 operator::tensorflow::Input() const 

אופרטור::tensorflow::פלט

 operator::tensorflow::Output() const 

פונקציות סטטיות ציבוריות

יְחִידָה

Attrs Unit(
  StringPiece x
)