既知の直接サブクラス |
モデルの入力または出力のデータバッファを表します。
パブリック メソッド
静的 TensorBuffer | |
静的 TensorBuffer | |
静的 TensorBuffer | |
ByteBuffer |
getBuffer()
データ バッファを返します。
|
抽象的 DataType |
getDataType()
このバッファのデータ型を返します。
|
整数 |
getFlatSize()
バッファの FlatSize を取得します。
|
抽象的 float[] |
getFloatArray()
このバッファに格納されている値の浮動小数点配列を返します。
|
抽象的 浮動小数点数 |
getFloatValue(int absIndex)
指定されたインデックスの浮動小数点値を返します。
|
抽象的 整数 [] |
getIntArray()
このバッファに格納されている値の int 配列を返します。
|
抽象的 整数 |
getIntValue(int absIndex)
指定されたインデックスの int 値を返します。
|
整数 [] |
getShape()
現在のシェイプを取得します。
|
抽象的 整数 |
getTypeSize()
配列内の 1 つの要素のバイト数を返します。
|
ブール値 |
isDynamic()
TensorBuffer が動的なサイズであるかどうか(任意のサイズの変更が可能)かどうかを返します。 |
抽象的 無効 |
loadArray(int[] src, int[] 費用が)
特定の形状を持つ int 配列をこのバッファに読み込みます。
|
抽象的 無効 |
loadArray(float[] src, int[] 費用が
指定した形状の浮動小数点配列をこのバッファに読み込みます。
|
無効 |
loadArray(float[] src)
浮動小数点配列をこのバッファに読み込みます。
|
無効 |
loadArray(int[] src)
int 配列をこのバッファに読み込みます。
|
無効 | |
無効 |
継承されるメソッド
パブリック メソッド
<ph type="x-smartling-placeholder"></ph> 一般公開 静的 TensorBuffer をご覧ください。 createDynamic (DataType データ型)
指定された DataType
で空の動的 TensorBuffer
を作成します。関数の形状は、
作成された TensorBuffer
は {0} です。
動的 TensorBuffers は、次の配列またはデータバッファを読み込むときにメモリを再割り当てします。 さまざまなバッファサイズを使用できます。次に例を示します。
// Creating a float dynamic TensorBuffer: TensorBuffer tensorBuffer = TensorBuffer.createDynamic(DataType.FLOAT32); // Loading a float array: float[] arr1 = new float[] {1, 2, 3}; tensorBuffer.loadArray(arr, new int[] {arr1.length}); // loading another float array: float[] arr2 = new float[] {1, 2, 3, 4, 5}; tensorBuffer.loadArray(arr, new int[] {arr2.length}); // loading a third float array with the same size as arr2, assuming shape doesn't change: float[] arr3 = new float[] {5, 4, 3, 2, 1}; tensorBuffer.loadArray(arr); // loading a forth float array with different size as arr3 and omitting the shape will result // in error: float[] arr4 = new float[] {3, 2, 1}; tensorBuffer.loadArray(arr); // Error: The size of byte buffer and the shape do not match.
パラメータ
dataType | 作成する TensorBuffer の dataType。
|
---|
<ph type="x-smartling-placeholder"></ph> 一般公開 静的 TensorBuffer をご覧ください。 createFixedSize (int[] shape, DataType dataType)
指定された shape
と DataType
で TensorBuffer
を作成します。以下に例を示します。
例:
// Creating a float TensorBuffer with shape {2, 3}: int[] shape = new int[] {2, 3}; TensorBuffer tensorBuffer = TensorBuffer.createFixedSize(shape, DataType.FLOAT32);
// Creating an uint8 TensorBuffer of a scalar: int[] shape = new int[] {}; TensorBuffer tensorBuffer = TensorBuffer.createFixedSize(shape, DataType.UINT8);
// Creating an empty uint8 TensorBuffer: int[] shape = new int[] {0}; TensorBuffer tensorBuffer = TensorBuffer.createFixedSize(shape, DataType.UINT8);
固定サイズの TensorBuffer は、作成後にサイズを変更することはできません。
パラメータ
シェイプ | 作成する TensorBuffer の形状。 |
---|---|
dataType | 作成する TensorBuffer の dataType。 |
例外
NullPointerException | shape が null の場合。 |
---|---|
IllegalArgumentException | shape に正数でない要素がある場合。
|
<ph type="x-smartling-placeholder"></ph> 一般公開 静的 TensorBuffer をご覧ください。 createFrom (TensorBuffer バッファ、DataType dataType)
指定された DataType
で、別のデータからディープコピーする TensorBuffer
を作成します。
パラメータ
buffer | コピー元の TensorBuffer 。 |
---|---|
dataType | 新しく作成された TensorBuffer の想定される DataType 。 |
例外
NullPointerException | buffer が null の場合。
|
---|
<ph type="x-smartling-placeholder"></ph> 一般公開 抽象的 DataType をご覧ください。 getDataType ()
このバッファのデータ型を返します。
<ph type="x-smartling-placeholder"></ph> 一般公開 整数 getFlatSize ()
バッファの FlatSize を取得します。
例外
IllegalStateException | 基盤となるデータが破損した場合 |
---|
<ph type="x-smartling-placeholder"></ph> 一般公開 抽象的 float[] getFloatArray ()
このバッファに格納されている値の浮動小数点配列を返します。バッファの型が 1 つでも
値が浮動小数点数に変換されます。たとえば、TensorBufferUint8
の値は uint8 から float に変換されます。
<ph type="x-smartling-placeholder"></ph> 一般公開 抽象的 浮動小数点数 getFloatValue (int absIndex)
指定されたインデックスの浮動小数点値を返します。バッファの型が float 型と異なる場合は、
値は浮動小数点数に変換されます。たとえば、TensorBufferUint8
から値を読み取る場合、値はまず uint8 として読み取られた後、
uint8 で浮動小数点数にします。
For example, a TensorBuffer with shape {2, 3} that represents the following array, [[0.0f, 1.0f, 2.0f], [3.0f, 4.0f, 5.0f]]. The fourth element (whose value is 3.0f) in the TensorBuffer can be retrieved by: float v = tensorBuffer.getFloatValue(3);
パラメータ
absIndex | 読み取る値の絶対インデックス。 |
---|
<ph type="x-smartling-placeholder"></ph> 一般公開 抽象的 整数 [] getIntArray ()
このバッファに格納されている値の int 配列を返します。バッファの型が 1 つでも
int よりも小さい場合、値は int に変換されるため、精度が低下する可能性があります。たとえば
値が {400.32f, 23.04f} の TensorBufferFloat
から int 配列を取得し、出力
は {400, 23} です。
<ph type="x-smartling-placeholder"></ph> 一般公開 抽象的 整数 getIntValue (int absIndex)
指定されたインデックスの int 値を返します。バッファの型が int と異なる場合、
整数に変換されます。たとえば、TensorBufferFloat
から値を読み取る場合、
値はまず float として読み取られ、その後 float から int に変換されます。減少
精度が適用される場合があります
For example, a TensorBuffer with shape {2, 3} that represents the following array, [[0.0f, 1.0f, 2.0f], [3.0f, 4.0f, 5.0f]]. The fourth element (whose value is 3.0f) in the TensorBuffer can be retrieved by: int v = tensorBuffer.getIntValue(3); Note that v is converted from 3.0f to 3 as a result of type conversion.
パラメータ
absIndex | 読み取る値の絶対インデックス。 |
---|
<ph type="x-smartling-placeholder"></ph> 一般公開 整数 [] getShape ()
現在のシェイプを取得します。(予期しない変更を避けるため、ここでコピーを返します)。
例外
IllegalStateException | 基盤となるデータが破損した場合 |
---|
<ph type="x-smartling-placeholder"></ph> 一般公開 抽象的 整数 getTypeSize ()
配列内の 1 つの要素のバイト数を返します。たとえば、浮動小数点バッファは 戻り値は 4 で、バイトバッファは 1 を返します。
<ph type="x-smartling-placeholder"></ph> 一般公開 ブール値 isDynamic ()
TensorBuffer
が動的なサイズであるかどうか(任意のサイズの変更が可能)かどうかを返します。
<ph type="x-smartling-placeholder"></ph> 一般公開 抽象的 無効 loadArray (int[] src, int[] graph)
特定の形状を持つ int 配列をこのバッファに読み込みます。バッファの型が 1 つでも
int よりも多い場合、値はバッファの型に変換されてから
精度が低下する可能性があります。たとえば、値が {400,
-23} を TensorBufferUint8
に代入すると、値は [0, 255] に切り詰められ、その後
{255, 0} によって uint8 にキャストされます。
パラメータ
src | 読み込むソースの配列。 |
---|---|
シェイプ | src が表すテンソルの形状。 |
例外
NullPointerException | src が null の場合。 |
---|---|
NullPointerException | shape が null の場合。 |
IllegalArgumentException | 読み込む配列のサイズが 適用できます。 |
<ph type="x-smartling-placeholder"></ph> 一般公開 抽象的 無効 loadArray (float[] src, int[] graph)
指定した形状の浮動小数点配列をこのバッファに読み込みます。バッファの型が 1 つでも
浮動小数点数よりも大きい場合、値はバッファの型に変換されてから
精度が低下する可能性があります。たとえば、値が {400.32f, -23.04f} の TensorBufferUint8
に浮動小数点配列を読み込むと、値は [0, 255] に収まり、
その後、{255, 0} によって uint8 にキャストされます。
パラメータ
src | 読み込むソースの配列。 |
---|---|
シェイプ | src が表すテンソルの形状。 |
例外
NullPointerException | src が null の場合。 |
---|---|
NullPointerException | shape が null の場合。 |
IllegalArgumentException | 読み込む配列のサイズが 適用できます。 |
<ph type="x-smartling-placeholder"></ph> 一般公開 無効 loadArray (float[] src)
浮動小数点配列をこのバッファに読み込みます。バッファの型が float 型と異なる場合は、
値はバッファに読み込まれる前にバッファの型に変換され、
精度が適用される場合がありますたとえば、浮動小数点配列を TensorBufferUint8
に読み込む場合などです。
値が {400.32f, -23.04f} の場合、値は [0, 255] にクランプされてから、次のようにキャストされます。
uint8 を {255, 0} で割ったものです。
このメソッドを使用すると、src
のシェイプがこのオブジェクトのシェイプと同じであることを前提としています。
TensorBuffer
。したがって、buffer
(src.length
)のサイズは常に一致する必要があります。
この TensorBuffer
のフラットサイズ(固定サイズと動的な TensorBuffer
の両方)。src
の形状が異なる場合は loadArray(float[], int[])
を使用します。
パラメータ
src | 読み込むソースの配列。 |
---|
<ph type="x-smartling-placeholder"></ph> 一般公開 無効 loadArray (int[] src)
int 配列をこのバッファに読み込みます。バッファの型が int と異なる場合、
は、バッファに読み込まれる前にバッファの型に変換され、
精度が適用される場合があります。たとえば、値が {400, -23} の int 配列を TensorBufferUint8
に読み込むと、値は [0, 255] にクランプされた後、uint8 にキャストされます。
{255, 0}。
このメソッドを使用すると、src
のシェイプがこのオブジェクトのシェイプと同じであることを前提としています。
TensorBuffer
。したがって、buffer
(src.length
)のサイズは常に一致する必要があります。
この TensorBuffer
のフラットサイズ(固定サイズと動的な TensorBuffer
の両方)。src
の形状が異なる場合は loadArray(int[], int[])
を使用します。
パラメータ
src | 読み込むソースの配列。 |
---|
<ph type="x-smartling-placeholder"></ph> 一般公開 無効 loadBuffer (ByteBuffer バッファ)
この TensorBuffer
にバイトバッファを読み込みます。バッファサイズは
この TensorBuffer
。
このメソッドを使用すると、buffer
のシェイプがこのオブジェクトのシェイプと同じであることを前提としています。
TensorBuffer
。したがって、buffer
(buffer.limit()
)のサイズは常に
固定サイズと動的な TensorBuffer
の両方で、この TensorBuffer
のフラットサイズと一致します。buffer
に異なる値がある場合は、loadBuffer(ByteBuffer, int[])
を使用します。
適用します。
重要: 読み込まれたバッファは参照です。変更しないでください。ここでは、 パフォーマンス上の懸念がありますが、修正が必要な場合はコピーを作成してください。
最適なパフォーマンスを得るには、常に直接の ByteBuffer
または ByteBuffer
を読み込む
配列を基盤とします
buffer
が読み取り専用の場合は、パフォーマンス向上のために、書き込み時のコピー戦略を採用します。
パラメータ
buffer | 読み込むバイトバッファ。 |
---|
<ph type="x-smartling-placeholder"></ph> 一般公開 無効 loadBuffer (ByteBuffer バッファ、int[] シェイプ)
特定の形状でこの TensorBuffer
にバイトバッファを読み込みます。
重要: 読み込まれたバッファは参照です。変更しないでください。ここでは、 パフォーマンス上の懸念がありますが、修正が必要な場合はコピーを作成してください。
最適なパフォーマンスを得るには、常に直接の ByteBuffer
または ByteBuffer
を読み込む
配列を基盤とします
パラメータ
buffer | 読み込むバイトバッファ。 |
---|---|
シェイプ |
例外
NullPointerException | buffer が null の場合。 |
---|---|
IllegalArgumentException | buffer と typeSize のサイズが一致していない場合
buffer と flatSize のサイズが一致しません。
|