Open harashm opened 3 years ago
You need at least the time_idx
as the known covariate in the future.
I had this bug as well. It results in an AttributeError
"AttributeError (note: full exception trace is shown but execution is paused at: _run_module_as_main) 'NoneType' object has no attribute 'item'" in the on_train_batch_end (line 331). This is caused by the output being None and it trying to access an item that does not exist.
It is caused by a StopIteration being issued by the Lightning Core because there is no item in the output.
This in turn causes the TemporalFusionTransformer to bomb out at line 438 from the forward method and never get to the LSTM.
"embeddings_varying_decoder, decoder_sparse_weights = self.decoder_variable_selection(
embeddings_varying_decoder,
static_context_variable_selection[:, max_encoder_length:],
)"
The root cause of this appears to be the sub_modules VariableSelectionNetwork forward function. This test for the self.num_inputs being greater than 1. However in this situation the self.num_inputs = 0 ( for some reason) and we end up with a "stopiteration" from the lower level context libraries.
This was resolved when I put in a "time_varying_known_reals" to compliment the single "time_varying_unknown_reals" that I had. I therefore had 2 input variables rather than 1.
From the documentation it does not say that you have to have more than 1 input variable
The solution will be to either:
FYI wasted 2 days of debugging into the code and will likely catch out newbies like me.
This is the solution I found This is the solution I found training = TimeSeriesDataSet( data, time_idx = 'dateIndex', target = 'variable1', group_ids=['groupID'], max_encoder_length = 10, min_encoder_length = 10, min_prediction_idx = 1, max_prediction_length=5, min_prediction_length=5, time_varying_unknown_reals=['variable1'],
)
I tried to fit TFT model with univariate signal, no covariates at all, and I got into the following error. I wonder if this model can basically be fitted to my scenario, because after digging into the code, I saw some 'if else' statements based on 'num_inputs > 1', therefore I suspect its a bug ...
Code to reproduce the problem