Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

RBF Neural Network Class - MetaTrader 5 Library | MT5 EA Download - MetaTrader 5 Resources

author EAcpu | 2 reads | 0 comments |

This represents the classic implementation of RBFN, consisting of two layers of neurons: hidden layer neurons with radially symmetric activation functions and exit layers with linear and sigmoid activation functions.

The activation function of the output layer is automatically selected based on the test output data to train the network. For the range -1 to 1, the hyperbolic tangent is applied, and for the range 0 .. 1, sigmoid is applied. If the test output data is outside the range -1 .. 1, the activation function is not used.

The creation of the network is declared as a class parameter constructor.

 CNetRBF * net = new CNetRBF (size of input vector, maximum number of hidden layer neurons, size of output vector);

When creating a network, set the maximum number of neurons in the hidden layer that the network can use. The actual number of neurons required is determined by the learning network.

The learning network is provided by calling the Learn method (number of learning modes, input data array, output data array, number of learning cycles, maximum learning error).

The input and output learning data are located vector by vector in a one-dimensional array. The learning process is limited by the number of learning epochs or the acceptable error.

The Learn method returns the following values:

-4 - Out of memory.

The calculation method (array of input vectors, array of network responses) is used to obtain the network response.

The Save (open a file handle using the FILE_WRITE and FILE_BIN flags) and Load (open a file handle using the FILE_READ and FILE_BIN flags) methods are used to save a network to a file and load a network from a file respectively. Network topology, learning errors, and array weights are saved to files. If the loaded network topology parameters are different from the established network topology parameters, the network will not be loaded and the Load method will return false.

The usage of this class is shown in the attached sample: Test_RBFN_XOR - learns the network function "excluded OR", Test_RBFN_MUL_ADD - learns an integer multiplication and addition network. This means that the class and sample files are placed in one folder.


Attachment download

📎 class_netrbf.mqh (22.75 KB)

📎 test_rbfn_xor.mq5 (2.48 KB)

📎 test_rbfn_mul_add.mq5 (2.14 KB)

Source: MQL5 #1267

Verification code Refresh