Code Monkey home page Code Monkey logo

javaneuralnetwork's Introduction

Neural Network in Java

This is a neural network implementation in Java. How do you use it? Example:

Example: 4 layer, MNIST evaluator

ActivationFunction<SMatrix> f = new LeakyReluFunction<>(0.01);
ActivationFunction<SMatrix> softMax = new SoftmaxFunction<>();
LayeredNetworkBuilder<SMatrix> b = 
		new LayeredNetworkBuilder<SMatrix>(28 * 28) // Input size
		.layer(new NetworkLayer<>(f, 784, 0.1)) // First layer
		.layer(new NetworkLayer<>(f, 30, 0.1)) // Hidden 1
		.layer(new NetworkLayer<>(f, 70, 0.1)) // Hidden 2
		.layer(new NetworkLayer<>(softMax, 10)) // logits output
		.costFunction(new SmoothL1CostFunction<>()) // loss (here called cost)
		.evaluationFunction(new ArgMaxEvaluationFunction<>()) // pred class = real class
		.optimizer(new ADAM<>(0.01, 0.9, 0.999)) // ADAM optimizer
		.clipping(true) // norm clipping
		.initializer(
			new SimpleInitializer(MethodConstants.XAVIER,MethodConstants.SCALAR));

return b.create();

And then training the network with train like so:

// Implement these yourself
List<NetworkInput> training = getDataFromDataSource("/foo/bar/myTrainingData");
List<NetworkInput> validation = getDataFromDataSource("/foo/bar/myValidationData");
int epochs = 100;
int batchSize = 32;

// Starts batch descent with the optimizer set in the constructor.
network.train(training, validation, epochs, batchSize);

javaneuralnetwork's People

Contributors

edvn0 avatar

Watchers

 avatar

javaneuralnetwork's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.