TensorBuffer

공개 추상 클래스 TensorBuffer
알려진 직접 서브클래스

모델의 입력 또는 출력을 위한 데이터 버퍼를 나타냅니다.

공개 메서드

정적 TensorBuffer
createDynamic(DataType dataType)
지정된 DataType로 빈 동적 TensorBuffer를 만듭니다.
정적 TensorBuffer
createFixedSize(int[] 도형, DataType dataType)
지정된 shapeDataTypeTensorBuffer를 만듭니다.
정적 TensorBuffer
createFrom(TensorBuffer 버퍼, DataType dataType)
지정된 DataType를 사용하여 다른 항목에서 딥 복사 데이터를 만드는 TensorBuffer를 만듭니다.
ByteBuffer
getBuffer()
데이터 버퍼를 반환합니다.
추상 DataType
getDataType()
이 버퍼의 데이터 유형을 반환합니다.
int
getFlatSize()
버퍼의 splitSize를 가져옵니다.
추상 float[]
getFloatArray()
이 버퍼에 저장된 값의 부동 소수점 배열을 반환합니다.
추상 부동 소수점 수
getFloatValue(int absIndex)
주어진 색인의 부동 소수점 값을 반환합니다.
추상 정수[]
getIntArray()
이 버퍼에 저장된 값의 int 배열을 반환합니다.
추상 정수
getIntValue(int absIndex)
지정된 색인에서 int 값을 반환합니다.
int[]
getShape()
현재 셰이프를 가져옵니다.
추상 정수
getTypeSize()
배열에서 단일 요소의 바이트 수를 반환합니다.
부울
isDynamic()
TensorBuffer의 크기가 동적인 경우 (임의의 크기 조절 가능)를 반환합니다.
추상 무효
loadArray(int[] src, int[] 도형)
int 배열을 특정 형태로 이 버퍼에 로드합니다.
추상 무효
loadArray(float[] src, int[] 도형)
이 버퍼에 특정 모양의 부동 배열을 로드합니다.
void
loadArray(float[] src)
이 버퍼에 부동 배열을 로드합니다.
void
loadArray(int[] src)
이 버퍼에 int 배열을 로드합니다.
void
loadBuffer(ByteBuffer 버퍼)
TensorBuffer에 바이트 버퍼를 로드합니다.
void
loadBuffer(ByteBuffer 버퍼, int[] 모양)
TensorBuffer에 특정 형태의 바이트 버퍼를 로드합니다.

상속된 메서드

공개 메서드

<ph type="x-smartling-placeholder"></ph> 공개 정적 TensorBuffer createDynamic (DataType 데이터 유형)

지정된 DataType로 빈 동적 TensorBuffer를 만듭니다. 피처스토어의 모양은 만든 TensorBuffer이(가) {0}입니다.

동적 TensorBuffer는 다음에 해당하는 배열이나 데이터 버퍼를 로드할 때 메모리를 재할당합니다. 다양한 버퍼 크기를 지원합니다. 예를 들면 다음과 같습니다.

 // 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[] 도형, DataType dataType)

지정된 shapeDataTypeTensorBuffer를 만듭니다. 다음은 몇 가지 예:

 // 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는 일단 생성된 후에는 변경할 수 없습니다.

매개변수
shape 생성할 TensorBuffer의 모양입니다.
dataType 생성할 TensorBuffer의 dataType입니다.
생성 값
NullPointerException shape가 null인 경우
IllegalArgumentException shape에 양수가 아닌 요소가 있는 경우.

<ph type="x-smartling-placeholder"></ph> 공개 정적 TensorBuffer createFrom (TensorBuffer 버퍼, DataType dataType)

지정된 DataType를 사용하여 다른 항목에서 딥 복사 데이터를 만드는 TensorBuffer를 만듭니다.

매개변수
버퍼 복사할 소스 TensorBuffer입니다.
dataType 새로 생성된 TensorBuffer의 예상 DataType입니다.
생성 값
NullPointerException buffer가 null인 경우

<ph type="x-smartling-placeholder"></ph> 공개 ByteBuffer getBuffer ()

데이터 버퍼를 반환합니다.

<ph type="x-smartling-placeholder"></ph> 공개 추상 DataType getDataType ()

이 버퍼의 데이터 유형을 반환합니다.

<ph type="x-smartling-placeholder"></ph> 공개 정수 를 통해 개인정보처리방침을 정의할 수 있습니다. getFlatSize ()

버퍼의 splitSize를 가져옵니다.

생성 값
IllegalStateException 기본 데이터가 손상된 경우

<ph type="x-smartling-placeholder"></ph> 공개 추상 float[] 를 통해 개인정보처리방침을 정의할 수 있습니다. getFloatArray ()

이 버퍼에 저장된 값의 부동 소수점 배열을 반환합니다. 버퍼의 유형이 다른 경우 값이 부동 소수점 수로 변환됩니다. 예를 들어 TensorBufferUint8의 값은 uint8에서 float로 변환됩니다.

