Skip to content
Advertisement

How to increase the number of decimals when predicting an attribute using LSTM on Python?

I have an LSTM model on Python (Keras) in which predicts floats with long decimals. However, the predicted value has fewer decimals than expected. For instance:

  • Input value: 41.39011366661221
  • Predicted value: 41.396626

Should I use something on my model? I’ve also tried to normalize the input. Unfortunately, I get the same number of output decimals.

Any clue?

Advertisement

Answer

Your input have long decimals, but the problem is related to the way Keras captures your data by defining internally their floating format.

To set the Keras floating numbers internally you could :

1/ set the dtype definition (dtype stands for dataset type)

An example on a constant with Keras with different dtype definitions :

JavaScript

2/ set float using set_floatx() function :

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement