0
$\begingroup$

In the paper "A Deep Reinforcement Learning Framework for the Financial Portfolio Management Problem" the CNN in the picture below is applied on the portfolio management problem.

CNN

I am trying to understand how this network works and can be implemented in keras.

What I don't understand is, why do we have 20+1 feature maps after the second convolution? And how I am supposed to include the portfolio w from last period in keras?

My current implementation is as follows:

def network(self):
    input1 = Input(shape=(3, 50, 4))
    conv1 = Conv2D(2, (1, 3), activation='relu',)(input1)
    conv2 = Conv2D(10, (1, 48), activation='relu')(conv1)
    conv3 = Conv2D(1, (1, 1), activation='relu')(conv2)
    flat1 = Flatten()(conv3)
    preds = Activation('softmax')(flat1)
    model = Model(input1, preds)
    model.compile(optimizer='rmsprop', loss='mse') # todo loss function
    return model

Thanks for any help.

$\endgroup$
0
$\begingroup$

You can concatenate your tensors in Keras. I have written the model below

from keras.models import Sequential, Model
from keras.layers import Concatenate, Dense, LSTM, Input, concatenate, Flatten
from keras.optimizers import Adagrad

price_history = Input(shape=(11, 50, 3))
feature_maps = Conv2D(2, (1, 3), activation='relu')(price_history)
feature_maps = Conv2D(20, (1, 48), activation='relu')(feature_maps)

# Add the w from the last period
w_last = Input(shape=(11, 1, 1))
feature_maps = concatenate([feature_maps, w_last], axis = -1)
feature_map = Conv2D(1, (1, 1), activation='relu')(feature_maps)
feature_map = Flatten()(feature_map)

# Add the cash bias
cash_bias = Input(shape=(1,))
feature_map = concatenate([feature_map, cash_bias], axis = -1)
w = Activation('softmax')(feature_map)

model = Model(inputs=[price_history, w_last, cash_bias], outputs=w)
print(model.summary())

model.compile(optimizer=ada_grad, loss='binary_crossentropy',
               metrics=['accuracy'])

I am not sure about the loss function, I have not read the paper in detail. But this model describes what they have in the paper.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.