Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Java Deep Learning Cookbook
Java Deep Learning Cookbook

Java Deep Learning Cookbook: Train neural networks for classification, NLP, and reinforcement learning using Deeplearning4j

eBook
€8.99 €26.99
Paperback
€32.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Java Deep Learning Cookbook

Data Extraction, Transformation, and Loading

Let's discuss the most important part of any machine learning puzzle: data preprocessing and normalization. Garbage in, garbage out would be the most appropriate statement for this situation. The more noise we let pass through, the more undesirable outputs we will receive. Therefore, you need to remove noise and keep signals at the same time.

Another challenge is handling various types of data. We need to convert raw datasets into a suitable format that a neural network can understand and perform scientific computations on. We need to convert data into a numeric vector so that it is understandable to the network and so that computations can be applied with ease. Remember that neural networks are constrained to only one type of data: vectors.

There has to be an approach regarding how data is loaded into a neural network. We cannot...

Technical requirements

Concrete implementations of the use cases that will be discussed in this chapter can be found at https://github.com/PacktPublishing/Java-Deep-Learning-Cookbook/tree/master/02_Data_Extraction_Transform_and_Loading/sourceCode/cookbook-app/src/main/java/com/javadeeplearningcookbook/app.

After cloning our GitHub repository, navigate to the
Java-Deep-Learning-Cookbook/02_Data_Extraction_Transform_and_Loading/sourceCode directory. Then, import the cookbook-app project as a Maven project by importing the pom.xml file inside the cookbook-app directory.

The datasets that are required for this chapter are located in the Chapter02 root directory (Java-Deep-Learning-Cookbook/02_Data_Extraction_Transform_and_Loading/). You may keep it in a different location, for example, your local directory, and then refer to it in the source code accordingly.

...

Reading and iterating through data

ETL is an important stage in neural network training since it involves data. Data extraction, transformation, and loading needs to be addressed before we proceed with neural network design. Bad data is a much worse situation than a less efficient neural network. We need to have a basic understanding of the following aspects as well:

  • The type of data you are trying to process
  • File-handling strategies

In this recipe, we will demonstrate how to read and iterate data using DataVec.

Getting ready

As a prerequisite, make sure that the required Maven dependencies have been added for DataVec in your pom.xml file, as we mentioned in previous chapter, Configuring Maven for DL4J recipe.

The following...

Performing schema transformations

Data transformation is an important data normalization process. It's a possibility that bad data occurs, such as duplicates, missing values, non-numeric features, and so on. We need to normalize them by applying schema transformation so that data can be processed in a neural network. A neural network can only process numeric features. In this recipe, we will demonstrate the schema creation process.

How to do it...

  1. Identify the outliers in the data: For a small dataset with just a few features, we can spot outliers/noise via manual inspection. For a dataset with a large number of features, we can perform Principal Component Analysis (PCA), as shown in the following code:
INDArray factor...

Building a transformation process

The next step after schema creation is to define a data transformation process by adding all the required transformations. We can manage an ordered list of transformations using TransformProcess. During the schema creation process, we only defined a structure for the data with all its existing features and didn't really perform transformation. Let's look at how we can transform the features in the datasets from a non-numeric format into a numeric format. Neural networks cannot understand raw data unless it is mapped to numeric vectors. In this recipe, we will build a transformation process from the given schema.

How to do it...

  1. Add a list of transformations to TransformProcess....

Serializing transforms

DataVec gives us the ability to serialize the transforms so that they're portable for production environments. In this recipe, we will serialize the transformation process.

How to do it...

  1. Serialize the transforms into a human-readable format. We can transform to JSON using TransformProcess as follows:
String serializedTransformString = transformProcess.toJson()

We can transform to YAML using TransformProcess as follows:

String serializedTransformString = transformProcess.toYaml()

Executing a transform process

After the transformation process has been defined, we can execute it in a controlled pipeline. It can be executed using batch processing, or we can distribute the effort to a Spark cluster. Previously, we look at TransformProcessRecordReader, which automatically does the transformation in the background. We cannot feed and execute the data if the dataset is huge. Effort can be distributed to a Spark cluster for a larger dataset. You can also perform regular local execution. In this recipe, we will discuss how to execute a transform process locally as well as remotely.

How to do it...

  1. Load the dataset into RecordReader. Load the CSV data in the case of CSVRecordReader:
RecordReader reader = new...

Normalizing data for network efficiency

