Skip to content

An Infant Library of Artificial Neural Network (multilayer-deep-convolutional-machine-learning)

License

Notifications You must be signed in to change notification settings

MinhasKamal/Intellectron

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Intellectron

An Infant Library of Artificial Neural Network

The project is a simple implementation of Deep Neural Network. Several machine learning algorithms are put together here. This tiny library is particularly suitable for small projects.

How to Use?

  1. Download Intellectron.jar, and integrate it in your project's build path.
  2. Now, use it in your project like this-
	// This is a demonstration of XOR gate implementation in Neural Network.
	public static void main(String[] args) {
		// For XOR gate-
		// ------------------
		// | input | output |
		// |----------------|
		// | 0 | 0 |   0    |
		// | 0 | 1 |   1    |
		// | 1 | 0 |   1    |
		// | 1 | 1 |   0    |
		// ------------------
		double[][] inputs = new double[][]{
			{0, 0}, {0, 1}, {1, 0}, {1, 1}
		};
		double[][] expectedOutputs = new double[][]{
			{0}, {1}, {1}, {0}
		};
		
		// Here, we are creating four layers of neural network.
		// First layer is created automatically using the input data.
		// Here the input has two categories, so first layer (input layer)
		// will have 2 neurons. 
		// The second layer will contain- 4, third layer- 2, and fourth layer
		// (output layer) contains 1 neuron.
		int[] numbersOfNeuronsInLayers = new int[]{4, 2, 1};
		
		// The 'DeepNeuralNetworkImplementation' object takes the network 
		// structure, learning rate, and number of inputs (input categories).
		DeepNeuralNetworkImplementation deepNeuralNetworkImplementation = 
			new DeepNeuralNetworkImplementation(numbersOfNeuronsInLayers, 0.1, 2);
		
		// Here we are running 20,000 cycles to train the network.
		// In each cycle we are passing the input and expected output.
		System.out.println("# Training...\n");
		int cycle = 20000;
		for(int i=0; i<cycle; i++){
			deepNeuralNetworkImplementation.train(inputs, expectedOutputs);
		}
		
		// Storing knowledge in the memory storage
		System.out.println("# Storing Knowledge...\n");
		String workspace = System.getenv("SystemDrive") + System.getenv("HOMEPATH") + "\\Desktop\\";
		deepNeuralNetworkImplementation.dump(workspace+"knowledge.xml");
		
		// Predicting output for inputs from acquired knowledge
		System.out.println("# Predicting...");
		double prediction;
		prediction = deepNeuralNetworkImplementation.predict(new double[]{0, 0})[0];
		System.out.println("input- 0, 0; prediction- "+prediction);
		prediction = deepNeuralNetworkImplementation.predict(new double[]{0, 1})[0];
		System.out.println("input- 0, 1; prediction- "+prediction);
		prediction = deepNeuralNetworkImplementation.predict(new double[]{1, 0})[0];
		System.out.println("input- 1, 0; prediction- "+prediction);
		prediction = deepNeuralNetworkImplementation.predict(new double[]{1, 1})[0];
		System.out.println("input- 1, 1; prediction- "+prediction);
	}

You can find some simple implementations in the test section. There is also a beautiful project created with Intellectron- DeepGenderRecognizer; you will get a nice insight from it too.

Releases

License

MIT License

Intellectron is licensed under MIT License.