3rd generation NN, deep learning, deep belief nets and Restricted Boltzmann Machines

This is a discussion on 3rd generation NN, deep learning, deep belief nets and Restricted Boltzmann Machines within the Trading Software forums, part of the Commercial category; Initially I wondered why we use the SVM on such apparantly trivial estimation problems. Bayes shows us that the best ...

Reply
 
LinkBack Thread Tools Search this Thread
Old Oct 17, 2010, 12:31am   #16
Joined Jan 2007
Re: 3rd generation NN, deep learning, deep belief nets and Restricted Boltzmann Machi

Initially I wondered why we use the SVM on such apparantly trivial estimation problems. Bayes shows us that the best decision we can make uses the conditional pdf p(y/x) where y is output and x is input. So in effect, we are using the SVM to estimate this pdf. Another way to estimate it would be to count the number of times x results in y (Num(y/x)), and count the number of times x occurs. Then a good estimate i s Num(y/x)/Num(x). This is probably pretty good if we have 60 counts or so in each counting bin. So, for 1000 samples, as used in these examples, we could accommodate maybe 16 bins.

In fact, for the Explosivepip strategy there are only 3 conditions and 2 outputs, so we would need only 16 bins, and 1000 samples are probably enough.

However in the pipMaximizer strategy there are 9 conditions and 2 outputs, so we would need 256 bins, and with 1000 samples we have only 4 counts in each bin on average, so the estimate would probably be poor indeed if the pdf is at all spread out.

It would be interesting to compare the performance of an SVM to a histogram at least for the ExplosivePip strategy.

We might simply use more samples and return to counting things, but then we might run up against the inherent non-stationarity in Fx series. By the time we got to 25600 samples we might have lost the local pdf, and find only a pdf averaged over too much time. So maybe the SVM is a good idea after all. It will be a particularly good idea if we ever get to continuous inputs and outputs.

Incidentally, I have been trying to understand the hasline.m code. It seems to me that this is a count of the number of bars that cross a line defined by the mid of a bar. This is not the same as the article referenced in the code comments, where the idea is to find price lines with the minimum number of crossings. Furthermore, the result is counted over a period from 1 to t-1 which increases with t. So as t increases this count will increase, and the likelihood that it will exceed M will increase, until after a couple of hundred samples it seems that this indicator is very likely to be 1 and carry no information. Can someone check me on this please?
fralo is offline   Reply With Quote
Old Oct 17, 2010, 5:20am   #17
Joined Jan 2007
Re: 3rd generation NN, deep learning, deep belief nets and Restricted Boltzmann Machi

Indicator builder uses open for BBands and all MA's. If we use close for entry/exit (as we should) then I suggest that all indicators use close as input.
fralo is offline   Reply With Quote
Old Oct 17, 2010, 7:29am   #18
Joined Nov 2001
Re: 3rd generation NN, deep learning, deep belief nets and Restricted Boltzmann Machi

Quote:
Originally Posted by Prawnsandwich View Post
Listened to the first few minutes of one of these out of curiosity..and I have to say it sounds like a pile of sh1t..... deliberately vague and pseudo -complicated ..maybe it gets better further on in...anyone else have more patience ?


I like the way you circled the problem and then decided to call a spade a spade!

They'll be feeding us prawnsandwiches next!
Splitlink is offline   Reply With Quote
Old Oct 17, 2010, 10:53am   #19
Joined Jan 2009
Re: 3rd generation NN, deep learning, deep belief nets and Restricted Boltzmann Machi

Krzysiaczek99 started this thread
Quote:
Originally Posted by fralo View Post
Indicator builder uses open for BBands and all MA's. If we use close for entry/exit (as we should) then I suggest that all indicators use close as input.
Yes it must be changed otherwise is a mess for example in this code
he compares pSAR with Close and checks MACDSign which is calculated on Open

Code:
cond(1) = pSAR(i) < close(i); % parabolic SAR below
            cond(2) = (price(i) > stop) || (price(i) < limit);
            cond(3) = (MACDSign(i)) > 0 && (MAhist(i) > 0); %TODO: cross over above
I will make a document where i will collect all changes and solutions
Krzysiaczek99 is offline   Reply With Quote
Old Oct 17, 2010, 10:59am   #20
Joined Jan 2009
Re: 3rd generation NN, deep learning, deep belief nets and Restricted Boltzmann Machi

