-
Notifications
You must be signed in to change notification settings - Fork 647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ENH] using TFT without past target values #1585
Comments
Did you find an answer to this question? I have the same problem/question. |
I think it is fixed by this: #1667 Generally, it is hard to understand the bug without minimal reproducible code - it would be appreciated if you could post code, or check whether the PR fixes the failure in your case. |
For my issue, I didn't want the target values being sent to the encoder, which for me causes leakage when there is some future aspect in the target values.. Not at all sure that this is the best approach but it seems like it might work for me. class MyTimeSeriesDataSet(TimeSeriesDataSet):
|
More appropriately, shouldn’t there be some way of specifying which taget variables should not be sent to the encoder? As for the documentation it wasn’t at all clear to me this is what was happening and it took me a while to understand this. The documentation should be abundantly clear about this. |
Does this issue summarize the documentation request well? What would help a lot if (in #1591) you could point exactly to classes or methods, with import locations, where you think documentation is currently unclear, @moogoofoo. Further, if you think the interface should change to a specific target state, an explicit explanation in this issue would be helpful. |
I was having the same issue. My target was based on looking up to 20 steps into the future, so this means that for the encoder_targets, I somehow needed to ignore the final 20 steps of of the encoder_targets in the getitem in order to avoid data leakage problems. I initially knew something was wrong because I was getting unreasonably high accuracies in the problem I was tackling, which caused me to go digging and see that the targets were getting used intermediately at the encoder output (I remembered reading this in the paper on TFT, but then had forgotten it). For MSELoss problems (and similar), you can set them to NaN, as the PyTorch loss function is smart enough to know that those shouldn't factor into the loss. I couldn't find a built-in way of doing this kind of masking easily. My solution was to just add a line at Line 1662 of the timeseries.py (right before the return), where I set the
Here I replace "-20" with whatever my lookahead window was when computing my target value. In this manner, I think I am assuring that I don't have data leakage. This is a very hacky solution, and I tried to see if there was a way to add a mask or lookahead window by subclassing TimeSeriesDataset. I got it working with the TimeSeriesDataset, but then couldn't figure out why that didn't also work when using the from_dataset static member function. I really need this to work for from_dataset for my val and test sets, so that I have the same normalization statistics derived from the training set. I need to dig in more to find a permanent solution, and could potentially make a pull request once I get it sorted out. |
Followup: Here is the derived TimeSeriesDataSet class that I came up with to do the masking I need. It seems to be working as I wanted it to. I'm sure there are more compact ways of doing the parameters with *args and **kwargs. This allows me to make my binary training targets be looking into the future, but ensure there is no data leakage for the intermediate encoder_targets. The one thing I hadn't realized until I was working on this is that the TFT can have variable encoder series lengths. What this means is that if I don't set the min_encoder_length to be larger than the encoder_mask_len, then I have the possibility of having all encoder_targets being masked off. I will probably try adding all three parameters of min_encoder_length, max_encoder_length, and encoder_mask_len to my optuna parameter optimization search.
|
@jpswensen, this is nice! Would you be able to contribute this in a pull request, and possibly a test case, to see whether this works and also does not break anything? Would be great! |
Hi all, this question is quite interesting, any updates on this? |
,I think the high-level update is two-fold:
|
-Hi,
I have a question regarding the use of the Temporal Fusion Transformer (TFT) model.
Is it possible to effectively use the TFT model without providing past target values in the known or unknown inputs? Specifically, I am only passing the target value as the target in the TimeSeriesDataset class and never include past target values in the known or unknown inputs.
Could you please provide some guidance in such scenarios?
Thank you for your assistance!
Best regards,
Maha
The text was updated successfully, but these errors were encountered: