از اینکه با Google I/O تنظیم کردید متشکریم. مشاهده همه جلسات در صورت تقاضا تماشا کنید

tensorflow :: ops :: Substr

#include <string_ops.h>

زیر رشته ها را از Tensor رشته ها برگردانید.

خلاصه

برای هر رشته در Tensor ورودی ، یک رشته فرعی ایجاد می کند که از index 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']

استدلال ها:

  • دامنه: یک شی Sc Scope
  • ورودی: تانسور رشته ها
  • pos: اسکالر موقعیت شخصیت اول را در هر زیر رشته تعریف می کند
  • len: اسکالر تعداد کاراکترهایی را که باید در هر زیر رشته وارد کند تعریف می کند

ویژگی های اختیاری (به Attrs مراجعه کنید):

  • unit: واحدی که برای ایجاد زیر رشته استفاده می شود. یکی از این موارد: "BYTE" (برای تعیین موقعیت و طول توسط بایت) یا "UTF8_CHAR" (برای نقاط کد Unicode رمزگذاری شده UTF-8). پیش فرض "BYTE" . اگر unit=UTF8_CHAR و رشته های input شامل ساختار معتبر UTF-8 unit=UTF8_CHAR نتایج تعریف نمی شوند.

بازده:

سازندگان و ویرانگران

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

 Substr(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input input,
  ::tensorflow::Input pos,
  ::tensorflow::Input len
)

Substr

 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
)