How to use an external variable in a custom loss function for an lstm model in Keras?

47 views Asked by At

I am attempting to create an LSTM model to predict buy and sell signals. What I have is some imput devided like: (batch_size, delta_time, input_vector_vals). The LStm will take delta_time number of input_vectors (delta_time, input_vector_vals) and output a single vector of two components (the buy signal and the sell signal).

To train the lstm I would like to be able to use one more variable besides the two obligatory (lstm_output and real_output). The extra variable would vary for each output meaning that each input will also have an associated extra variable. I would like to use the extra variable in the loss function to be able to control how relevant the mistakes of the net must be. Basically I want to make the error less impactfull for some particular time events and more impactfull in others, this is why I want to use the extra variable.

Is there a way to accomplish this? Am I off in my reasoning?

0

There are 0 answers