تينسورفلو :: العمليات :: Substr
#include <string_ops.h>
إرجاع السلاسل الفرعية من Tensor
السلاسل.
ملخص
لكل سلسلة في Tensor
الإدخال ، يتم إنشاء سلسلة فرعية تبدأ من مؤشر pos
بطول إجمالي len
.
إذا حدد len
سلسلة فرعية تمتد إلى ما بعد طول سلسلة الإدخال ، أو إذا كان len
سالبًا ، فسيتم استخدام أكبر عدد ممكن من الأحرف.
يشير pos
السلبي إلى المسافة داخل السلسلة إلى الوراء من النهاية.
إذا حدد موضع pos
فهرسًا خارج النطاق لأي من سلاسل الإدخال ، InvalidArgumentError
طرح InvalidArgumentError
.
يجب أن يكون لكل من pos
و len
نفس الشكل ، وإلا ValueError
طرح 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
:
0a8acd80
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']
يرفع:
-
ValueError
: إذا كان لا يمكن تحويل الوسيطة الأولى إلى Tensor منdtype string
. -
InvalidArgumentError
: إذا كانت المؤشرات خارج النطاق. -
ValueError
: إذا لم تكنpos
وlen
بنفس الشكل.
الحجج:
- النطاق: كائن النطاق
- الإدخال: موتر الأوتار
- pos: عددي يحدد موضع الحرف الأول في كل سلسلة فرعية
- لين: عددي يحدد عدد الأحرف المراد تضمينها في كل سلسلة فرعية
السمات الاختيارية (انظر 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 :: العمليات :: 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 :: Output
operator::tensorflow::Output() const
وظائف ثابتة عامة
وحدة
Attrs Unit( StringPiece x )
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-04-20 UTC.