15
ND4J ND-ARRAYS FOR JAVA SCIENTIFIC COMPUTING ON THE JVM

Nd4 j slides.pptx

Embed Size (px)

Citation preview

Page 1: Nd4 j slides.pptx

ND4J

ND-ARRAYS FOR JAVA

SCIENTIFIC COMPUTING ON THE JVM

Page 2: Nd4 j slides.pptx

Why another scientific library?

Page 3: Nd4 j slides.pptx

Different libraries:

JVM:

● Jblas (not

maintained)

● Breeze (scala)

● Spire (scala)

● Core.matrix(clojure)

● Netlib blas

● N + 1 pure java

impls

Real scientific

environments (no

fragmentation!):

● octave/matlab

● numpy

● R

● Theano

Page 4: Nd4 j slides.pptx

Blas and NDArrays

BLAS - Basic Linear Algebra Sub programs. Underlies EVERY fast

matrix lib out there.

NDArrays - matrices, tensors, math is done on axes (eg: rows/cols)

Page 5: Nd4 j slides.pptx

Matlab/Octave

a = ones(5,5)

a =

1 1 1 1 1

1 1 1 1 1

1 1 1 1 1

1 1 1 1 1

1 1 1 1 1

octave:2> sum(a,1)

ans =

5 5 5 5 5

Page 6: Nd4 j slides.pptx

Numpy

>>> import numpy as np

>>> a = np.ones((5,5))

>>> np.sum(a,axis=1)

array([ 5., 5., 5., 5., 5.])

Page 7: Nd4 j slides.pptx

Nd4j java/scala

import org.nd4j.api.linalg.DSL._

import org.nd4j.linalg.api.ndarray.INDArray

import org.nd4j.linalg.factory.Nd4j

val a = Nd4j.ones(5,5)

println Nd4j.sum(a,1)

[5.0, 5.0, 5.0, 5.0, 5.0]

Page 8: Nd4 j slides.pptx

Blas Implementations

● Cublas (cuda)

● Openblas

● Intel MKL(cpu)

● Nvblas(cuda)

● Clblas(opencl)

● ATLAS(CPU)

● LAPACK(CPU)

Page 9: Nd4 j slides.pptx

ND4J

A DISTRIBUTED FRAMEWORK

FOR MATRIX MANIPULATION

NATIVE

JBLAS

GPU

JCUDA ??

WITH SWAPPABLE BACKENDS…

Page 10: Nd4 j slides.pptx

Core Concepts

● DataBuffer - A DataBuffer is a storage abstraction. A raw buffer

could be an nio buffer or a jcuda buffer. This allows for backend

optimal storage.

● FFTInstance - An instantiation of FFT. Every hardware maker has

their own impls.

● ConvolutionInstance - An instantiation of Convolution. Same as FFT

● Complex Numbers - (An abstraction over different libs)

● BlasWrapper - An interface to a blas backend (blas is a standard for

cripe sakes!)

● Op - Some sort of a mathematical operation (dot product, element

wise addition,negation,..)

● Garbage Collector (WIP) - Native resource handling where needed

Page 11: Nd4 j slides.pptx

Other Features

● Loss Functions

● Adaptive learning rates

● Solvers (LBFGS,Conjugate gradient,Hessian Free,SGD)

● RNG: (DIfferent distributions based on apache math)

Page 12: Nd4 j slides.pptx

ND4J

ND4J IS PORTABLE

& CROSS-PLATFORM

DESKTOP CLOUD MOBILE

Page 13: Nd4 j slides.pptx

ND4J

ND4J SUPPORTS

JAVA

SCAL

A CLOJURE

Page 14: Nd4 j slides.pptx

ND4J

FAMILIAR SEMANTICS

NUMPY

MATLA

B

SCIKIT-

LEARN

Page 15: Nd4 j slides.pptx

ND4J

ADAM GIBSON

[email protected]