A lightweight, self-contained neural network library written in Java, designed for learning, experimentation, and visualization.
It provides a clean API for building and training fully connected neural networks, along with a real-time Swing-based visualizer for inspecting layers, neurons, activations, and weights.
The project is distributed as a reusable JAR library, making it easy to integrate into other Java applications.
- Fully connected feedforward neural network
- Forward propagation
- Backpropagation training
- ReLU activation function
- Adjustable learning rate
- Real-time network visualization
- Interactive zoom
- Visual representation of:
- Neuron activations
- Layer structure
- Weight magnitude and sign
- Model saving and loading via serialization
- No external machine learning libraries required
- Go to the Releases section of this repository
- Download the latest
.jarfile
- Open Project Structure
- Navigate to Libraries
- Click + → Java
- Select the downloaded JAR
- Apply and close
javac -cp neural-network.jar YourProject.java
java -cp neural-network.jar;. YourProjectimport io.arsh.Network;
Network network = new Network(3, 5, 2);
network.setLearningRate(0.1);double[] output = network.forward(
new double[]{1.0, 0.5, 0.2}
);network.train(
new double[]{1.0, 0.5, 0.2},
new double[]{0.0, 1.0}
);The library includes a built-in visualizer for inspecting the network in real time:
network.show();- Each circle represents a neuron
- Color intensity reflects activation value
- Connection thickness represents weight magnitude
- Color differences indicate positive vs negative weights
- Mouse wheel → zoom
- Click & drag → move around
Networks can be serialized and reused:
network.save("model.nn");
Network loaded = Network.load("model.nn");Network— core neural network logicLayer— manages neurons per layerNeuron— stores weights, bias, value, and gradientutils— activation functions (ReLU, Sigmoid)visualizer— Swing-based real-time renderer
The design prioritizes clarity, modularity, and educational value.
This library is well-suited for:
- Educational projects
- Learning neural network fundamentals
- Visual demonstrations
- Java-based simulations
- Custom tools requiring lightweight neural networks
This project is not a production-level framework and very inefficient but great for learning how neural network works.
- Better optimization options (GPU Integration)
- Training performance graphs
- Loss function visualization
- More control
This project is open-source and free to use for learning, experimentation, and personal projects.