텐서플로우:: 연산:: 부분 문자열
#include <string_ops.h> 문자열 Tensor 에서 부분 문자열을 반환합니다.
요약
입력 Tensor 의 각 문자열에 대해 인덱스 pos 에서 시작하여 총 길이 len 인 부분 문자열을 생성합니다.
len 입력 문자열의 길이를 초과하는 부분 문자열을 정의하거나 len 음수인 경우, 가능한 한 많은 문자가 사용됩니다.
음수 pos 문자열의 끝에서 뒤쪽으로의 거리를 나타냅니다.
pos 지정한 인덱스가 입력 문자열 중 어느 하나에 대해 범위를 벗어나는 경우 InvalidArgumentError 가 발생합니다.
pos 와 len 동일한 형태를 가져야 하며, 그렇지 않으면 Op 생성 시 ValueError 발생합니다.
참고 : Substr 최대 2차원까지 브로드캐스팅을 지원합니다. 브로드캐스팅에 대한 자세한 내용은 여기를 참조하세요.
예시
스칼라 pos 와 len 사용:
input = [b'Hello', b'World'] position = 1 length = 3
output = [b'ell', b'orl']
input 과 동일한 형태의 pos 와 len 사용합니다.
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']] pos 와 len 에 input 브로드캐스팅합니다.
input = b'thirteen' position = [1, 5, 7] length = [3, 2, 1]
output = [b'hir', b'ee', b'n']
인상액:
-
ValueError: 첫 번째 인수를dtype string의 Tensor 로 변환할 수 없는 경우 발생합니다. -
InvalidArgumentError: 인덱스가 범위를 벗어난 경우 발생합니다. -
ValueError:pos와len형태가 같지 않은 경우 발생합니다.
논거:
- 범위: 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) | |
구조 | |
|---|---|
| 텐서플로우:: 연산:: 부분 문자열:: 속성 | 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
연산자::텐서플로우::입력
operator::tensorflow::Input() const
연산자::텐서플로우::출력
operator::tensorflow::Output() const
공개 정적 함수
단위
Attrs Unit( StringPiece x )