Skip to content
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

ValueError: invalid frequency | freq_str=Q -> offset_name=QE #110

Open
Manukrish2504 opened this issue Oct 25, 2024 · 5 comments
Open

ValueError: invalid frequency | freq_str=Q -> offset_name=QE #110

Manukrish2504 opened this issue Oct 25, 2024 · 5 comments

Comments

@Manukrish2504
Copy link

When I run "forecasts, tss = get_lag_llama_predictions(backtest_dataset, prediction_length, device, num_samples)" with my own data...I'm having an invalid frequency error. Kindly help....

Error:
:2: FutureWarning: You are using torch.load with weights_only=False (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for weights_only will be flipped to True. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via torch.serialization.add_safe_globals. We recommend you start setting weights_only=True for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.
ckpt = torch.load("lag-llama.ckpt", map_location=device) # Uses GPU since in this Colab we use a GPU.

ValueError Traceback (most recent call last)
in <cell line: 1>()
----> 1 forecasts, tss = get_lag_llama_predictions(backtest_dataset, prediction_length, device, num_samples)

3 frames
/usr/local/lib/python3.10/dist-packages/gluonts/time_feature/lag.py in get_lags_for_frequency(freq_str, lag_ub, num_lags, num_default_lags)
147 )
148 else:
--> 149 raise ValueError(f"invalid frequency | freq_str={freq_str} -> offset_name={offset_name}")
150
151 # flatten lags list and filter

ValueError: invalid frequency | freq_str=Q -> offset_name=QE

@ashok-arjun
Copy link
Contributor

What frequency are you using?

@afshinebtia
Copy link

Hi @ashok-arjun,

Thanks for your excellent work.
When running the code locally, I get the following result even for the default dataset. Would you please help me with this?

Exception                                 Traceback (most recent call last)
Cell In[14], line 1
----> 1 forecasts, tss = get_lag_llama_predictions(backtest_dataset, prediction_length, device, num_samples)

Cell In[11], line 10, in get_lag_llama_predictions(dataset, prediction_length, device, context_length, use_rope_scaling, num_samples)
      3 estimator_args = ckpt["hyper_parameters"]["model_kwargs"]
      5 rope_scaling_arguments = {
      6     "type": "linear",
      7     "factor": max(1.0, (context_length + prediction_length) / estimator_args["context_length"]),
      8 }
---> 10 estimator = LagLlamaEstimator(
     11     ckpt_path="./model_weigth/lag-llama.ckpt",
     12     prediction_length=prediction_length,
     13     context_length=context_length, # Lag-Llama was trained with a context length of 32, but can work with any context length
     14 
     15     # estimator args
     16     input_size=estimator_args["input_size"],
     17     n_layer=estimator_args["n_layer"],
     18     n_embd_per_head=estimator_args["n_embd_per_head"],
     19     n_head=estimator_args["n_head"],
     20     scaling=estimator_args["scaling"],
     21     time_feat=estimator_args["time_feat"],
     22     rope_scaling=rope_scaling_arguments if use_rope_scaling else None,
     23 
     24     batch_size=1,
     25     num_parallel_samples=100,
     26     device=device,
     27 )
     29 lightning_module = estimator.create_lightning_module()
     30 transformation = estimator.create_transformation()

File ~/miniforge3/envs/llm/lib/python3.12/site-packages/gluonts/core/component.py:364, in validated.<locals>.validator.<locals>.init_wrapper(*args, **kwargs)
    361     self.__class__.__getnewargs_ex__ = validated_getnewargs_ex
    362     self.__class__.__repr__ = validated_repr
--> 364 return init(self, **all_args)

File ~/mycode/llm/TimeSeries/LagLlama/lag-llama/lag_llama/gluon/estimator.py:179, in LagLlamaEstimator.__init__(self, prediction_length, context_length, input_size, n_layer, n_embd_per_head, n_head, max_context_length, rope_scaling, scaling, lr, weight_decay, aug_prob, freq_mask_rate, freq_mixing_rate, jitter_prob, jitter_sigma, scaling_prob, scaling_sigma, rotation_prob, permutation_prob, permutation_max_segments, permutation_seg_mode, magnitude_warp_prob, magnitude_warp_sigma, magnitude_warp_knot, time_warp_prob, time_warp_sigma, time_warp_knot, window_slice_prob, window_slice_reduce_ratio, window_warp_prob, window_warp_window_ratio, window_warp_scales, distr_output, loss, num_parallel_samples, batch_size, num_batches_per_epoch, trainer_kwargs, train_sampler, validation_sampler, time_feat, dropout, lags_seq, data_id_to_name_map, use_cosine_annealing_lr, cosine_annealing_lr_args, track_loss_per_series, ckpt_path, nonnegative_pred_samples, use_single_pass_sampling, device)
    176 lag_indices = []
    177 for freq in lags_seq:
    178     lag_indices.extend(
--> 179         get_lags_for_frequency(freq_str=freq, num_default_lags=1)
    180     )
    182 if len(lag_indices):
    183     self.lags_seq = sorted(set(lag_indices))

File ~/miniforge3/envs/llm/lib/python3.12/site-packages/gluonts/time_feature/lag.py:149, in get_lags_for_frequency(freq_str, lag_ub, num_lags, num_default_lags)
    143     lags = (
    144         _make_lags_for_second(offset.n)
    145         + _make_lags_for_minute(offset.n / 60)
    146         + _make_lags_for_hour(offset.n / (60 * 60))
    147     )
    148 else:
--> 149     raise Exception("invalid frequency")
    151 # flatten lags list and filter
    152 lags = [
    153     int(lag) for sub_list in lags for lag in sub_list if 7 < lag <= lag_ub
    154 ]

Exception: invalid frequency

@SandroKraft
Copy link

SandroKraft commented Nov 8, 2024

I recieve the same error "ValueError: invalid frequency | freq_str=Q -> offset_name=QE" running "forecasts, tss = get_lag_llama_predictions(backtest_dataset, prediction_length, device, num_samples)" with my own data.

The frequence of my data is freq='D'

Any Solutions on this topic so far?

@kashif
Copy link
Contributor

kashif commented Nov 13, 2024

so i have updated the API to use the latest gluonts if you want to try it out... I am in the process of updating the colab notebooks

@yigedabuliu
Copy link

我使用以下命令重新安装gluonts库后代码恢复正常。
pip install gluonts[torch]==0.14.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants