Skip to content

kkalass/nd4j

Repository files navigation

ND4J

A Numpy and Matlab like environment for cross-platform scientific computing.

  • Supports GPUs via CUDA and Native via Jblas.
  • All of this is wrapped in a unifying interface.
  • The API is a mix of Numpy and Jblas.

An example creation:

       INDArray arr = Nd4j.create(new float[]{1,2,3,4},new int[]{2,2});

This will create a 2 x 2 NDarray.

The project works as follows:

Include the following in your pom.xml.

        <dependency>
         <artifactId>nd4j</artifactId>
         <groupId>org.nd4j</groupId>
         <artifactId>nd4j-api</artifactId>
         <version>0.0.3.5.2</version>
        </dependency>

From there, you need to pick a suitable implementation. This can be either Jblas for native or Cuda for GPUs.

Jblas:

        <dependency>
           <artifactId>nd4j</artifactId>
           <groupId>org.nd4j</groupId>
           <artifactId>nd4j-jblas</artifactId>
           <version>0.0.3.5.2</version>
        </dependency>

Jcuda:

        <dependency>
         <artifactId>nd4j</artifactId>
         <groupId>org.nd4j</groupId>
         <artifactId>nd4j-jcublas</artifactId>
         <version>0.0.3.5.2</version>
        </dependency>

We are still in the process of streamlining the release for for Jcuda. For now, please do the following:

         git clone https://github.com/SkymindIO/mavenized-jcuda
         cd mavenized-jcuda
         mvn clean install

This will install the Jcuda jar files.

You need to specify a version of Jcuda to use as well. The version will depend on your GPU. Amazon supports 0.5.5.

Basics

In-place operations:

         INDArray arr = Nd4j.create(new float[]{1,2,3,4},new int[]{2,2});
         //scalar operation
         arr.addi(1);

         //element wise operations
         INDArray arr2 = ND4j.create(new float[]{5,6,7,8},new int[]{2,2});
         arr.addi(arr2);

Duplication operations:

         //clone then add
         arr.add(1);
         //clone then add
         arr.add(arr2);

Dimensionwise operations (column and row order depending on the implementation chosen)

         arr.sum(0);

About

Scientific Computing for the JVM (NDArrays)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 93.8%
  • Cuda 3.5%
  • Scala 1.8%
  • C 0.7%
  • C++ 0.2%
  • HTML 0.0%