I am following the tutorial about Time Series Forecasting from the TensorFlow website (https://www.tensorflow.org/tutorials/structured_data/time_series), and I am facing difficulties caused by the occurrence of the error below (which also occurs in other code snippets that run later), when I apply my input data (time series), that has 1440 points, to the code, and I change the code to forecast 300 points (OUT_STEPS = 300, label_width=OUT_STEPS, shift=OUT_STEPS, etc.), also adjusting the inputs to 300.
Executed code:
history = compile_and_fit(lstm_model, wide_window)
IPython.display.clear_output()
val_performance['LSTM'] = lstm_model.evaluate(wide_window.val)
performance['LSTM'] = lstm_model.evaluate(wide_window.test, verbose=0)
Code execution output:
/usr/local/lib/python3.7/dist-packages/keras/utils/generic_utils.py:915: RuntimeWarning: divide by zero encountered in log10
numdigits = int(np.log10(self.target)) + 1
---------------------------------------------------------------------------
OverflowError Traceback (most recent call last)
<ipython-input-67-8a2e627c43f4> in <module>()
2
3 IPython.display.clear_output()
----> 4 val_performance['LSTM'] = lstm_model.evaluate(wide_window.val)
5 performance['LSTM'] = lstm_model.evaluate(wide_window.test, verbose=0)
4 frames
/usr/local/lib/python3.7/dist-packages/keras/utils/generic_utils.py in update(self, current, values, finalize)
913
914 if self.target is not None:
--> 915 numdigits = int(np.log10(self.target)) + 1
916 bar = ('%' + str(numdigits) + 'd/%d [') % (current, self.target)
917 prog = float(current) / self.target
OverflowError: cannot convert float infinity to integer
I concluded that there is some dependency between the number of data entry and the number of forecast points, because if I set the number of forecast points to 300 points in the example of the TensorFlow website, with number of input like 70091 (considering df = df[5::6]), this type of error that I mentioned does not occur, but if I select only 1440 points, the same error that occurs applying my data of 1440 points also occurs. If you want you can check/edit the example code from the TensorFlow website, in which I set the input number 1440 points, and made the necessary settings to forecast 300 points, here on this Google Colab Notebook: https://colab.research.google.com/drive/1DCraelosxrRcF6VLF5Fv6Rj5hSfvr_YS?usp=sharing.
Could anyone help me with this, please?
Thanks in advance.
The error is caused by passing a zero value (self.target) into numdigits = int(np.log10(self.target)) + 1
this means numdigits == np.inf and you can't do int(np.inf).
I think the real issue though is caused by wide_window's shape. when you run `wide_window.val' you are getting shape (None, 300, 19) and (None, 300, 1) and I think you want it to have (32, 300, 19) and (32, 300, 1).
Hope that helps you start to track it down.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With