NdArraySequence
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
N차원 배열의 요소 시퀀스입니다.
NdArraySequence
주어진 차원에서 NdArray
탐색하고 각 요소를 방문하는 데 사용됩니다. 예를 들어, [x, y]
축에 nxm
행렬이 있는 경우 요소는 다음 순서로 반복됩니다.
x 0 y 0 , x 0 y 1 , ..., x 0 y m-1 , x 1 y 0 , x 1 y 1 , ..., x n-1 y m-1
상속된 메서드
인터페이스 java.lang.Iterable에서 추상적인 공백 | forEach (소비자<? super T> arg0) |
추상 반복자<T> | 반복자 () |
추상 분할기<T> | 분할기 () |
공개 방법
각 요소를 새 슬라이스로 반환합니다.
기존 Java 컬렉션과 달리 NdArraySequence
의 요소는 일시적입니다. 즉, 각 반복마다 새로운 NdArray
인스턴스가 할당됩니다. 성능을 향상시키기 위해 DataBufferWindow
를 사용하여 동일한 인스턴스를 재활용하여 이 시퀀스의 모든 요소를 볼 수 있습니다.
그러나 어떤 경우에는 반환된 각 요소가 원래 배열의 새로운 조각인지 확인하기 위해 이러한 최적화를 비활성화하는 것이 더 나을 수도 있습니다. 예를 들어, 방문한 하나 이상의 요소가 시퀀스 반복 범위를 벗어나야 하는 경우 asSlices()
시퀀스에서 반환된 모든 요소가 고유한 인스턴스인지 확인합니다.
final List<IntNdArray> vectors = new ArrayList<>();
IntNdArray matrix = NdArrays.ofInts(Shape.of(6, 6));
ndArray.elements(0).forEach(e -> vectors::add); // Not safe, as `e` might always be the same recycled instance
ndArray.elements(0).asSlices().forEach(e -> vectors::add); // Safe, each `e` is a distinct NdArray instance
보고
- 새로운 슬라이스로 반복되는 각 요소를 반환하는 시퀀스
공개 추상 무효 forEachIndexed (BiConsumer<long[], T> 소비자)
이 반복의 각 요소와 해당 좌표를 방문하세요.
중요: 성능 향상을 위해 반복 중에 좌표가 변경 가능하고 재사용될 수 있으므로 소비자 메서드는 좌표에 대한 참조를 유지해서는 안 됩니다.
,
N차원 배열의 요소 시퀀스입니다.
NdArraySequence
주어진 차원에서 NdArray
탐색하고 각 요소를 방문하는 데 사용됩니다. 예를 들어, [x, y]
축에 nxm
행렬이 있는 경우 요소는 다음 순서로 반복됩니다.
x 0 y 0 , x 0 y 1 , ..., x 0 y m-1 , x 1 y 0 , x 1 y 1 , ..., x n-1 y m-1
상속된 메서드
인터페이스 java.lang.Iterable에서 추상적인 공백 | forEach (소비자<? super T> arg0) |
추상 반복자<T> | 반복자 () |
추상 분할기<T> | 분할기 () |
공개 방법
각 요소를 새 슬라이스로 반환합니다.
기존 Java 컬렉션과 달리 NdArraySequence
의 요소는 일시적입니다. 즉, 각 반복마다 새로운 NdArray
인스턴스가 할당됩니다. 성능을 향상시키기 위해 DataBufferWindow
를 사용하여 동일한 인스턴스를 재활용하여 이 시퀀스의 모든 요소를 볼 수 있습니다.
그러나 어떤 경우에는 반환된 각 요소가 원래 배열의 새로운 조각인지 확인하기 위해 이러한 최적화를 비활성화하는 것이 더 나을 수도 있습니다. 예를 들어, 방문한 하나 이상의 요소가 시퀀스 반복 범위를 벗어나야 하는 경우 asSlices()
시퀀스에서 반환된 모든 요소가 고유한 인스턴스인지 확인합니다.
final List<IntNdArray> vectors = new ArrayList<>();
IntNdArray matrix = NdArrays.ofInts(Shape.of(6, 6));
ndArray.elements(0).forEach(e -> vectors::add); // Not safe, as `e` might always be the same recycled instance
ndArray.elements(0).asSlices().forEach(e -> vectors::add); // Safe, each `e` is a distinct NdArray instance
보고
- 새로운 슬라이스로 반복되는 각 요소를 반환하는 시퀀스
공개 추상 무효 forEachIndexed (BiConsumer<long[], T> 소비자)
이 반복의 각 요소와 해당 좌표를 방문하세요.
중요: 성능 향상을 위해 반복 중에 좌표가 변경 가능하고 재사용될 수 있으므로 소비자 메서드는 좌표에 대한 참조를 유지해서는 안 됩니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-26(UTC)
[null,null,["최종 업데이트: 2025-07-26(UTC)"],[],[],null,["# NdArraySequence\n\npublic interface **NdArraySequence** \n\n|---|---|---|\n| Known Indirect Subclasses [FastElementSequence](/jvm/api_docs/java/org/tensorflow/ndarray/impl/sequence/FastElementSequence)\\\u003cT, U extends [NdArray](/jvm/api_docs/java/org/tensorflow/ndarray/NdArray)\\\u003cT\\\u003e\\\u003e, [SingleElementSequence](/jvm/api_docs/java/org/tensorflow/ndarray/impl/sequence/SingleElementSequence)\\\u003cT, U extends [NdArray](/jvm/api_docs/java/org/tensorflow/ndarray/NdArray)\\\u003cT\\\u003e\\\u003e, [SlicingElementSequence](/jvm/api_docs/java/org/tensorflow/ndarray/impl/sequence/SlicingElementSequence)\\\u003cT, U extends [NdArray](/jvm/api_docs/java/org/tensorflow/ndarray/NdArray)\\\u003cT\\\u003e\\\u003e |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------| | [FastElementSequence](/jvm/api_docs/java/org/tensorflow/ndarray/impl/sequence/FastElementSequence)\\\u003cT, U extends [NdArray](/jvm/api_docs/java/org/tensorflow/ndarray/NdArray)\\\u003cT\\\u003e\\\u003e | A sequence recycling the same `NdArray` instance when iterating its elements | | [SingleElementSequence](/jvm/api_docs/java/org/tensorflow/ndarray/impl/sequence/SingleElementSequence)\\\u003cT, U extends [NdArray](/jvm/api_docs/java/org/tensorflow/ndarray/NdArray)\\\u003cT\\\u003e\\\u003e | A sequence of one single element | | [SlicingElementSequence](/jvm/api_docs/java/org/tensorflow/ndarray/impl/sequence/SlicingElementSequence)\\\u003cT, U extends [NdArray](/jvm/api_docs/java/org/tensorflow/ndarray/NdArray)\\\u003cT\\\u003e\\\u003e | A sequence creating a new `NdArray` instance (slice) for each element of an iteration | |||\n\nA sequence of elements of an N-dimensional array.\n\nAn `NdArraySequence` is used to traverse an `NdArray` in a given dimension\nand visit each of its elements. For example, given a `n x m` matrix on the `[x, y]` axes,\nelements are iterated in the following order:\n\nx~0~y~0~, x~0~y~1~, ..., x~0~y~m-1~, x~1~y~0~, x~1~y~1~, ..., x~n-1~y~m-1~\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n### Public Methods\n\n|--------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [NdArraySequence](/jvm/api_docs/java/org/tensorflow/ndarray/NdArraySequence)\\\u003cT\\\u003e | [asSlices](/jvm/api_docs/java/org/tensorflow/ndarray/NdArraySequence#asSlices())() Returns each element as a new slice. |\n| abstract void | [forEachIndexed](/jvm/api_docs/java/org/tensorflow/ndarray/NdArraySequence#forEachIndexed(java.util.function.BiConsumer\u003clong[], T\u003e))(BiConsumer\\\u003clong\\[\\], T\\\u003e consumer) Visit each elements of this iteration and their respective coordinates. |\n\n### Inherited Methods\n\nFrom interface java.lang.Iterable \n\n|---------------------------|-------------------------------------|\n| abstract void | forEach(Consumer\\\u003c? super T\\\u003e arg0) |\n| abstract Iterator\\\u003cT\\\u003e | iterator() |\n| abstract Spliterator\\\u003cT\\\u003e | spliterator() |\n\nPublic Methods\n--------------\n\n#### public abstract [NdArraySequence](/jvm/api_docs/java/org/tensorflow/ndarray/NdArraySequence)\\\u003cT\\\u003e\n**asSlices**\n()\n\nReturns each element as a new slice.\n\nUnlike conventional Java collections, elements of a `NdArraySequence` are transient, i.e. new `NdArray`\ninstances are allocated for each iteration. To improve performance, the same instance can be recycled to view\nall elements of this sequence, using a [DataBufferWindow](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/DataBufferWindow).\n\nIn some cases though, it might be preferable to disable such optimizations to ensure that each element returned is a\nnew slice of the original array. For example, if one or more elements visited must live beyond the scope of the sequence\niteration, `asSlices()` makes sure that all elements returned by the sequence are unique instances.\n\n final List\u003cIntNdArray\u003e vectors = new ArrayList\u003c\u003e();\n IntNdArray matrix = NdArrays.ofInts(Shape.of(6, 6));\n ndArray.elements(0).forEach(e -\u003e vectors::add); // Not safe, as `e` might always be the same recycled instance\n ndArray.elements(0).asSlices().forEach(e -\u003e vectors::add); // Safe, each `e` is a distinct NdArray instance\n \n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n##### Returns\n\n- a sequence that returns each elements iterated as a new slice \n\n##### See Also\n\n- [DataBufferWindow](/jvm/api_docs/java/org/tensorflow/ndarray/buffer/DataBufferWindow) \n\n#### public abstract void\n**forEachIndexed**\n(BiConsumer\\\u003clong\\[\\], T\\\u003e consumer)\n\nVisit each elements of this iteration and their respective coordinates.\n\n*Important: the consumer method should not keep a reference to the coordinates\nas they might be mutable and reused during the iteration to improve performance.*\n\n\u003cbr /\u003e\n\n##### Parameters\n\n| consumer | method to invoke for each elements |\n|----------|------------------------------------|"]]