Krzysiaczek99 started this thread
Quote:
Originally Posted by Highfreq View Post
You should not waist your time on this kind on nets. I have implemented several kinds and realized that the reasons they work so well at classifying stuffs are the very reasons they donít work when applied to markets:

They are very sensitive to the number and the size of layers which make them impractical in market environments.

For the training stage to converge properly they need many thousands input occurrences:
- Even in optimized C++ training takes several hours,
- Even with feature extraction, it is hard or even impossible to find such high number of input occurrences from market data.

These networks have several hundred million neurons the majority on them placed on the first layer. The reason Deep networks work so well in classification is that they encode each possible solution to the problem in the first layer. It is then just a matter to pick the most appropriate one from higher level representations just as it happens in the brain. Deep networks fit the problem at hand very well though raising the question of generalization. Neural nets do not adapt but I was expecting them to pick recurrent market states so that I could trade the deviation. Well, it was quite a disappointment for me to realize that they donít. It was argued that deep networks infer new solutions after learning but I did not see it.

My conclusion after 3 years investigating deep architectures. They are not appropriate to trading at the moment. To address the generalization issue we need incremental versions with online learning. I am currently looking into dynamic factored structures which use similar RBM building blocks. I believe they are more promising but still in a very early stage of development.

My advice: carry out due diligence before spending time on this.

My 2 pips.
Very interesting mail. Is your research a public domain ?? Is it possible to have a look ??
What sort of models you examined ?? Did you try Hilton's autoencoder model with pretraining, training and fine tuning ?? What learning algorithms you used ??

Krzysztof
Krzysiaczek99 is offline   Reply With Quote
Old Oct 17, 2010, 11:44am   #21
Joined Jan 2009
Re: 3rd generation NN, deep learning, deep belief nets and Restricted Boltzmann Machi

Krzysiaczek99 started this thread interesting post from barnix from forex-tsd

http://www.forex-tsd.com/expert-advi...tml#post365921

on his site

http://sites.google.com/site/bettereaclone/

there is his SVM EA together with some infor about LDS. Another system to compare and methods to investigate

Last edited by Krzysiaczek99; Oct 17, 2010 at 11:54am.
Krzysiaczek99 is offline   Reply With Quote
Old Oct 17, 2010, 1:47pm   #22
Joined Nov 2008
Re: 3rd generation NN, deep learning, deep belief nets and Restricted Boltzmann Machi

Quote:
Originally Posted by Splitlink View Post


I like the way you circled the problem and then decided to call a spade a spade!

They'll be feeding us prawnsandwiches next!
Maybe I was just being lazy and jumping to conclusions.....or maybe not..
Prawnsandwich is offline   Reply With Quote
Old Oct 17, 2010, 5:10pm   #23
Joined Jan 2009
Re: 3rd generation NN, deep learning, deep belief nets and Restricted Boltzmann Machi

Krzysiaczek99 started this thread
Quote:
Originally Posted by fralo View Post

Incidentally, I have been trying to understand the hasline.m code. It seems to me that this is a count of the number of bars that cross a line defined by the mid of a bar. This is not the same as the article referenced in the code comments, where the idea is to find price lines with the minimum number of crossings. Furthermore, the result is counted over a period from 1 to t-1 which increases with t. So as t increases this count will increase, and the likelihood that it will exceed M will increase, until after a couple of hundred samples it seems that this indicator is very likely to be 1 and carry no information. Can someone check me on this please?
Yes, the code is wrong

Code:
its called from here in explosivePip

54  for t=1:length-1
          price = open;
          cond = zeros(1,NUM_COND);
          cond(1) = hasLine(low,high,t,'SUP'); 


function x = hasLine(low, high, t, type)
    % adopted from: http://articles.mql4.com/369
    % A Method for Drawing Support and Resistant Line
    % a suport line is present if there at least previous M bar that cross
    % its price.
    % We added that past high must not below current line for support
    % and past low must not above current line for resistant
    % In this simplified version, we choose:
    M = 4;   
    x = 0;
    if (t >= M)        
        cross_count = 0;
        mid = (low(t) + high(t))/2;
        last = t-1;     
        for i = 1:last  <----- range will increase on every call
            if (low(t-i) < mid) && (high(t-i) > mid)
                cross_count = cross_count + 1; % first cross is itself
                if (cross_count >= M)
                    break;
                end
the range in 'for' statement will increase but it should be fixed. Perhaps instead of this we can use another solution. See this.

http://www.breakoutfutures.com/Newsl...letter0303.htm

