"New Neural" is an Open Source neural network engine project for the MetaTrader 5 platform. - page 72

 
yu-sha:

The two inputs are the values of some indicator or will someone external feed the data ?

external data, as well as the output, you can display can exclude, as desired.

ZY this is a drawing from an XOR problem, classic MLP

 
Urain:

Now I just had a stray thought:

Maybe to ask the MQ API to set tasks for cluster?

to distribute the task without passing the tester, directly from MQL5. The task is certainly complex, it requires a lot of checks, but can be solved.

What do you think, brothers, is not too high sweep? cluster certainly sacred cow, but we have to work hard.


It would be very cool! But the question would be how agents would be remunerated in this case?

 

How about this?

Otherwise the meaning of neurons 1, 2 and 8 is unclear

 
yu-sha:

How about this?

Otherwise the meaning of neurons 1 and 2 is incomprehensible

Well, you can do it this way, it doesn't matter.
 

First xml-file: network before preprocessing -UrainTaskPre.xml

When you have a lot of neurons of the same type, it's easy to make a mistake - here you define a template and preprocessor should unwrap it into a ready-made network file

<ROOT>

    <NET>

                <LAYER CLASS="EXTERN" NAME="INPUT">
                        <NEURON NAME="NEURON:%ID%.INPUT" VALUE="0.0">
                                <REPEAT FOR="%ID%" FROM="1" TO="2"/>
                        </NEURON>
                </LAYER>

                <LAYER CLASS="TANH" NAME="HID:0">
                        <NEURON NAME="NEURON:%ID%.HID:0" BIAS="0.0">
                                <REPEAT FOR="%ID%" FROM="1" TO="2"/>
                                <LINK TO="expr:.+\.INPUT$" WEIGHT="0.0"/>
                        </NEURON>
                </LAYER>

                <LAYER CLASS="TANH" NAME="OUT">
                        <NEURON NAME="OUT" BIAS="0.0">
                                <LINK TO="expr:.+\.HID:0$" WEIGHT="0.0"/>
                        </NEURON>
                </LAYER>

    </NET>

</ROOT>

Then the preprocessor handles substitutions <REPEAT .../>, <INCLUDE .../>, "expr:..." and we get the network

UrainTaskPost.xml

<ROOT>
    <NET>
        <LAYER CLASS="EXTERN" NAME="INPUT">
            <NEURON NAME="NEURON:1.INPUT" VALUE="0.0" />
            <NEURON NAME="NEURON:2.INPUT" VALUE="0.0" />
        </LAYER>
        <LAYER CLASS="TANH" NAME="HID:0">
            <NEURON NAME="NEURON:1.HID:0" BIAS="0.0">
                <LINK TO="NEURON:1.INPUT" WEIGHT="0.0" />
                <LINK TO="NEURON:2.INPUT" WEIGHT="0.0" />
            </NEURON>
            <NEURON NAME="NEURON:2.HID:0" BIAS="0.0">
                <LINK TO="NEURON:1.INPUT" WEIGHT="0.0" />
                <LINK TO="NEURON:2.INPUT" WEIGHT="0.0" />
            </NEURON>
        </LAYER>
        <LAYER CLASS="TANH" NAME="OUT">
            <NEURON NAME="OUT" BIAS="0.0">
                <LINK TO="NEURON:1.HID:0" WEIGHT="0.0" />
                <LINK TO="NEURON:2.HID:0" WEIGHT="0.0" />
            </NEURON>
        </LAYER>
    </NET>
</ROOT>

Below is a script that opens an XML file, parses it into an XML tree, creates a neural network from it, initializes the inputs and here it Run()

//+------------------------------------------------------------------+
//|                                                  UrainScript.mq5 |
//|                        Copyright 2011, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2011, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"

#include <Cuda\Base.mqh>

CXmlDocument xmlDoc;

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
    string err;
    
    // Создаем дерево XML
    if (xmlDoc.CreateFromFile("UrainTaskPost.xml",err))
    {
      Print ("Root:",xmlDoc.FDocumentElement.GetName());
      CXmlElement * xmlNet = xmlDoc.FDocumentElement.GetChild(0);

      // Печатаем вложенные уровни
      for (int j=0; j<xmlNet.GetChildCount(); j++)
      {
        CXmlElement * xmlLayer = xmlNet.GetChild(j);
        Print ("Element #",j,", CLASS=",xmlLayer.GetAttributeValue("CLASS"),", NAME=",xmlLayer.GetAttributeValue("NAME"));
      }
      
      // Строим нейросеть из дерева XML
      CNet net;
      if (net.LoadFrom(xmlNet))
      {
        ((CNeuronService*)(net.GetNeuron("NEURON:1.INPUT"))).SetValue(0.1234 f);
        ((CNeuronService*)(net.GetNeuron("NEURON:2.INPUT"))).SetValue(0.1234 f);
        net.Run();
        Print ("OUT=",net.GetNeuron("OUT").GetValue());
      }
    }
   
  }
