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)

Importing and loading Keras models and layers

There can be times when you want to import a model that is not available in the DL4J Model Zoo API. You might have created your own model in Keras/TensorFlow, or you might be using a pre-trained model from Keras/TensorFlow. Either way, we can still load models from Keras/TensorFlow using the DL4J model import API.

Getting ready

This recipe assumes that you already have the Keras model (pre-trained/not pre-trained) set up and ready to be imported to DL4J. We will skip the details about how to save Keras models to disk as it is beyond the scope of this book. Usually, Keras models are stored in .h5 format, but that isn't a restriction as the model-import API can import from...