'How to exclude the output/label from the list of inputs when performing time series forecasting with Tensorflow
I'm trying to make use of an online Tensorflow tutorial for my own purposes, as it's very close to something I would like to do with time series forecasting (https://www.tensorflow.org/tutorials/structured_data/time_series#3_plot). However, there's one big difference between my objective and what's provided by Tensorflow. In the tutorial, the output/label (T(deg C)) is also effectively used as a feature when making the predictions. What changes should be made to the code so that this doesn't happen and only the features that I define are used to make the prediction? I still want the time series element captured, I just don't want to factor in the output/label observations when making the prediction. The output/label observations would then only be valuable for training, validation and testing - they would not ultimately be needed to make the forecast.
I first tried the following modification already, where I added "-num_outputs" where the inputs are defined under "split_window".
def split_window(self, features):
inputs=features[:, self.input_slice, :-num_outputs]
labels=features[:, self.labels_slice, :]
if self.label_columns is not None:
labels=tf.stack(
[labels[:, :, self.column_indices[name]] for name in self.label_columns],
axis=-1)
inputs.set_shape([None, self.input_width, None])
labels.set_shape([None, self.label_width, None])
return inputs, labels
WindowGenerator.split_window=split_window
This only half worked, as Python threw the following error at me further on down in the code: "slice index 6 of dimension 2 out of bounds. [Op:StridedSlice] name: baseline/strided_slice/". As you might have guessed, 6 is my target number of features.
Any help would be much appreciated. Thank you!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
