Quickstart
Hands-on quickstart guide for ND4J — creating arrays, basic operations, indexing, and shape manipulation
Maven Setup
<properties>
<dl4j.version>1.0.0-M2.1</dl4j.version>
</properties>
<dependencies>
<!-- ND4J API -->
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-api</artifactId>
<version>${dl4j.version}</version>
</dependency>
<!-- CPU backend — replaces this with nd4j-cuda-11.x-platform for GPU -->
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-native-platform</artifactId>
<version>${dl4j.version}</version>
</dependency>
</dependencies>Imports Used in This Guide
Array Creation
zeros, ones, rand
createFromArray
arange and linspace
Array Properties
Printing Arrays
Basic Operations
Copy operations (non-destructive)
In-place operations (i suffix)
Operation
Copy
In-place
Data type requirement
Reduction Operations
Transform Operations
Matrix Multiplication
Indexing and Slicing
Single-element access
Exporting to Java arrays
Slicing with NDArrayIndex
Assigning into a slice
Shape Manipulation
reshape and ravel
Transpose
Stacking Arrays
Copies vs Views
Reference assignment — no copy
Views — shallow copy
Deep copy with dup()
Quick Reference
Array creation
Method
Description
Element-wise arithmetic
Op
Copy
In-place
Reductions
Method
Result
Transforms (Transforms class)
Method
Description
Shape manipulation
Method
Returns
Notes
Last updated
Was this helpful?