Time Variant Networks

Have specific questions about how to work with certain MemBrain features? Not sure about which checkbox in MemBrain has which effects? Want to know if a certain functionality is available in MemBrain or not?

Your questions will be appreciated here!
roman
Posts: 3
Joined: Sat 29. Jul 2017, 10:15

Time Variant Networks

Postby roman » Sat 29. Jul 2017, 10:36

I have done neural network for predicting price movement in Forex.
I used the delay neurons. I have prepared the training data and trained network. The question is now how to use it (network) in applications? Only one input and one output, but the network decides based on previous input values.To give those previous values? I tried before checking to give the necessary number of input values, but it did not help - the network lies on the source of the sample data.

User avatar
TJetter
Posts: 267
Joined: Sat 13. Oct 2012, 11:04

Re: Time Variant Networks

Postby TJetter » Sun 30. Jul 2017, 11:58

Hi,
it's actually difficult to say anything without more specific information and/or questions.
Are your questions related to creation and training of your network in MemBrain itself or are you solely wondering how to integrate the network into your application?
In the latter case we first need to discuss about which application you want to integrate into. You'll probably need to use the MemBrain dll then to access the NN from your application. Depending on the application the way to access dlls typically varies.

Before you try to integrate the NN into your application, however, you first need to be sure that you exactly know what you want to do with the network. This in particular includes that you know what time series you want to feed into your networks and what exactly you are predicting.

Can you post your network and training/validation data here? That would help a lot in analyzing things.

Regards
Thomas Jetter

roman
Posts: 3
Joined: Sat 29. Jul 2017, 10:15

Re: Time Variant Networks

Postby roman » Sun 30. Jul 2017, 14:58

Hello, Thomas!
Thank you for you reply :)
I wrote a small application in MQL5 which help to manually indicate reversal points (moments) and generate data set. The obtained data set is trained with help of MemBrain.
After that I generate the C-code and use it to create the DLL, which in turn is connected to a MQL5 application for testing.
And everything works fine.
To filter the found reversal points of price I want to use a prediction of the price movement. The question is: when I use a simple neural network to classify the incoming data I'm passing the dataset , call a function Think and recieve some number of outputs. When using Time Variant network - I need to transfer only one input value to obtain a single output value. But when using Delay neurons in the network I should (I think) to pass the values that precede the input value to get the correct result. And with that, there is a problem:)
So, I need example of using DLL with time variant net :)

PS: I can share the code to generate DLL and an example of how to use it in MQL4/MQL5.
Attachments
2017-07-30 20-42-17 Strategy Tester Visualization NNDiverEA5 on AUDUSD,M30 from 2016.01.01 to 2017.07.04.jpg
(231.5 KiB) Not downloaded yet
2017-07-30 20-41-12 50104752 - Alpari-MT5-Demo Demo Account - Hedge - [AUDUSD,M30].jpg
(174.41 KiB) Not downloaded yet

User avatar
TJetter
Posts: 267
Joined: Sat 13. Oct 2012, 11:04

Re: Time Variant Networks

Postby TJetter » Mon 31. Jul 2017, 20:30

Hi,

I'm not quite sure if I understand correctly: You use the MemBrain generated C-Code and the MemBrain C-Code library in order to generate a dll (using which compiler?) which you then use from metatrader, right?
Why don't you use the MemBrain dll directly from metatrader and load your trained net via the dll? Why are you useing the C-code? Or does metatrader not allow to access native windows dlls?

Nevertheless, no matter if you use the c-code or the dll: In case you use delay neurons (or rather delay links) you can apply an input value to all of your input neurons, then perform a Think Step and a new output activation will be produced at the output neuron(s) of your net. In principal, this is no difference to time invariant nets. However, the produced output neuron activation(s) do not only depend on the last applied input activation but also on the internal state of the net (internal neuron activations and activations stored along delay links). I.e. the order of input data sets matters, both during training and during usage of the net. Also, the initialization of the net matters since this determines its initial internal state. A good approach is to feed a significant time series into the net in order to 'flush' it, before using its outputs.
Thomas Jetter

roman
Posts: 3
Joined: Sat 29. Jul 2017, 10:15

Re: Time Variant Networks

Postby roman » Tue 1. Aug 2017, 07:55

Hello, Thomas!
TJetter wrote:Hi,

I'm not quite sure if I understand correctly: You use the MemBrain generated C-Code and the MemBrain C-Code library in order to generate a dll (using which compiler?) which you then use from metatrader, right?
Why don't you use the MemBrain dll directly from metatrader and load your trained net via the dll? Why are you useing the C-code? Or does metatrader not allow to access native windows dlls?


The original idea was to try to port the code directly in MQL, which has very similar syntax and is actually a variant of C++. But due to the fact that the meaning of the typedef in MQL differs from similar in C, this task proved to be difficult.
I use VC2017. But it adds a lot of garbage. Think to use MinGW.
TJetter wrote:Nevertheless, no matter if you use the c-code or the dll: In case you use delay neurons (or rather delay links) you can apply an input value to all of your input neurons, then perform a Think Step and a new output activation will be produced at the output neuron(s) of your net. In principal, this is no difference to time invariant nets. However, the produced output neuron activation(s) do not only depend on the last applied input activation but also on the internal state of the net (internal neuron activations and activations stored along delay links).


Is it possible that state of delay neurons can be cleared between calling diffrent call of DLL? I mean MY DLL :D
In the generated code I found the part that, I think, is responsible for working with neurons. But I don't know whether their status in the following functions NeuralNetApplyInputAct call.
TJetter wrote: I.e. the order of input data sets matters, both during training and during usage of the net. Also, the initialization of the net matters since this determines its initial internal state. A good approach is to feed a significant time series into the net in order to 'flush' it, before using its outputs.


Yes, I think so and did it.
So, now I will try to use original DLL to check if it will help.
Thank you)

User avatar
TJetter
Posts: 267
Joined: Sat 13. Oct 2012, 11:04

Re: Time Variant Networks

Postby TJetter » Thu 3. Aug 2017, 05:33

roman wrote:s it possible that state of delay neurons can be cleared between calling diffrent call of DLL?

Yes, the MemBrain dll provides the function '_MB_ResetNet()' for this. In the C-Code the corresponding function is 'void NeuralNetInitAndReset(void)'.

The function resets all neurons to the (internal) activation 0 and also clears alls activations on links with len > 1 that are stored in the net.

You can test the effects of the function in MemBrain itself: Menu <Net><Reset Net>. You can use the setting <View><Show Activation Spikes on Links> in order to see the effect on stored activations in links with logical length > 1.

Regards,
Thomas
Thomas Jetter


Return to “All about using MemBrain”