Introduction to artificial neural networks and the implementation and operation of single-layer networks-Use of the aforge. NET Framework (V)

Source: Internet
Author: User
Tags types of functions

Previous 4ArticleThis is a fuzzy system, which is different from the traditional value logic. The theoretical basis is fuzzy mathematics, so some friends are confused. If you are interested, please refer to relevant books, I recommend the "fuzzy mathematics tutorial", the National Defense Industry Press, which is very comprehensive and cheap (I bought 7 yuan ).

Introduction to Artificial Neural Networks

Artificial Neural Network (ANN) is a mathematical model used to process information in a structure similar to the neural network of the brain. It is an operational model consisting of a large number of neurons and mutual connections. Each neuron represents a specific output function called the activation function ). The connection between each two nodes represents a weighted value for the connection signal, called weight (weight), used to simulate memory. The output of the entire network varies according to the connection method, weight value, and incentive function of the network. And the network itself is usually a naturalAlgorithmOr function approximation, or expression of a logical policy.

Artificial Neural Networks have obvious advantages in the following three aspects:

1. Self-learning

2. Lenovo Storage

3. fast search for optimization solutions

For more information, see

Aforge. NET Single-layer network implementation and operation

The implementation of neural networks in aforge. NET is mainly implemented in aforge. Neuro and obtained using Install-package aforge. Neuro.

Follow these steps:

1. Build a model

You don't need to talk about the and operation. Sort out the input and output:

[0, 0] ==> [0]

[1, 0] ==> [0]

[0, 1] ==> [0]

[1, 1] ==> [1]

It is easy to see that there are two inputs, and one output node. The number of layers is sufficient.

Code:

 //  Sort input and output data  
Double [] [] Input = New Double [ 4 ] []; Double [] [] Output = New Double [ 4 ] [];
Input [0 ] = New Double [] { 0 , 0 }; Output [ 0 ] = New Double [] { 0 };
Input [ 1 ] = New Double [] { 0 , 1 }; Output [ 1 ] = New Double [] { 0 };
Input [ 2 ] = New Double [] { 1 , 0 }; Output [ 2 ] = New Double [] { 0 };
Input [3 ] = New Double [] { 1 , 1 }; Output [ 3 ] = New Double [] { 1 };

2. Select incentive functions and learning rules

The iactivationfunction interface must be implemented for the incentive functions in aforge. net. Three types of functions are implemented in aforge. Net:

Bipolarsigmoidfunction

Sigmoidfunction

Thresholdfunction)

Our activation function selects the activation function.

Next, let's consider learning functions.

The isupervisedlearning or iunsupervisedlearning interfaces must be implemented for learning functions in aforge. net,ProgramLibrary implementation:

Perceptron learning is the first neural network learning algorithm. It appeared in 1957 and is often used for linear data classification.

Code:

 
//Create a network, number of layers 1, input 2, output 1, incentive function boosting function
Activationnetwork network =NewActivationnetwork (NewThresholdfunction (),2,1);
 
//The learning method is the sensor learning algorithm.
Perceptronlearning Teacher =NewPerceptronlearning (network );

3. Training Network

Teacher. runepoch (input, output );

4. Get output for processing

Because the algorithm is simulated, there is no processing. Just simulate it and see the effect.

 
//Simulation
For(IntI =0; I <4; I ++)
{
Console. writeline ("Input {0 }:==>{ 1}, {2} SIM {0 }:==>{ 3}", I, input [I] [0], Input [I] [1], Network. Compute (input [I]) [0]);
}

Complete code:

 //  Sort input and output data 
Double [] [] Input = New Double [ 4 ] []; Double [] [] Output = New Double [ 4 ] [];
Input [ 0 ] = New Double [] { 0 , 0 }; Output [ 0 ] = New Double [] { 0 };
Input [ 1 ] = New Double [] { 0 , 1 }; Output [ 1 ] = New Double [] { 0 };
Input [2 ] = New Double [] { 1 , 0 }; Output [ 2 ] = New Double [] { 0 };
Input [ 3 ] = New Double [] { 1 , 1 }; Output [ 3 ] = New Double [] { 1 };

For ( Int I = 0 ; I < 4 ; I ++)
{
Console. writeline ( " Input {0 }:==>{ 1}, {2} output {0 }:==>{ 3} " , I, input [I] [0 ], Input [I] [ 1 ], Output [I] [ 0 ]);
}

// Create a network, number of layers 1, input 2, output 1, incentive function boosting function
Activationnetwork network = New Activationnetwork ( New Thresholdfunction (), 2 , 1 );

// The learning method is the sensor learning algorithm.
Perceptronlearning Teacher = New Perceptronlearning (network );

// Define absolute error
Double Error = 1.0 ;
Console. writeline ();
Console. writeline ( " Learning error ==>{ 0} " , Error );

// Output learning rate
Console. writeline ();
Console. writeline ( " Learning rate ==>{ 0} " , Teacher. learningrate );

// Iterations
Int Iterations = 0 ;
Console. writeline ();
While (Error> 0.001 )
{
Error = teacher. runepoch (input, output );
Console. writeline ( " Learning error ==>{ 0} " , Error );
Iterations ++;
}
Console. writeline ( " Iterations ==>{ 0} " , Iterations );
Console. writeline ();
Console. writeline ( " Sim: " );

// Simulation
For ( Int I = 0 ; I < 4 ; I ++)
{
Console. writeline ( " Input {0 }:==>{ 1}, {2} SIM {0 }:==>{ 3} " , I, input [I] [ 0 ], Input [I] [1 ], Network. Compute (input [I]) [ 0 ]);
}

Effect:

Prospect of combining artificial neural networks and Fuzzy Systems

I want to explain why artificial neural networks are used after the fuzzy logic is completed. Although fuzzy logic and neural networks are two completely different fields, their basic theories are far different. One is a new model and the other is a new set theory. However, the combination of objective practice and theory can completely combine them. The combination of fuzzy logic and neural networks produces a new technical field: This is the fuzzy neural network.

Common forms include:

1. Logical Fuzzy Neural Network

2. arithmetic and Fuzzy Neural Networks

3. Hybrid logical Neural Networks

I personally feel that the combination of the two is actually a problem of learning and optimizing the weight coefficient.

Logical fuzzy neural networks use error-based learning algorithms. For arithmetic fuzzy neural systems, fuzzy BP algorithms and genetic algorithms are generally used. The two technologies are mature. For hybrid logical neural networks, there are generally no specific algorithms, and they are mostly used for computing rather than learning.

Some may think that the first two are relatively new. I thought so at first, but I have searched related papers for nearly ten years (from Wanfang ), most ideas and methods can be found in the early data of magazines such as cybernetics (around 1980.

 

3 documents on perceptron learning: http://www.ctdisk.com/file/4525564

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.