JNeuralNet is a fully independent Neural Network written in Java from scratch, designed to train and evaluate on the MNIST dataset (handwritten digits 0-9). The project demonstrates the core concepts of neural networks without relying on external libraries.
The default network architecture configured in Main.java is:
- Input Layer: 784 neurons (28x28 flattened MNIST images)
- Hidden Layer 1: 128 neurons (ReLU Activation)
- Output Layer: 10 neurons (Softmax Activation paired with CrossEntropy Loss)
- Optimizer: Stochastic Gradient Descent (SGD)
- Java 17 or higher
- Maven (Required for compilation and testing)
Warning
Maven Requirement & Installation
This project uses Maven to manage compilation and the testing suite. If Maven is not installed on your system, commands like mvn clean test will fail.
To install Maven on Windows:
You can download it directly via Winget or script. If you just installed it, be sure to restart your terminal or IDE (like VS Code, Eclipse, or IntelliJ) so the PATH changes take effect.
You can verify the installation by running:
mvn -versionTo compile the Java source files, run:
mvn clean compileThis will load the MNIST dataset from the local MNIST Dataset folder, initialize the network, and begin training across epochs.
mvn exec:java -Dexec.mainClass="Main"The project includes a suite of JUnit 5 tests covering the discrete mathematics (Sigmoid, Matrix shapes, XOR convergence) and dataset parsing.
mvn testsrc/main/math: Pure java manual implementations ofSigmoid,ReLU,Softmax,MSE, andCrossEntropy.src/main/nn: Core implementation of Neural Components (Neuron,Layer,NeuralNetwork,Trainer).src/main/data: Dataset parsers targeting.idxfile formats.src/test: Unit tests proving convergence mechanics on logic gates like XOR.