tensorflow:: ops:: Substr
#include <string_ops.h> Restituisce le sottostringhe dal Tensor di stringhe.
Riepilogo
Per ogni stringa nel Tensor di input, crea una sottostringa che inizia all'indice pos con una lunghezza totale di len .
Se len definisce una sottostringa che si estende oltre la lunghezza della stringa di input, vengono utilizzati il maggior numero possibile di caratteri.
Un pos negativo indica la distanza all'interno della stringa a ritroso dall'estremità.
Se pos specifica un indice fuori dall'intervallo per una qualsiasi delle stringhe di input, viene generato un InvalidArgumentError .
pos e len devono avere la stessa forma, altrimenti viene generato un ValueError durante la creazione dell'Op.
NOTA : Substr supporta il broadcasting fino a due dimensioni. Ulteriori informazioni sul broadcasting sono disponibili qui.
Esempi
Utilizzando le variabili scalari pos e len :
input = [b'Hello', b'World'] position = 1 length = 3
output = [b'ell', b'orl']
Utilizzando pos e len con la stessa forma 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']] Trasmissione pos e 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']] Trasmissione input su pos e len :
input = b'thirteen' position = [1, 5, 7] length = [3, 2, 1]
output = [b'hir', b'ee', b'n']
Argomentazioni:
- ambito: un oggetto Scope
- input: Tensore di stringhe
- pos: Scalare che definisce la posizione del primo carattere in ogni sottostringa
- len: Scalare che definisce il numero di caratteri da includere in ogni sottostringa
Attributi opzionali (vedere Attrs ):
- unità: l'unità utilizzata per creare la sottostringa. Una delle seguenti opzioni:
"BYTE"(per definire posizione e lunghezza in byte) o"UTF8_CHAR"(per i punti di codice Unicode codificati in UTF-8). Il valore predefinito è"BYTE". I risultati non sono definiti seunit=UTF8_CHARe le stringheinputnon contengono UTF-8 strutturalmente valido.
Resi:
Costruttori e distruttori | |
|---|---|
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) |
attributi pubblici | |
|---|---|
operation | |
output | |
Funzioni pubbliche | |
|---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const | |
Funzioni statiche pubbliche | |
|---|---|
Unit (StringPiece x) | |
Strutture | |
|---|---|
| tensorflow::ops::Substr::Attrs | Impostatori di attributi opzionali per Substr . |
attributi pubblici
operazione
Operation operation
produzione
::tensorflow::Output output
Funzioni pubbliche
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 )
nodo
::tensorflow::Node * node() const
operatore::tensorflow::Input
operator::tensorflow::Input() const
operatore::tensoreflusso::output
operator::tensorflow::Output() const
Funzioni statiche pubbliche
Unità
Attrs Unit( StringPiece x )