Upload
adam-gibson
View
166
Download
2
Embed Size (px)
Citation preview
ND4J
ND-ARRAYS FOR JAVA
SCIENTIFIC COMPUTING ON THE JVM
Why another scientific library?
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
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)
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
Numpy
>>> import numpy as np
>>> a = np.ones((5,5))
>>> np.sum(a,axis=1)
array([ 5., 5., 5., 5., 5.])
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]
Blas Implementations
● Cublas (cuda)
● Openblas
● Intel MKL(cpu)
● Nvblas(cuda)
● Clblas(opencl)
● ATLAS(CPU)
● LAPACK(CPU)
ND4J
A DISTRIBUTED FRAMEWORK
FOR MATRIX MANIPULATION
NATIVE
JBLAS
GPU
JCUDA ??
WITH SWAPPABLE BACKENDS…
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
Other Features
● Loss Functions
● Adaptive learning rates
● Solvers (LBFGS,Conjugate gradient,Hessian Free,SGD)
● RNG: (DIfferent distributions based on apache math)
ND4J
ND4J IS PORTABLE
& CROSS-PLATFORM
DESKTOP CLOUD MOBILE
ND4J
ND4J SUPPORTS
JAVA
SCAL
A CLOJURE
ND4J
FAMILIAR SEMANTICS
NUMPY
MATLA
B
SCIKIT-
LEARN