Krzysztof
Krzysiaczek99 is offline   Reply With Quote
Old Oct 18, 2010, 12:47pm   #24
Joined Jan 2009
Convolutional Neural Networks

Krzysiaczek99 started this thread I believe we should extend scope of our project for Lechun Convolutional Neural Networks.
Seems to have error lower by 50-70% than BP and SVM. Relevant info below.

http://www.iro.umontreal.ca/%7Elisa/...hapter2007.pdf
http://www.cs.nyu.edu/~yann/talks/le...3-convnets.pdf

http://www.mathworks.com/matlabcentr...-network-class

Krzysztof
Krzysiaczek99 is offline   Reply With Quote
Old Oct 18, 2010, 7:23pm   #25
Joined Jan 2007
Re: 3rd generation NN, deep learning, deep belief nets and Restricted Boltzmann Machi

Here is a question for philosophers and thread poets. Care to answer?

There is inherent structure in the images and speech that have been the targets of most DBN research... most children can do better than most machines because they have learned the structure. The machines try to extract the structure. Some do it well for images and speech. Can they do it for markets?

Is there structure to some representation of the markets? Certainly not recognizable by most adults. Probably not recognizable by majority of traders. Do supertraders recognize structure, or are they just defying the odds?

DBN machines make sense for robotic applications. Do they make sense for the market?
fralo is offline   Reply With Quote
Old Oct 18, 2010, 7:49pm   #26
Joined Aug 2008
Re: 3rd generation NN, deep learning, deep belief nets and Restricted Boltzmann Machi

Quote:
Originally Posted by fralo View Post
Here is a question for philosophers and thread poets. Care to answer?

There is inherent structure in the images and speech that have been the targets of most DBN research... most children can do better than most machines because they have learned the structure. The machines try to extract the structure. Some do it well for images and speech. Can they do it for markets?

Is there structure to some representation of the markets? Certainly not recognizable by most adults. Probably not recognizable by majority of traders. Do supertraders recognize structure, or are they just defying the odds?

DBN machines make sense for robotic applications. Do they make sense for the market?
Here are features from patches of weights in the second layer of a DBN trained with contrastive divergence and fine tuned with conjugate gradients. These features are high level representations of price patterns. Very powerful stuff. The only concern and not the least would be to devise an online version of the training process so that we can use them in trading. I am not aware that online learning exists for deep structures.

Sorry got to close a position...
Attached Thumbnails
feature-5-50.gif   feature-12-50.gif   feature-10012.gif  

Highfreq is offline   Reply With Quote
Old Oct 18, 2010, 9:47pm   #27
Joined Jan 2007
Re: 3rd generation NN, deep learning, deep belief nets and Restricted Boltzmann Machi

I found several bugs that were future leaks, and some that were due to stop and limit exit prices not correctly evaluated. I changed these to fix the bugs, and ran a strategy evaluation on the new code. The results are very different. e.g. For instantpip I get profit = -$1724 on 461 trades.

I did not test the other strategies, since I do not have confidence in my ability to code fixes in MatLab. The modified code is contained in the zip file below. You will find that there are changes in spotFX.m,hasline.m, indicatorBuilder.m, and the four exits. All of my future leak changes are marked by a comment beginning with scf, so they are easily found; however, to fix the problem with stop and limit exit prices I had to make larger changes, so not all those are commented. But they are obvious on comparison to earlier versions.

The code I used to train and evaluate the instantpip strategy is in the zip file. Anyone interested please do not take my word, but look at the code and find any errors that I have made. I hope you find some.

If you find no errors, then I suggest that most of the good results reported in TradeFX are due to future leaks and incorrect exit price evaluation. We must do the work over!
Attached Files
File Type: zip TradeFX mods.zip (10.7 KB, 172 views)
fralo is offline   Reply With Quote
Old Oct 19, 2010, 12:48am   #28
Joined Jan 2009
Re: 3rd generation NN, deep learning, deep belief nets and Restricted Boltzmann Machi

Krzysiaczek99 started this thread
Quote:
Originally Posted by Highfreq View Post
Here are features from patches of weights in the second layer of a DBN trained with contrastive divergence and fine tuned with conjugate gradients. These features are high level representations of price patterns. Very powerful stuff. The only concern and not the least would be to devise an online version of the training process so that we can use them in trading. I am not aware that online learning exists for deep structures.

Sorry got to close a position...
So are you using this autoencoder setup with pretraining and fine tuning ?

