tensorflow:: ops:: Substr

#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']

議論:

  • スコープ:スコープオブジェクト
  • 入力:文字列のテンソル
  • pos: 各部分文字列の最初の文字の位置を定義するスカラー値
  • len: 各部分文字列に含める文字数を定義するスカラー値

オプション属性( Attrs参照):

  • unit: 部分文字列を作成する際に使用する単位。次のいずれかを指定します"BYTE" (位置と長さをバイト単位で指定する場合)または"UTF8_CHAR" (UTF-8 エンコードされた Unicode コードポイントを指定する場合)。デフォルトは"BYTE"です。unit 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 

operator::tensorflow::Input

 operator::tensorflow::Input() const 

operator::tensorflow::Output

 operator::tensorflow::Output() const 

パブリック静的関数

ユニット

Attrs Unit(
  StringPiece x
)