Coder Social home page Coder Social logo

Comments (10)

SpeeeedLee avatar SpeeeedLee commented on May 20, 2024

Also, I do not fully understand how the model gets the prediction for multiple future time points autoregressively at inference time.

Say I want to make 3 future predictions, and 100 trajectories, does it work as follows?

for _ in range(100):

  1. Get the t-distribution parameters (Parameter_1) for the future first day.
  2. Sample one data (Data_1) from t-distribution with Parameter_1.
  3. Get the Parameter_2, by including the Data_1
  4. Sample one data (Data_3) from t-distribution with Parameter_2.
  5. trajectories.append([Data_1, Data_2, Data_3])

Additionally, it would be great if you could give me a hint on where I can find the detail code for autoregressive prediction, thanks!

from lag-llama.

sudongwanglijuan avatar sudongwanglijuan commented on May 20, 2024

for t in range(self.prediction_length):
if self.time_feat:
params, loc, scale = self.model(
*args,
past_time_feat=repeated_past_time_feat,
future_time_feat=repeated_future_time_feat[..., : t + 1, :],
past_target=repeated_past_target,
past_observed_values=repeated_past_observed_values,
use_kv_cache=self.use_kv_cache,
)
else:
params, loc, scale = self.model(
*args,
past_time_feat=None, # repeated_past_time_feat,
future_time_feat=None, # repeated_future_time_feat[..., : t + 1, :],
past_target=repeated_past_target,
past_observed_values=repeated_past_observed_values,
use_kv_cache=self.use_kv_cache,
)
sliced_params = [
p[:, -1:] for p in params
] # Take the last timestep predicted. Each tensor is of shape (#bsz*#parallel_samples, 1)
distr = self.model.distr_output.distribution(sliced_params, loc, scale)
sample = distr.sample() # (#bsz*#parallel_samples, 1)
if self.nonnegative_pred_samples:
sample = F.relu(sample)
future_samples.append(sample)
repeated_past_target = torch.cat((repeated_past_target, sample), dim=1)
repeated_past_observed_values = torch.cat(
(repeated_past_observed_values, torch.ones_like(sample)), dim=1
)

from lag-llama.

ashok-arjun avatar ashok-arjun commented on May 20, 2024

Hello, it's Arthur, Thank you for your great work. I would like to ask whether it is possible to get the specific lag indices you use during the pre-training or zero-shot phases.

In the Colab tutorial notebook, it is indicated that the context length is set to 32, and the maximum potential lag index could be 1092. However, the exact indices used to tokenize the 32 historical time points remain unclear to me. Do you employ all of the 1092 lags, or is there a specific subset that is used?

Thank you!

Hi @SpeeeedLee .

The 32 historical time series points are consecutive, and sampled before the timestep to be predicted.

The lags however are sampled possibly even beyond this 32-length context, but sparsely as denoted by the lag indices.
The figure below might be useful to clarify the difference.
Screenshot 2024-04-05 at 1 33 54 PM

As for the indices of the lags, in our experiments, we sample lags of certain frequencies, upto a certain length.

The frequencies are denoted here:

lags_seq: list = ["Q", "M", "W", "D", "H", "T", "S"],

The corresponding code to sample lags is here. We use the get_lags_for_frequency function of GluonTS in our code:

for freq in lags_seq:
lag_indices.extend(
get_lags_for_frequency(freq_str=freq, num_default_lags=1)
)

To give an example, the lags of the "D" frequency (daily) frequency look like this:

[0, 7, 12, 13, 14, 19, 20, 21, 26, 27, 28, 29, 30, 55, 83, 362, 363, 364, 726, 727, 728, 1090, 1091, 1092]

As for the actual lag indices that come from all these frequencies:

[0, 7, 8, 10, 11, 12, 13, 14, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, 34, 35, 36, 46, 47, 48, 50, 51, 52, 55, 57, 58, 59, 60, 61, 70, 71, 72, 83, 94, 95, 96, 102, 103, 104, 117, 118, 119, 120, 121, 142, 143, 144, 154, 155, 156, 166, 167, 168, 177, 178, 179, 180, 181, 334, 335, 336, 362, 363, 364, 502, 503, 504, 670, 671, 672, 718, 719, 720, 726, 727, 728, 1090, 1091, 1092]

For the code GluonTS uses to generate these lag indices, you can refer to the source code of the get_lags_for_frequency function.

from lag-llama.

ashok-arjun avatar ashok-arjun commented on May 20, 2024

Feel free to follow up if you have clarifications or close the issue if it answers your questions. Thanks!

from lag-llama.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.