Skip to Content
Hands-On Machine Learning for Algorithmic Trading
book

Hands-On Machine Learning for Algorithmic Trading

by Stefan Jansen
December 2018
Beginner to intermediate
684 pages
21h 9m
English
Packt Publishing
Content preview from Hands-On Machine Learning for Algorithmic Trading

Defining and training the model

We use a similar architecture with two stacked LSTM layers with 12 and 6 units, respectively, followed by a fully-connected layer with 10 units. The output layer has two units, one for each time series. We compile them using mean absolute loss and the recommended RMSProp optimizer, as follows:

n_features = output_size = 2lstm1_units = 12lstm2_units = 6rnn = Sequential([    LSTM(units=lstm1_units,         dropout=.2,         recurrent_dropout=.2,         input_shape=(window_size, n_features), name='LSTM1',         return_sequences=True),    LSTM(units=lstm2_units,         dropout=.2,         recurrent_dropout=.2,         name='LSTM2'),    Dense(10, name='FC1'),    Dense(output_size, name='Output')])rnn.compile(loss='mae', optimizer='RMSProp')

The model has 1,268 parameters, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Machine Learning for Algorithmic Trading - Second Edition

Machine Learning for Algorithmic Trading - Second Edition

Stefan Jansen

Publisher Resources

ISBN: 9781789346411Supplemental Content