Normalization makes a neural network's job much easier. It helps the neural network treat all the features the same, irrespective of their range of values. The main goal of normalization is to arrange the numeric values in a dataset on a common scale without actually disturbing the difference in the range of values. Not all datasets require a normalization strategy, but if they do have different numeric ranges, then it is a crucial step to perform normalization on the data. Normalization has a direct impact on the stability/accuracy of the model. ND4J has various preprocessors to handle normalization. In this recipe, we will normalize the data.

How to do it...

  1. Create a dataset...
Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Install and configure Deeplearning4j to implement deep learning models from scratch
  • Explore recipes for developing, training, and fine-tuning your neural network models in Java
  • Model neural networks using datasets containing images, text, and time-series data

Description

Java is one of the most widely used programming languages in the world. With this book, you will see how to perform deep learning using Deeplearning4j (DL4J) – the most popular Java library for training neural networks efficiently. This book starts by showing you how to install and configure Java and DL4J on your system. You will then gain insights into deep learning basics and use your knowledge to create a deep neural network for binary classification from scratch. As you progress, you will discover how to build a convolutional neural network (CNN) in DL4J, and understand how to construct numeric vectors from text. This deep learning book will also guide you through performing anomaly detection on unsupervised data and help you set up neural networks in distributed systems effectively. In addition to this, you will learn how to import models from Keras and change the configuration in a pre-trained DL4J model. Finally, you will explore benchmarking in DL4J and optimize neural networks for optimal results. By the end of this book, you will have a clear understanding of how you can use DL4J to build robust deep learning applications in Java.

Who is this book for?

If you are a data scientist, machine learning developer, or a deep learning enthusiast who wants to implement deep learning models in Java, this book is for you. Basic understanding of Java programming as well as some experience with machine learning and neural networks is required to get the most out of this book.

What you will learn

  • Perform data normalization and wrangling using DL4J
  • Build deep neural networks using DL4J
  • Implement CNNs to solve image classification problems
  • Train autoencoders to solve anomaly detection problems using DL4J
  • Perform benchmarking and optimization to improve your model s performance
  • Implement reinforcement learning for real-world use cases using RL4J
  • Leverage the capabilities of DL4J in distributed systems

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Nov 08, 2019
Length: 304 pages
Edition : 1st
Language : English
ISBN-13 : 9781788995207
Vendor :
Oracle
Category :
Languages :
Concepts :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Nov 08, 2019
Length: 304 pages
Edition : 1st
Language : English
ISBN-13 : 9781788995207
Vendor :
Oracle
Category :
Languages :
Concepts :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 119.97
Java Deep Learning Cookbook
€32.99
Java Coding Problems
€41.99
Hands-On Microservices with Spring Boot and Spring Cloud
€44.99
Total 119.97 Stars icon
Banner background image

Table of Contents

13 Chapters
Introduction to Deep Learning in Java Chevron down icon Chevron up icon
Data Extraction, Transformation, and Loading Chevron down icon Chevron up icon
Building Deep Neural Networks for Binary Classification Chevron down icon Chevron up icon
Building Convolutional Neural Networks Chevron down icon Chevron up icon
Implementing Natural Language Processing Chevron down icon Chevron up icon
Constructing an LSTM Network for Time Series Chevron down icon Chevron up icon
Constructing an LSTM Neural Network for Sequence Classification Chevron down icon Chevron up icon
Performing Anomaly Detection on Unsupervised Data Chevron down icon Chevron up icon
Using RL4J for Reinforcement Learning Chevron down icon Chevron up icon
Developing Applications in a Distributed Environment Chevron down icon Chevron up icon
Applying Transfer Learning to Network Models Chevron down icon Chevron up icon
Benchmarking and Neural Network Optimization Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.5
(2 Ratings)
5 star 50%
4 star 50%
3 star 0%
2 star 0%
1 star 0%
Maxwell Dec 16, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is an excellently put together book on deep learning. The author puts you on a path to truly understanding how to use java to build learning applications. Granted, you will need the skills to back it up, but if you're like me and just needed a bit of help to get you started -- then this is book is an excellent choice.I liked how well this book flowed as well. Seeing a huge wall of text can be be off-putting when trying to learn something complex like this. I can confidently say I came away with more knowledge than I had when I started. So for me, it was worth the purchase.
Amazon Verified review Amazon
Cliente Amazon Mar 23, 2020
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Thee book is awesome if you don't have knowledge about DL4J. It explains quite well how the basic of algorithms for Machine Learning work. I found really good examples, but incompletes in some way. My humble opinion: it's a good choice if you don't have prior knowledge in DL4J.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.