NdArraySequence
Koleksiyonlar ile düzeninizi koruyun
İçeriği tercihlerinize göre kaydedin ve kategorilere ayırın.
Bilinen Dolaylı Alt Sınıflar |
N boyutlu bir dizinin öğeleri dizisi.
Bir NdArraySequence
bir NdArray
belirli bir boyutta geçmek ve öğelerinin her birini ziyaret etmek için kullanılır. Örneğin, [x, y]
eksenlerinde bir nxm
matrisi verildiğinde, öğeler aşağıdaki sırayla yinelenir:
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
Genel Yöntemler
soyut NdArraySequence <T> | |
soyut geçersiz | forEachIndexed (BiConsumer<long[], T> tüketicisi) Bu yinelemenin her bir öğesini ve ilgili koordinatlarını ziyaret edin. |
Kalıtsal Yöntemler
Java.lang.Iterable arayüzünden soyut geçersiz | forEach (Tüketici<? süper T> arg0) |
soyut Yineleyici<T> | yineleyici () |
soyut Ayırıcı<T> | ayırıcı () |
Genel Yöntemler
Her öğeyi yeni bir dilim olarak döndürür.
Geleneksel Java koleksiyonlarından farklı olarak, NdArraySequence
öğeleri geçicidir, yani her yineleme için yeni NdArray
örnekleri tahsis edilir. Performansı artırmak için aynı örnek, DataBufferWindow
kullanılarak bu dizinin tüm öğelerini görüntülemek üzere geri dönüştürülebilir.
Ancak bazı durumlarda, döndürülen her öğenin orijinal dizinin yeni bir dilimi olmasını sağlamak için bu tür optimizasyonların devre dışı bırakılması tercih edilebilir. Örneğin, ziyaret edilen bir veya daha fazla öğenin dizi yinelemesinin kapsamı dışında kalması gerekiyorsa asSlices()
dizi tarafından döndürülen tüm öğelerin benzersiz örnekler olmasını sağlar.
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
İade
- yeni bir dilim olarak yinelenen her öğeyi döndüren bir dizi
forEachIndexed genel özet geçersiz (BiConsumer<long[], T> tüketicisi)
Bu yinelemenin her bir öğesini ve ilgili koordinatlarını ziyaret edin.
Önemli: Tüketici yöntemi, performansı artırmak için yineleme sırasında değiştirilebileceğinden ve yeniden kullanılabildiğinden koordinatlara referans tutmamalıdır.
Parametreler
tüketici | her öğe için çağrılacak yöntem |
---|
Aksi belirtilmediği sürece bu sayfanın içeriği Creative Commons Atıf 4.0 Lisansı altında ve kod örnekleri Apache 2.0 Lisansı altında lisanslanmıştır. Ayrıntılı bilgi için Google Developers Site Politikaları'na göz atın. Java, Oracle ve/veya satış ortaklarının tescilli ticari markasıdır.
Son güncelleme tarihi: 2025-07-26 UTC.
[null,null,["Son güncelleme tarihi: 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|----------|------------------------------------|"]]