Road map for beginners new to deep learning.
Where you start depends on what you already know.
The prerequisites for really understanding deep learning are linear algebra, calculus and statistics, as well as programming and some machine learning. The prerequisites for applying it are just learning how to deploy a model.
In the case of Deeplearning4j, you should know Java well and be comfortable with tools like the IntelliJ IDE and the automated build tool Maven.
Below you'll find a list of resources. The sections are roughly organized in the order they will be useful.
Patrick Winston's Introduction to Artificial Intelligence @MIT (For those interested in a survey of artificial intelligence.)
Andrej Karpathy's Convolutional Neural Networks Class at Stanford (For those interested in image recognition.)
The math involved with deep learning is basically linear algebra, calculus and probability, and if you have studied those at the undergraduate level, you will be able to understand most of the ideas and notation in deep-learning papers. If haven't studied those in college, never fear. There are many free resources available (and some on this website).
Linear Algebra for Machine Learning; Patrick van der Smagt
If you do not know how to program yet, you can start with Java, but you might find other languages easier. Python and Ruby resources can convey the basic ideas in a faster feedback loop. "Learn Python the Hard Way" and "Learn to Program (Ruby)" are two great places to start.
A Vim Tutorial and Primer (Vim is an editor accessible from the command line.)
If you want to jump into deep-learning from here without Java, we recommend Theano and the various Python frameworks built atop it, including Keras and Lasagne.
Once you have programming basics down, tackle Java, the world's most widely used programming language. Most large organizations in the world operate on huge Java code bases. (There will always be Java jobs.) The big data stack -- Hadoop, Spark, Kafka, Lucene, Solr, Cassandra, Flink -- have largely been written for Java's compute environment, the JVM.
With that under your belt, we recommend you approach Deeplearning4j through its examples.
Most of what we know about deep learning is contained in academic papers. You can find some of the major research groups here.
While individual courses have limits on what they can teach, the Internet does not. Most math and programming questions can be answered by Googling and searching sites like Stackoverflow and Math Stackexchange.
Quickstart for Java using Maven
This is everything you need to run DL4J examples and begin your own projects.
We recommend that you join our . There you can request help and give feedback, but please do use this guide before asking questions we've answered below. If you are new to deep learning, we've included with links to courses, readings and other resources.
If you just want to get started, please consider reading our .
We are currently reworking the Getting Started Guide.
If you find that you have trouble following along here, take a look at the Konduit blog, as it features .
Deeplearning4j started as a domain-specific language to configure deep neural networks, and evolved in to a suite of tools developers use to do everything from train models in java to deploy models to production.
Use cases include: 1. Numerical computation. See:
2. Define and train models using a tensorflow/pytorch like interface. See:
3. Model import and deployment. See:
4. Running models on spark. See:
5. A small self contained library for running math code. See:
Other use cases are available as well, please feel free to check more of our
You should have these installed to use this QuickStart guide. DL4J targets professional Java developers who are familiar with production deployments, IDEs and automated build tools. Working with DL4J will be easiest if you already have experience with these.
Please make sure you have a 64-Bit version of java installed, as you will see an error telling you no jnind4j in java.library.path
if you decide to try to use a 32-Bit version instead. Make sure the JAVA_HOME environment variable is set.
If you are working on a Mac, you can simply enter the following into the command line:
The latest version of Mac's Mojave OS breaks git, producing the following error message:
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
This can be fixed by running:
Use the command line to enter the following:
Open IntelliJ and choose Import Project. Then select the dl4j-examples
directory.
Choose 'Import project from external model' and ensure that Maven is selected.
Continue through the wizard's options. Select the SDK that begins with jdk
. (You may need to click on a plus sign to see your options...) Then click Finish. Wait a moment for IntelliJ to download all the dependencies. You'll see the horizontal bar working on the lower right.
Pick an example from the file tree on the left. Right-click the file to run.
The example repository contains multiple example projects that are grouped by different levels of functionality. The dl4j-examples
project you just opened has the simplest examples, but feel free to explore the other projects too!
To run DL4J in your own projects, we highly recommend using Maven for Java users, or a tool such as SBT for Scala. The basic set of dependencies and their versions are shown below. This includes:
deeplearning4j-core
, which contains the neural network implementations
nd4j-native-platform
, the CPU version of the ND4J library that powers DL4J
datavec-api
- Datavec is our library vectorizing and loading data
To run the example, right click on it and select the green button in the drop-down menu. You will see, in IntelliJ's bottom window, a series of scores. The rightmost number is the error score for the network's classifications. If your network is learning, then that number will decrease over time with each batch it processes. At the end, this window will tell you how accurate your neural-network model has become:
In another window, a graph will appear, showing you how the multilayer perceptron (MLP) has classified the data in the example. It will look like this:
Congratulations! You just trained your first neural network with Deeplearning4j.
Q: I'm using a 64-Bit Java on Windows and still get the no jnind4j in java.library.path
error
A: You may have incompatible DLLs on your PATH. To tell DL4J to ignore those, you have to add the following as a VM parameter (Run -> Edit Configurations -> VM Options in IntelliJ):
Q: SPARK ISSUES I am running the examples and having issues with the Spark based examples such as distributed training or datavec transform options.
Windows users might be seeing something like:
Now that you've learned how to run the different examples, we've made a template available for you that has a basic MNIST trainer with simple evaluation code.
To use the template:
Copy the standalone-sample-project
from the examples and give it the name of your project.
Import the folder into IntelliJ.
Start coding!
Deeplearning4j is a framework that lets you pick and choose with everything available from the beginning. We're not Tensorflow (a low-level numerical computing library with automatic differentiation) or Pytorch. Deeplearning4j has several subprojects that make it easy-ish to build end-to-end applications.
Deeplearning4j has two other notable components:
1.8 or later (Only 64-Bit versions supported)
(automated build and dependency manager)
or Eclipse
If you are new to Java or unfamiliar with these tools, read the details below for help with installation and setup. Otherwise, skip to .
If you don't have Java 1.8 or later, download the current . To check if you have a compatible version of Java installed, use the following command:
Maven is a dependency management and automated build tool for Java projects. It works well with IDEs such as IntelliJ and lets you install DL4J project libraries easily. to the latest release following for your system. To check if you have the most recent version of Maven installed, enter the following:
Maven is widely used among Java developers and it's pretty much mandatory for working with DL4J. If you come from a different background, and Maven is new to you, check out and our , which includes some additional troubleshooting tips. such as Ivy and Gradle can also work, but we support Maven best.
An Integrated Development Environment () allows you to work with our API and configure neural networks in a few steps. We strongly recommend using , which communicates with Maven to handle dependencies. The is free.
There are other popular IDEs such as and . However, IntelliJ is preferred, and using it will make finding help on the easier if you need it.
Install the . If you already have Git, you can update to the latest version using Git itself:
Every Maven project has a POM file. Here is when you run your examples.
Within IntelliJ, you will need to choose the first Deeplearning4j example you're going to run. We suggest MLPClassifierLinear
, as you will almost immediately see the network classify two groups of data in our UI. The file on .
Join our community forums on .
Read the .
Check out the more detailed .
Python folks: If you plan to run benchmarks on Deeplearning4j comparing it to well-known Python framework [x], please read on how to optimize heap space, garbage collection and ETL on the JVM. By following them, you will see at least a 10x speedup in training time.
A: You may be missing some dependencies that Spark requires. See this for a discussion of potential dependency issues. Windows users may need the winutils.exe from Hadoop.
Download winutils.exe from and put it into the null/bin/winutils.exe (or create a hadoop folder and add that to HADOOP_HOME)
If that is the issue, see . In this case replace with "Nd4jCpu".
The Quickstart template is available at .
If you'd like to deploy models to production, you might like our .
Deeplearning4j has several submodules. These range from a visualization UI to distributed training on Spark. For an overview of these modules, please look at the .
To get started with a simple desktop app, you need two things: An and deeplearning4j-core
. For more code, see the .
If you want a flexible deep-learning API, there are two ways to go. You can use nd4j standalone See our or the .
If you want distributed training on Spark, you can see our . Keep in mind that we cannot setup Spark for you. If you want to set up distributed Spark and GPUs, that is largely up to you. Deeplearning4j simply deploys as a JAR file on an existing Spark cluster.
If you want Spark with GPUs, we recommend .
If you want to deploy on mobile, you can see our .
We deploy optimized code for various hardware architectures natively. We use C++ based for loops just like everybody else. For that, please see our .
Deeplearning4j is meant to be an end-to-end platform for building real applications, not just a tensor library with automatic differentiation. If you want a tensor library with autodiff, please see ND4J and . Samediff is still in beta, but if you want to contribute, please join our .
Lastly, if you are benchmarking Deeplearnin4j, please consider coming in to our and asking for tips. Deeplearning4j has , but some may not work exactly like the Python frameworks do.