4

I have a recurrent neural network in Flux of the form:

net = Chain(LSTM(8,100), Dense(100,1))

The input to the network are minute bars of stock data (each of those bars having 8 numbers), where there can be a varying number of bars fed into the recurrent network. I am repeating this on roughly 2000 different stocks. Here is how the data generally looks:

enter image description here

enter image description here

I am using the following function to feed the data into the recurrent network:

function mapNetworkOverStocks(net, stocksInput)
    unFlattened = map(x -> (output = net.(x); Flux.reset!(net); output), stocksInput)
    map(x -> map(y -> y[1], x), unFlattened)
end

and calling it with:

mapNetworkOverStocks(net, allStocksData)

The problem is that it is running pretty slowly. In Mathematica, I am able to get similar code to run in 7.79389 seconds, while it is taking 93.413394 seconds in Julia. Is there any way to get this running as quickly as the Mathematica version?

logankilpatrick
  • 13,148
  • 7
  • 44
  • 125
Jmeeks29ig
  • 219
  • 1
  • 7
  • Any reason why you're using a map within a map, just to grab the first index of all elements? Doing stuff like `arr[:,1]` or `arr[1,:]` doesn't require nested maps, I don't think... – bug_spray Mar 24 '20 at 18:17

0 Answers0