Deeplearning4j-nd4j Method Quick Index

Source: Internet
Author: User
Tags mul rand scalar sin
deeplearning4j-nd4j Method Quick Index

ND4J and nd4s are scientific computing libraries for the JVM and are designed for production environments, where routines run fast and have low RAM requirements.

Main Features: Multi-purpose Multidimensional Array object multi-platform function, including GPU linear algebra and signal processing functions

Due to the gap in usability, Java, Scala, and Clojure programmers cannot take full advantage of the most powerful tools for data analysis such as NumPy or MATLAB. Other libraries, such as breeze, do not support multidimensional arrays or tensor, which is the key to deep learning and other tasks. Nd4j and nd4s are being used by national laboratories to complete climate modelling tasks. Such tasks require computationally intensive simulations to be performed.

Nd4j in an open source, distributed, GPU-enabled library, it brings intuitive, scientific computing tools for Python programmers to the JVM. Structurally, nd4j is similar to SLF4J. ND4J enables engineers in production environments to easily port algorithms and interfaces to other libraries within the Java and Scala architectures.Create NdarrayCreate a value of 0:nd4j.zeros (NRows, NCols) nd4j.zeros (int ...) create a line vector or column vector that is all 1:nd4j.ones (nRows, nCols) copy NDArray:arr.dup (): Myrow = Nd4j.create (Mydoublearr), MyCol = Nd4j.create (mydoublearr,new int[]{10,1}) Create two-dimensional double[][using NDArray:Nd4j.creat] E (double[][]) Ndarray stacking from rows or columns: Nd4j.hstack (Indarray ...) Nd4j.vstack (Indarray ...) creates an element that obeys the NDArray:Nd4j.rand (int,int) Nd4j.rand (int[]) of the normal (0,1) range of NDArray:Nd4j.randn (int, int) Nd4j.randn (int[])
get the properties of NdarrayGet Dimension: Rank () A method that is useful only for two-dimensional ndarray, gets the number of rows and columns: Rows () columns () Length of dimension i: Size (i) Gets the shape of the Ndarray: shape () Gets the number of all elements: Arr.length ( ) determine the type of Ndarray: Ismatrix () Isvector () Isrowvector () Isrowvector ()Gets or sets a specific valueFor line I, the value of column J: arr.getdouble (i,j) Gets a value that exceeds the three-dimensional Ndarray: arr.getdouble (int[]) assigns a value to a specific location: Arr.putscalar (int[],double)tensor operationAdd a value: Arr1.add (MyDouble) minus one value: Arr1.sub (MyDouble) multiplied by a value: Arr.mul (MyDouble) divided by one value: Arr.div (mydouble) subtraction inverse operation (Scalar- ARR1): Arr1.rsub (mydouble) Division inverse Operation (SCALAR/ARR1): Arr1.rdiv (MyDouble)Element (element-wise) operationAdd: Arr1.add (arr2) minus: Arr1.sub (ARR2) by: Arr1.mul (ARR2) except: Arr1.div (ARR2) Assignment: Arr1.assign (ARR2)protocol OperationSum of all elements: Arr.sumnumber () Product of all elements: Arr.prod () L1 or L2 norm: Arr.norm1 () Arr.norm2 () standard deviation of all elements: Arr.stdnumber ()linear algebra OperationsMatrix multiplication: Arr1.mmul (arr2) matrix transpose: Transpose () Get diagonal matrix: Nd4j.diag (Indarray) matrix inversion: Invertmatrix.invert (Indarray,boolean)Get Ndarray partGet a row (for 2-D Ndarray only): GetRow (int) gets multiple lines (only for 2-D Ndarray): getRows (int ...) sets one line (only for 2-dimensional Ndarray): PutRow (Int,indarray) Gets the first three rows, Values for all columns: nd4j.create (0). Get (Ndarrayindex.interval (0,3), Ndarrayindex.all ());element-level transformations (Tanh, Sigmoid, Sin, Log etc)Using Transform:Transforms.sin (Indarray) Transforms.log (Indarray) transforms.sigmoid (Indarray) Method 1: Nd4j.getexecutioner (). Execandreturn (New Tanh (Indarray)) method 2:nd4j.getexecutioner (). Execandreturn ( Nd4j.getopfactory (). CreateTransform ("Tanh", Indarray))

Reference: Https://nd4j.org/userguide Https://nd4j.org/cn/index using nd4j to achieve PCA dimensionality reduction: https://github.com/deeplearning4j/nd4j/ blob/master/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/dimensionalityreduction/ Pca.java ND4J Basic Operation code example: Https://github.com/sjsdfg/dl4j-tutorials

More documents can be viewed https://github.com/sjsdfg/deeplearning4j-issues.
Your star is my driving force for continuous sharing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.