UHG
Search
Close this search box.

Guide To Set Up A Working Environment For Deeplearning4j

Share

Table of Content

For a long time, Java has been the dominant software development platform rivalled by very few languages. But Java and its popularity had very little to do with the development of  Machine Learning applications.

Though Java is faster than Python, it couldn’t make headway into the Artificial Intelligence(AI) and Machine Learning(ML) space dominated by Python and other languages that were much simpler and came packed with libraries for all kinds of ML tasks.

The rise of ML and AI applications and its huge demand has made Java more adaptable for related tasks by coming up with libraries and frameworks. Deeplearning4j is one such library that facilitates Java developers or programmers to create ML applications and to solve any ML related problem.

In this article, we will learn to get started with Deeplearning4j by setting up a development environment for building Machine Learning applications or projects in Java.

Prerequisite

Install java for you OS

For instructions on how to install follow the link here 

Setting Up Environment For Deeplearning4j

We will cover the entire set-up in 4 simple steps.

Installing Maven

If you have worked with Java projects then you must be familiar with Apache Maven. A project management and comprehension tool that lets you build applications from a POM(Project Object Model) file.  We will start by downloading and installing the latest Apache Maven. Follow the steps below:

Step 1. Verify if Java is installed correctly by typing java -- version in your terminal. If installed correctly, the command will return the version of the java installed. If not try setting the path environment to the installed location of Java. 

Execute the following command to add the JAVA_HOME environment variable. The following examples have been made in OSx.

Check for the location of the Home directory in your installed java location.

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-12.0.1.jdk/Contents/Home

This command only adds the path for the current session, to persist the changes type emacs .profile on your Mac terminal and add the following line to the file and save it.

Execute the following code to add the java bin path

export PATH=$JAVA_HOME/bin:$PATH

Now try java -version

Follow the instructions here for Windows or Linux systems.

Step 2. Head to https://maven.apache.org/download.cgi and download the archive for the latest maven source code.

Step 3. Once downloaded, extract the archive using any decompressing utility and move the decompressed folder to the user directory.

mv apache-maven-3.6.1 /Users/user/

Step 4. Set the path environment variable to include maven and test if maven is installed correctly.

To set the path,  execute the following command:

export PATH=/Users/user/apache-maven-3.6.1/bin:$PATH

To verify, execute mvn --version

Installing Git

Step 1. Head to https://git-scm.com/download/ which is the downloads page on Github’s official website. Select the installer for your operating system and it will be downloaded to your system.

The installation process is pretty straight forward. Run the installer to install Github in your system. 

Step 2. Verify the installation by executing the git --version in your terminal or command prompt.

You should get a similar output if everything is right.

Installing Intellij IDE

Step 1. Head to the official download page of Intellij by clicking here. Choose the installer for your os and click the download should start. We will stick to the free community edition.

Step 2. Once downloaded execute the installer to install Intellij IDE in your system.

Building and running an example project with Deeplearning4j

Step 1. Head to https://deeplearning4j.org/ and click on the examples section which will take you to the official Github repository for Deeplearning4j examples.

Step 2. Clone the repository to your local system

Copy the cloning url and execute the below command with the copied url. Make a local directory to clone the repository.

mkdir Deeplearning4j
cd Deeplearning4j

git clone https://github.com/deeplearning4j/dl4j-examples.git

Step 3. After cloning move inside to the dl4j-examples/dl4j-examples directory and execute the command mvn clean install to build the project. It may take some time to build the project.

Step 4. Once finished building, open Intellij IDE and select import project since we already have an example project that we built using maven.

On the upcoming page, select maven to specify that the project is a maven build. Include the checkbox to import maven projects automatically in the next page and next and import.

Step 5. Set the location of the project that we built using maven, select the libraries you want to include and click open to import the project into Intellij. The IDE will open up with your project imported. Wait till the processes are completed and once done you will find the project on the projects bar on the left side.

Step 6. Expand the projects and head to src/main/java/org.deeplearning4j.examples/dataexamples. You will find a hand full of examples. 

Double click on an example to open up the code. Execute the code by clicking on the run button and enjoy the results.

Step 7. You can now create or import new Maven projects using IntelliJ.

Congrats! You have set up a free java environment for Machine Learning. Happy Coding !!

📣 Want to advertise in AIM? Book here

Related Posts
19th - 23rd Aug 2024
Generative AI Crash Course for Non-Techies
Upcoming Large format Conference
Sep 25-27, 2024 | 📍 Bangalore, India
Download the easiest way to
stay informed

Subscribe to The Belamy: Our Weekly Newsletter

Biggest AI stories, delivered to your inbox every week.
Flagship Events
Rising 2024 | DE&I in Tech Summit
April 4 and 5, 2024 | 📍 Hilton Convention Center, Manyata Tech Park, Bangalore
Data Engineering Summit 2024
May 30 and 31, 2024 | 📍 Bangalore, India
MachineCon USA 2024
26 July 2024 | 583 Park Avenue, New York
MachineCon GCC Summit 2024
June 28 2024 | 📍Bangalore, India
Cypher USA 2024
Nov 21-22 2024 | 📍Santa Clara Convention Center, California, USA
Cypher India 2024
September 25-27, 2024 | 📍Bangalore, India
discord icon
AI Forum for India
Our Discord Community for AI Ecosystem, In collaboration with NVIDIA.