deepjavalibrary / djl

An Engine-Agnostic Deep Learning Framework in Java
https://djl.ai
Apache License 2.0
4.07k stars 650 forks source link

How to create multidimensional arrays using NDManager.create() #2219

Closed 285220927 closed 1 year ago

285220927 commented 1 year ago

In python, we can use np.array([[[1, 2], [2, 3], [11, 22], [22, 33]], [[1, 2], [2, 3], [11, 22], [22, 33]]]) to create a three-dimensional array. The create method in djl can only support two-dimensional arrays. Is there a better way to create it besides reshape?

frankfliu commented 1 year ago
            int[] data = {1, 2, 2, 3, 11, 22, 22, 33, 1, 2, 2, 3, 11, 22, 22, 33};
            NDArray array = manager.create(data, new Shape(2, 3, 2));
frankfliu commented 1 year ago

Feel free to reopen the issue if you have further question