Did you or somebody else try Convolutional Neural Networks for market data ??

Krzysztof
Krzysiaczek99 is offline   Reply With Quote
Old Oct 19, 2010, 3:25am   #29
Joined Jan 2007
Re: 3rd generation NN, deep learning, deep belief nets and Restricted Boltzmann Machi

Quote:
Originally Posted by Highfreq View Post
Here are features from patches of weights in the second layer of a DBN trained with contrastive divergence and fine tuned with conjugate gradients. These features are high level representations of price patterns. Very powerful stuff. The only concern and not the least would be to devise an online version of the training process so that we can use them in trading. I am not aware that online learning exists for deep structures.

Sorry got to close a position...
I don't see why an online version could not be done. Conceptually you could do it with two Dll's, one to train and one to classify as follows:
Arrays/structures:
Rates array.. contains OHLCV for each bar
Target array..contains results if entry on a given bar
Input array
Net
MT4
Allocates memory for all structures (This is so that strategy tester will work. )
Maintains rates and Target array
Calls Net_Train with pointers to arrays
Calls Net_Classify with pointers to arrays
Uses result to trade
Net_Train
Calls feature_builder to build input array
Uses target array to label input array
Trains Net
Net_Classify
Calls feature_builder to update input array
Applies net to determine prediction
Feature_Builder
Calculates input to net .. indicators, conditions to build input array

Operation:
MT4 initializes the net by calling Net_Train
At end of each bar:
If a new label has been determined, MT4 calls Net_Train to update input array and retrain the net.
MT4 calls Net_Classify to get a prediction
MT4 makes appropriate trading decisions.

This all assumes that a net_train dll could run in 1 bar time. If not, then the training would have to go on in the background while new input was collected. Would require some double buffering.

Those are intriguing pictures of hidden structure. What is the nature of the input price patterns, and the DBN used to find them? I assume unsupervised learning for this level?
fralo is offline   Reply With Quote
Old Oct 19, 2010, 1:20pm   #30
Joined Jan 2009
Re: 3rd generation NN, deep learning, deep belief nets and Restricted Boltzmann Machi

Krzysiaczek99 started this thread
Quote:
Originally Posted by fralo View Post
I found several bugs that were future leaks, and some that were due to stop and limit exit prices not correctly evaluated. I changed these to fix the bugs, and ran a strategy evaluation on the new code. The results are very different. e.g. For instantpip I get profit = -$1724 on 461 trades.

I did not test the other strategies, since I do not have confidence in my ability to code fixes in MatLab. The modified code is contained in the zip file below. You will find that there are changes in spotFX.m,hasline.m, indicatorBuilder.m, and the four exits. All of my future leak changes are marked by a comment beginning with scf, so they are easily found; however, to fix the problem with stop and limit exit prices I had to make larger changes, so not all those are commented. But they are obvious on comparison to earlier versions.

The code I used to train and evaluate the instantpip strategy is in the zip file. Anyone interested please do not take my word, but look at the code and find any errors that I have made. I hope you find some.

If you find no errors, then I suggest that most of the good results reported in TradeFX are due to future leaks and incorrect exit price evaluation. We must do the work over!
After three small changes in the scripts (twice change open to close and transaction_fee set) accuracy seems to be 68.1% for instantPip strategy for EURUSD30_1_16Apr09.csv.

Missing funcionality in all those scripts seems to be spread handling. Spread must be considered both in profit calculation and entry/exit conditions calculation.

Krzysztof
Krzysiaczek99 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads
Thread Thread Starter Forum Replies Last Post
Neural Networks - Genetic Algorithms - Boltzmann Machines - FOREX crystal balls? gtatix Forex 27 Apr 30, 2012 9:27am
How deep is your Level II? insight2 Technical Analysis 6 Apr 29, 2008 10:41pm
In at the deep end! superspur First Steps 12 Dec 24, 2007 11:34am
Deep insight Disqplay Trading Software 1 Feb 7, 2006 12:01am
Deep INsight NKE Trading Software 0 Apr 8, 2005 10:57am

LinkBacks (?)
LinkBack to this Thread: http://www.trade2win.com/boards/trading-software/105880-3rd-generation-nn-deep-learning-deep-belief-nets-restricted-boltzmann-machines.html
Posted By For Type Date
Better NN EA development - Page 82 - Forex-TSD This thread Pingback Oct 17, 2010 12:51pm

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)