xiaoxiao2021-02-28  8

Starting a New ND4J Project

To create a new ND4J project within IntelliJ, either click on “Open Project” on IntelliJ’s opening screen, or click on the File/Open tab, and choose “nd4j.” If you have cloned the source files from Github, the directory should be available from IntelliJ.

To create a new ND4J project within IntelliJ, just put the right dependencies in your project’s POM.xml file. With those in place, Maven will be able to build ND4J for you. Pasting the right dependencies into your POM amounts to installing ND4J – no other install is necessary.

Select maven-archetype-quickstart.

The images below will walk you through the windows of the IntelliJ New Project Wizard using Maven. First, name your group and artifact as you please.

Click through the following screen with “Next”, and on the screen after that, name your project (“ND4J-test”, for example) and hit finish. Now go into your POM.xml file within the root of the new ND4J project in IntelliJ.

Update the POM file with the dependences you’ll need. These will vary depending on whether you’re running on CPUs or GPUs.

The default backend for CPUs is nd4j-native-platform, and for CUDA it isnd4j-cuda-7.5-platform. You can paste that into the<dependencies> ... </dependencies> section of your POM like this:

xml <dependency> <groupId>org.nd4j</groupId> <artifactId>nd4j-native-platform</artifactId> <version>${nd4j.version}</version> </dependency>

ND4J’s version is a variable here. It will refer to another line higher in the POM, in the<properties> ... </properties> section, specifying the nd4j version and appearing similar to this:

xml <nd4j.version></nd4j.version>

The dl4j version and DataVec version are also .

Version `` or higher now includes all backends by default and binaries for all platforms are automatically pulled. It is recommended to not alter this behaviorespecially if you are building on one platform but deploying to another (OS X vs. Linux). However, you can also explicitly pull binaries only for the platforms you are using. Information on how to do this can be found on thedependencies page.

import org.nd4j.linalg.api.ndarray.INDArray; import org.nd4j.linalg.factory.Nd4j; /** * Created by ESRI on 2017/11/4. */ public class Test1 { public static void main(String args[]){ INDArray x = Nd4j.create(new double[]{1, 2, 3, 4, 5, 6}, new int[]{3, 2}); System.out.println(x); } } SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See for further details. -- org.jblas INFO Starting temp DLL cleanup task. [[1.00,2.00] [3.00,4.00] [5.00,6.00]]