<ph type="x-smartling-placeholder"></ph> 공개 추상 부동 소수점 수 를 통해 개인정보처리방침을 정의할 수 있습니다. getFloatValue (int absIndex)

주어진 색인의 부동 소수점 값을 반환합니다. 버퍼의 유형이 부동 소수점 수와 다른 경우 값이 부동 소수점 수로 변환됩니다. 예를 들어 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 배열을 반환합니다. 버퍼의 유형이 다른 경우 값이 int로 변환되며 정밀도 손실이 적용될 수 있습니다. 예를 들어 값이 {400.32f, 23.04f}인 TensorBufferFloat에서 int 배열을 가져오면 출력은 {400, 23}입니다.

<ph type="x-smartling-placeholder"></ph> 공개 추상 정수 를 통해 개인정보처리방침을 정의할 수 있습니다. getIntValue (int absIndex)

지정된 색인에서 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 ()

배열에서 단일 요소의 바이트 수를 반환합니다. 예를 들어, 부동 버퍼는 4를 반환하고 바이트 버퍼는 1을 반환합니다.

<ph type="x-smartling-placeholder"></ph> 공개 불리언 를 통해 개인정보처리방침을 정의할 수 있습니다. isDynamic ()

TensorBuffer의 크기가 동적인 경우 (임의의 크기 조절 가능)를 반환합니다.

<ph type="x-smartling-placeholder"></ph> 공개 추상 무효 를 통해 개인정보처리방침을 정의할 수 있습니다. loadArray (int[] src, int[] 도형)

int 배열을 특정 형태로 이 버퍼에 로드합니다. 버퍼의 유형이 다른 경우 정수가 아닌 경우 값은 버퍼의 유형으로 변환되고 정밀도 손실이 적용될 수 있습니다 예를 들어 값이 {400, -23}을 TensorBufferUint8로 변환하면 값이 [0, 255] 로 고정되고 {255, 0}에 의해 uint8로 전송됩니다.

매개변수
src 로드할 소스 배열입니다.
shape src가 나타내는 텐서의 형태입니다.
생성 값
NullPointerException src가 null인 경우
NullPointerException shape가 null인 경우
IllegalArgumentException 로드할 배열의 크기가 지정합니다.

<ph type="x-smartling-placeholder"></ph> 공개 추상 무효 를 통해 개인정보처리방침을 정의할 수 있습니다. loadArray (float[] src, int[] 도형)

이 버퍼에 특정 모양의 부동 배열을 로드합니다. 버퍼의 유형이 다른 경우 이 값은 버퍼의 유형으로 변환되고 정밀도 손실이 적용될 수 있습니다 예를 들어 값이 {400.32f, -23.04f}인 TensorBufferUint8에 부동 배열을 로드하면 값이 [0, 255] 로 고정되고 그런 다음 {255, 0}로 uint8로 전송됩니다.

매개변수
src 로드할 소스 배열입니다.
shape src가 나타내는 텐서의 형태입니다.
생성 값
NullPointerException src가 null인 경우
NullPointerException shape가 null인 경우
IllegalArgumentException 로드할 배열의 크기가 지정합니다.

<ph type="x-smartling-placeholder"></ph> 공개 무효 를 통해 개인정보처리방침을 정의할 수 있습니다. loadArray (float[] src)

이 버퍼에 부동 배열을 로드합니다. 버퍼의 유형이 부동 소수점 수와 다른 경우 값은 버퍼로 로드되기 전에 버퍼의 유형으로 변환되며 적용될 수 있습니다. 예를 들어 부동 배열을 TensorBufferUint8에 로드합니다. 값이 {400.32f, -23.04f}인 경우, 값은 [0, 255] 로 고정된 다음 uint8 x {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] 로 고정된 다음 {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가 읽기 전용인 경우 성능을 위해 COW(기록 중 복사) 전략을 채택합니다.

매개변수
버퍼 로드할 바이트 버퍼입니다.

<ph type="x-smartling-placeholder"></ph> 공개 무효 를 통해 개인정보처리방침을 정의할 수 있습니다. loadBuffer (ByteBuffer 버퍼, int[] 도형)

TensorBuffer에 특정 형태의 바이트 버퍼를 로드합니다.

중요: 로드된 버퍼는 참조입니다. 수정하지 마세요. 여기에 사본을 만들지는 않습니다. 수정이 필요한 경우 사본을 만드세요.

최상의 성능을 위해 항상 직접 ByteBuffer 또는 ByteBuffer를 로드하세요. 배열로 지원됩니다

매개변수
버퍼 로드할 바이트 버퍼입니다.
shape
생성 값
NullPointerException buffer가 null인 경우
IllegalArgumentException buffertypeSize의 크기가 bufferflatSize의 크기가 일치하지 않습니다.