جریان تنسور:: عملیات:: خیابان فرعی

#include <string_ops.h>

رشته های فرعی را از Tensor of strings برگردانید.

خلاصه

برای هر رشته در 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']

استدلال ها:

  • scope: یک شی Scope
  • ورودی: تانسور رشته ها
  • pos: اسکالر که موقعیت اولین کاراکتر را در هر رشته فرعی تعیین می کند
  • len: اسکالر که تعداد کاراکترهایی را که باید در هر زیررشته گنجانده شود را تعیین می کند

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

  • unit: واحدی که برای ایجاد زیررشته استفاده می شود. یکی از این موارد: "BYTE" (برای تعیین موقعیت و طول بر اساس بایت) یا "UTF8_CHAR" (برای نقاط کد یونیکد رمزگذاری شده 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
)