//+------------------------------------------------------------------+

Note:

The class CNeuronService handles neurons of type "EXTERN" - a little inconsistency left over from the old days

It's easier to get used to it than to correct it )))

Results of the script:


UrainTaskPost.xml must be placed in a common terminal folder, for example, C:\Documents and Settings\All Users\Application Data\MetaQuotes\Terminal\Common\Files

Files from the archive to MQL5\Include

Files:
 
yu-sha:

First xml-file: network before preprocessing -UrainTaskPre.xml

When you have a lot of neurons of the same type it's easy to make a mistake - here we set a template and preprocessor should unwrap it into a ready-made network file

Then the preprocessor handles the substitution of <REPEAT .../> and we get the network

UrainTaskPost.xml

Below is a script that opens an XML file, parses it into an XML tree, creates a neural network from it, initializes the inputs and there it Run()

Already warmer, now explain how to interpret the file.

Where to write what to create links, or poke where it says they are set.

 
Urain:

Already warmer, now explain how to interpret the file.

where to write what to create the connections, or point where it says that they are set.

1) Each neuron must have a unique name, for example NEURON:1.HID:0

The name tells you that it is the 1st neuron of layer HID:0

2) The links use for addressing the neuron names + weights

3) every neuron class can (and must) override the virtual bool Init (CXmlElement *aXmlElement, CNet *aNet) and load from XML

P.S.

XML files are better to edit with Notepad than with Excel ))

 
yu-sha:

1) Each neuron must have a unique name, for example NEURON:1.HID:0

The name implies that it is the 1st neuron of the HID:0 layer

2) the links use the neuron names + weights for addressing

3) every neuron class can (and must) override the virtual bool Init (CXmlElement *aXmlElement, CNet *aNet) and load from XML

P.S.

It's better to edit XML files with Notepad than with Excel ))

Yes, I've edited it with both Excel and Word and Notepad, but it's not obvious, it's just two neurons, and it will be 200-2000, and each will have 100-200 links.

If I have to fiddle with it, I want it to be graphically useful or display, or, even better, graphically editable.

If you're going to do something, it should be more convenient than this: columns where we get it from, rows where we distribute it to

[количество слоёв] 3
[тип 0 слоя]input[количество нейронов 0 слой]2
[тип 1 слоя]mlp  [количество нейронов 1 слой]2
[тип 2 слоя]mlp  [количество нейронов 2 слой]1
   0 1 2 3 4
 -----------
0| 0 0 1 1 0
1| 0 0 1 1 0
2| 0 0 0 0 1
3| 0 0 0 0 1
4| 0 0 0 0 0
 
Urain:

Yes, I've got it in both Excel and Word and notepad, well, not obvious, it will be a wreck, while two neurons and will be 200-2000 and each for 100-200 connections.

If you have to fiddle with it, it would be easy to graphically display, or even better to edit graphically.

That's what PreProcessor is for.

Whether you have 2 neurons or 100, the file size is the same.

Well, if you want to edit graphically, no one is stopping you - just write a GUI and use

 
yu-sha:

PreProcessor is exactly for this

Whether you have 2 or 100 neurons, the file looks the same

And if you want to use graphics, you're free to write a GUI and use it.

Well, let's not hack off the shoulder, let's lay it all out in clear lines. I do not know that for others the same, but for me the way of loading that I posted above is obvious in terms of the algorithm of loading:

read a string, initialize 3 layer type objects,

read the first line, then call the first layer object, construct layer type input, initialize array of 2 neurons.

read the second line, then call the second object layer, construct the layer type mlp, initialize the array of 2 neurons.

read the third line, then call the second object layer, construct the mlp layer type, initialize the neuron array of 1.

Since the number of layers is 3, we finish the construction on the third line and assign connections.

for which we go through the table and call the necessary neurons, telling them the connections if the table contains 1.

And how would the algorithm work in xml ?

And the main advantage is that since the connection table is binary, it's perfectly shrinkable. The table for 8 neurons fits in one ulong. True, the farther into the woods the thicker the partisans in general the size with a large number of neurons is calculated as

X=N*N/8

where N is the number of neurons,

X is the number of bytes.