Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Java Deep Learning Cookbook

You're reading from  Java Deep Learning Cookbook

Product type Book
Published in Nov 2019
Publisher Packt
ISBN-13 9781788995207
Pages 304 pages
Edition 1st Edition
Languages
Author (1):
Rahul Raj Rahul Raj
Profile icon Rahul Raj

Table of Contents (14) Chapters

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

Extracting images from disk

For classification based on N labels, there are N subdirectories created in the parent directory. The parent directory path is mentioned for image extraction. Subdirectory names will be regarded as labels. In this recipe, we will extract images from disk using DataVec.

How to do it...

  1. Use FileSplit to define the range of files to load into the neural network:
FileSplit fileSplit = new FileSplit(parentDir, NativeImageLoader.ALLOWED_FORMATS,new Random(42));
int numLabels = fileSplit.getRootDir().listFiles(File::isDirectory).length;
  1. Use ParentPathLabelGenerator and BalancedPathFilter to sample the labeled dataset and split it into train/test sets:
ParentPathLabelGenerator parentPathLabelGenerator...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}