Book Image

Java Deep Learning Cookbook

By : Rahul Raj
Book Image

Java Deep Learning Cookbook

By: Rahul Raj

Overview of this book

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.
Table of Contents (14 chapters)

Training and evaluating the neural network model for CSV data

During the training process, the neural network learns to perform the expected task. For every iteration/epoch, the neural network will evaluate its training knowledge. Accordingly, it will re-iterate the layers with updated gradient values to minimize the error produced at the output layer. Also, note that labels (0 and 1 ) are not uniformly distributed across the dataset. So, we might need to consider adding weights to the label that appears less in the dataset. This is highly recommended before we proceed with the actual training session. In this recipe, we will train the neural network and evaluate the resultant model.

How to do it...

  1. Create an array to assign...