SkillAgentSearch skills...

JavaNet

Understanding and Implementing Neural Networks in Java from Scratch 💻 Learning the popular concept in the most 💪strongly typed language

Install / Use

/learn @SuyashSonawane/JavaNet
About this skill

Quality Score

0/100

Supported Platforms

Universal

Tags

README

<!-- PROJECT LOGO --> <br /> <p align="center"> <a href="https://github.com/suyashsonawane/JavaNet"> <img src="./docs/images/logo.png" alt="Logo" width="80" height="80"> </a> <h3 align="center">JavaNet</h3> <p align="center"> Understanding and Implementing Neural Networks in Java from Scratch 💻 Learning the popular concept in the most 💪strongly typed language <br /> <a href="https://github.com/suyashsonawane/JavaNet"><strong>Explore the docs »</strong></a> <br /> <br /> <a href="https://github.com/SuyashSonawane/JavaNet/blob/main/Driver.java">View Demo</a> · <a href="https://github.com/suyashsonawane/JavaNet/issues">Report Bug</a> · <a href="https://github.com/suyashsonawane/JavaNet/issues">Request Feature</a> </p> </p>

Contributors Forks Stargazers Issues MIT License LinkedIn

<!-- ABOUT THE PROJECT -->

About The Project

A simple Neural Network class completely written in Java from scratch without using any external libraries.

A Neural Network is a type of computational system which represents the human brain in a smaller manner. The Neurons are connected with Synapses, these concepts were taken from the 🧠. The system simulates the learning process of the brain by adjusting the Weights of the synapses by the process of Backpropagation.

Here's why you should consider using it:

  • Easy to use and test
  • Logging features
  • Customizable

I also developed a even more feature rich JavaScript library which can be found here Lite Neural Network

<!-- GETTING STARTED -->

Getting Started

  1. Place NeuralNetwork.java in your project directory
  2. Instantiate the neuralnetwork object
  3. Process the data in proper format
  4. Train the model
  5. Test the model

For full explanation, please refer to the Article

<!-- USAGE EXAMPLES -->

Usage

Instantiating the neuralnetwork object


// In the sample we are creating a neural network with 2 input features and 1 output with 10 hidden nodes

// default constructor
NeuralNetwork nn = new NeuralNetwork(2, 10, 1); 

// constructor with custom learning rate
NeuralNetwork nn_custom_lr = new NeuralNetwork(2, 10, 1, 0.01); 

// constructor with multi-threading set to true
NeuralNetwork nn_with_multithreading = new NeuralNetwork(2, 10, 1, true); 

// constructor with multi-threading set to true and custom learning rate
NeuralNetwork nn_custom_lr_with_multithreading = new NeuralNetwork(2, 10, 1, 0.01, true); 

Data Format


// As we have 2 input features we created the 2d double array for X and 1d double array for Y

double[][] X = { { 0, 0 }, { 1, 0 }, { 0, 1 }, { 1, 1 } };
double[][] Y = { { 0 }, { 1 }, { 1 }, { 0 } };

Training the model


// Here we pass the data and specify the number of epochs

nn.fit(X, Y, 500); // silent learn

nn.fit(X,Y,500,0); // logging set to 0, shows training time and average error

nn.fit(X,Y,500,1); // logging set to 1, shows logs for each epoch

Testing the model


// Here we used 4 data-points to test the model, we iterate and pass each data-point to the model

List<Double> output;
double[][] input = { { 0, 0 }, { 0, 1 }, { 1, 0 }, { 1, 1 } };
for (double d[] : input) {
    output = nn.predict(d);
    System.out.println(output.toString());
}

<!-- ROADMAP -->

Roadmap

See the open issues for a list of proposed features (and known issues).

<!-- CONTRIBUTING -->

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Project status

  • [x] Basic Library
  • [x] Documentation
  • [x] Explanation Article
  • [x] Multi-Threading Support
  • [ ] Interface to load data easily
  • [ ] Multiple layer architecture
  • [ ] Improve performance
  • [ ] Unit Testing
  • [ ] Production
<!-- LICENSE -->

License

Distributed under the MIT License. See LICENSE for more information.

<!-- CONTACT -->

Contact

Your Name - @suyashysonawane - suyashsonawane007@gmail.com

Project Link: https://github.com/suyashsonawane/JavaNet

<!-- MARKDOWN LINKS & IMAGES --> <!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
View on GitHub
GitHub Stars20
CategoryEducation
Updated1y ago
Forks4

Languages

Java

Security Score

75/100

Audited on Mar 8, 2025

No findings