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.
Before continuing, complete Hello World to verify Java 25, Maven, Deep Netts, licensing, and the Vector API.
Clone the repository:
git clone https://github.com/deepnetts/cookbook-examples.git
cd cookbook-examples
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 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.
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.
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.
If an example does not start, check:
src/main/resources/datasets/.For a detailed explanation of every operation, read the README inside the selected example.
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?
Thank you!