Table Of Contents


Built with 🛠 MkDocs - Theme 🖤 Github.

Running All Examples

Every project listed in Examples is a standalone Maven application and follows the same build-and-run process. Clone the repository only when you want to run or modify the code.

View Examples on GitHub

Before continuing, complete Hello World to verify Java 25, Maven, Deep Netts, licensing, and the Vector API.

Get the example projects

Clone the repository:

git clone https://github.com/deepnetts/cookbook-examples.git
cd cookbook-examples

Choose an example

Enter one of the project directories:

Project Directory Result
Simple Linear Regression examples/regression/sorting-execution-time-prediction Sorting execution time
Multiple Linear Regression examples/regression/computer-hardware-performance-prediction Relative computer performance
Logistic Regression examples/classification/sonar-rock-mine-classification Sonar rock-or-mine probability and class
Spam Classification examples/classification/email-spam-detection Spam probability and class
Multiclass Classification examples/classification/iris-flower-classification Iris species probabilities and class
Hot Dog or Not Hot Dog examples/img-classification/hotdog-nothotdog Hot-dog probability and class
Duke Logo Recognition examples/img-classification/duke-logo-recognition Duke-logo probability and class
Parking Lot Occupancy examples/img-classification/parking-lot-occupancy Occupancy probability and class
Handwritten Digit Recognition examples/img-classification/handwritten-digit-recognition MNIST digit and confidence
Lego Figure Recognition examples/img-classification/lego-figure-recognition Lego-figure probability and class
TensorFlow VGGNet16 Import examples/img-classification/tensorflow-vggnet16-import ImageNet label and confidence

For example:

cd examples/regression/sorting-execution-time-prediction

All following commands must be run from the selected project directory because datasets and generated models use project-relative paths.

Compile and run

Compile the selected project:

mvn compile

Then enable the Vector API and run its configured main class.

On Linux or macOS:

MAVEN_OPTS="--add-modules jdk.incubator.vector" mvn exec:java

On Windows Command Prompt:

set MAVEN_OPTS=--add-modules jdk.incubator.vector
mvn exec:java

On Windows PowerShell:

$env:MAVEN_OPTS="--add-modules jdk.incubator.vector"
mvn exec:java

The first run may take longer while Maven resolves dependencies. The application prints its training progress, evaluation metrics, and prediction in the terminal.

What the program does

Regardless of the selected problem, every application performs the same high-level workflow:

load data
-> inspect
-> shuffle and split
-> preprocess
-> build
-> train
-> evaluate
-> save
-> predict

Each application saves its trained .dnet model under the project's local models/ directory. Running it again may replace the previously generated model.

Run from an IDE

When running from an IDE, configure this VM option:

--add-modules jdk.incubator.vector

Use the selected project directory as the working directory so that its relative dataset paths resolve correctly.

For a one-epoch smoke test of an image-training example, use:

--add-modules=jdk.incubator.vector -Ddeepnetts.epochs=1

This completes loading, training, evaluation, model saving, and prediction, but one epoch is not intended to produce final model accuracy.

TensorFlow VGGNet16 is an import and inference example, so the epoch option does not apply. It needs a larger heap:

--add-modules=jdk.incubator.vector -Xmx8g

Its first run downloads approximately 600 MB of exported TensorFlow weights. It does not download the ImageNet training dataset.

Troubleshooting checklist

If an example does not start, check:

For a detailed explanation of every operation, read the README inside the selected example.

← Back to Examples

Yes. Every example directory is a standalone Maven project with its own source, resources, and pom.xml.

Pass Java module options and example-specific system properties to the Java process through your IDE's run configuration or the Maven command used to start the example.

Was this helpful?