Has anyone used LSTM?

Posted By: TraderTom

Has anyone used LSTM? - 01/16/21 22:41

Hi Everyone,

First time posting on here. I've been working on models for a couple of years, mostly with python, and have recently discovered zorro. The example machine learning scripts for zorro are very good but obviously written in R and C so a little alien to me.

I was wondering if anyone had done anything with LSTM's within zorro? Ideally within the example scripts to see a generic example. Obviously the main difference vs the standard keras example script is the shaping of the input data needs to be an array. Interested to see if anyones done anything with it?
Posted By: jcl

Re: Has anyone used LSTM? - 01/27/21 09:22

An example LSTM structure:

Code
create_model <- function(batchSize) {
  dropout <- 0.3
  model <- keras_model_sequential() 
  model %>%
    layer_lstm(batch_input_shape =  c(batchSize, 1, 27), units = 128, return_sequences = TRUE, stateful = TRUE, dropout = dropout, recurrent_dropout = dropout) %>%
    layer_lstm(units = 64, return_sequences = TRUE, stateful = TRUE, dropout = dropout, recurrent_dropout = dropout) %>%
    layer_lstm(units = 8, return_sequences = FALSE, stateful = TRUE, dropout = dropout, recurrent_dropout = dropout) %>%
    layer_dense(units = 1, activation = 'sigmoid')
}
Posted By: TraderTom

Re: Has anyone used LSTM? - 02/01/21 12:17

Thanks for your reply.

Sorry, it probably me being very very new to R but I'm struggling to understand how to use this in the context of zorro and R. I tried to create a model by modifying the DeepLearnKeras script as that seems to be the most obvious. It works fine in RStudio but then in zorro just fails at every step. Am I missing something in zorro to increase the verosity to give errors rather than just failing at each step?

Thanks

Tom
Posted By: strimp099

Re: Has anyone used LSTM? - 02/18/21 12:46

I’m also a python dev but the manual has enough to get started. Also note the R script has to have a certain structure for Zorro to know how to call. This might help: https://financial-hacker.com/build-better-strategies-part-5-developing-a-machine-learning-system/
Posted By: TraderTom

Re: Has anyone used LSTM? - 02/20/21 00:28

This was more to do with data shaping and the way zorro sends data to the neural functions.

Its less about neural networks in R and more about data shaping into 3D inputs for LSTM's.
© 2024 lite-C Forums