Standard C++ Definitions for Neurons and Neural Networks Layers

Some time ago a small system for digital identification was developed based on the BP neural network algorithm and interacted with MFC. In the process of implementation, we also try to find some source code. Generally speaking, the portability of these source code is not good. Most of the interactive parts and the core algorithm code are mixed together, so that not only the code reading difficulties, but also the core algorithm is important. Not portable. The importance of design patterns and design patterns! Therefore, the core algorithm of the BP neural network is implemented in standard C++, so the portability is guaranteed, and then the interaction between different GUI libraries based on the core algorithm (MFC, QT) can quickly build a good system. The following describes the principle of the BP algorithm (see "digital image processing and machine vision" is very suitable for engineering partners), while giving the code to achieve, and finally based on the core algorithm to build interactive examples.

The theoretical basis of artificial neural network

Sensor

The sensor is an artificial neuron with two simple outputs, as shown in the figure below.

2. Linear unit

Only the perceptual outputs of the 1 and -1 outputs actually limit their ability to process and sort. The following figure shows a simple generalization, namely a perceptron without a threshold.

3. Error criteria

A commonly used error metric, the square error criterion, is used. The formula is as follows.

Where D is the training sample, td is the training output of the training observation d, and ot is the actual observation of the observation d. If it's a convex function (that's fine, it's nice to hear the convex function, huh, huh!), but you can still use the gradient descent method to find its parameter w.

4. Gradient decline derivation

In higher mathematics, the concept of a gradient is actually a direction vector, which is the direction in which the directional derivative is the greatest, that is, along this direction, the value of the function changes fastest. Here we do a gradient descent, then we update the value of the parameter w in the negative direction of the gradient to quickly reach the minimum value of the E function. The steps of this gradient descent algorithm are basically as follows:

1) Initialize the parameter w (random, or other method).

2) Find the gradient.

3) Update the parameter w along the gradient direction to add a learning rate, that is, how much the step is down.

4) Repeat 1), 2), 3) until the set condition is reached (the number of iterations, or the reduction of E is less than a certain threshold).

The gradient expression is as follows:

So how do you get gradients? This is the process of deriving a complex function as follows:

Where xid is the input component xi corresponding to the dth observation in the sample. In this way, the updated expression of the parameter w in the training process is as follows (in which a learning rate is added, that is, the decreasing step):

So the update increment of the parameter wi is:

For the problem of the selection of the learning rate, the smaller one is usually able to guarantee convergence, see the figure below.

5. Incremental gradient drop

The disadvantage of the gradient descent algorithm in 4 is that sometimes the convergence speed is slow. If there are multiple local minimum values ​​on the error surface, the algorithm cannot guarantee that the global minimum can be found. In order to improve these disadvantages, an incremental gradient descent algorithm is proposed. Incremental gradient descent, which differs from gradient descent in 4, is that the updating of parameter w in 4 is calculated based on the error of the observations in the entire sample, whereas the incremental gradient descent algorithm is based on the single observation in the sample. The value of the error to calculate the update of w.

6. Gradient test

This is a more practical content. How to determine your own code is certainly not wrong? Because it is very easy to make mistakes when we are looking for a gradient, I have committed it, er, tune it out for two days and found out that an array is wrong in the table below. If you look earlier at Stanford University's deep learning basic tutorial, Now, this is just a part of the screenshot, and have time to take a closer look.

Multilayer neural network

Well, with the previous foundation, we can now conduct actual combat and construct a multilayer neural network.

Sigmoid neurons

Sigmoid neurons can be represented by the following diagram:

2. Neural network layer

A three-layer BP neural network can be represented by the following figure:

3. Standard C++ definitions of neurons and neural network layers

As can be seen from the schematic diagram of the three-layer BP neural network in 2, the hidden layer and the output layer have a similar structure. The neuron and neural network layers are defined as follows:

1

Automotive Battery


As the market changes and more vehicles are manufactured with start-stop technology, to reduce fuel consumption, and more power hungry options as standard such as sat-nav, smartphone interface and augmented displays, the need for a quality, reliable auxiliary battery becomes even more important. The RIMA Starter Batteries are designed specifically to deliver exceptional performance for high demanding start-stop vehicles. With an enhanced cycle life, our maintenance free AGM Battery can cope with the increased power demand from fuel saving technologies. They can deliver reliable power to a wide range of electrical equipment, as a complement to the main starter battery, even when the engine is idle. Ideal for cars, SUVs, vans and vehicles with start-stop technology and power hungry electrical equipment.

Starter Batteries including Car Start Stop Battery, Truck Battery and Marine battery.



General Feature

Absorbent Glass Mat(AGM) technology for efficient gas recombination of up to 99% and freedom from electrolyte maintenance or water adding, even if the battery is cracked in the sudden accident such as intense turbulence or high speed collision it can still normally start vehicles.
Special valve design, which prevent vehicle components installed near the battery from being corroded.
High Assembly Pressure Design can slow the positive paste shedding and prolong its life time greatly.
Reinforced polypropylene case is resistant to impact and deformation and widens the usable temperature
range from -30℃( -22℉ ) to 70℃( 158℉ ).
Patented deep cycle positive paste and negative lead carbon technology prolong the cycle life, improve the
charging acceptance and low-temperature starting capacity.
High purity 99.996% lead raw materials greatly reduce self-discharge and prolong shelf life.


Application:

Car/Automotive start-stop application, power supply application

Truck start-stop application, power supply application

RV start-stop applicaton, power supply application

For all kinds of Vehicles start-stop application, and power supply application


Starter Batteries,Heavy Duty Truck Battery,Diesel Truck Battery,Start Stop Battery

OREMA POWER CO., LTD. , https://www.oremabattery.com

Posted on