Coder Social home page Coder Social logo

y-debug-sys / diffusion-ts Goto Github PK

View Code? Open in Web Editor NEW
142.0 2.0 21.0 3.24 MB

[ICLR 2024] Official Implementation of "Diffusion-TS: Interpretable Diffusion for General Time Series Generation"

License: MIT License

Python 4.92% Jupyter Notebook 95.08%
diffusion-model pytorch time-series time-series-forecasting time-series-imputation

diffusion-ts's Introduction

Diffusion-TS: Interpretable Diffusion for General Time Series Generation

Abstract: Denoising diffusion probabilistic models (DDPMs) are becoming the leading paradigm for generative models. It has recently shown breakthroughs in audio synthesis, time series imputation and forecasting. In this paper, we propose Diffusion-TS, a novel diffusion-based framework that generates multivariate time series samples of high quality by using an encoder-decoder transformer with disentangled temporal representations, in which the decomposition technique guides Diffusion-TS to capture the semantic meaning of time series while transformers mine detailed sequential information from the noisy model input. Different from existing diffusion-based approaches, we train the model to directly reconstruct the sample instead of the noise in each diffusion step, combining a Fourier-based loss term. Diffusion-TS is expected to generate time series satisfying both interpretablity and realness. In addition, it is shown that the proposed Diffusion-TS can be easily extended to conditional generation tasks, such as forecasting and imputation, without any model changes. This also motivates us to further explore the performance of Diffusion-TS under irregular settings. Finally, through qualitative and quantitative experiments, results show that Diffusion-TS achieves the state-of-the-art results on various realistic analyses of time series.

Diffusion-TS is a diffusion-based framework that generates general time series samples both conditionally and unconditionally. As shown in Figure 1, the framework contains two parts: a sequence encoder and an interpretable decoder which decomposes the time series into seasonal part and trend part. The trend part contains the polynomial regressor and extracted mean of each block output. For seasonal part, we reuse trigonometric representations based on Fourier series. Regarding training, sampling and more details, please refer to our paper in ICLR 2024.


Figure 1: Overall Architecture of Diffusion-TS.

Dataset Preparation

All the four real-world datasets (Stocks, ETTh1, Energy and fMRI) can be obtained from Google Drive. Please download dataset.zip, then unzip and copy it to the folder ./Data in our repository.

Running the Code

The code requires conda3 (or miniconda3), and one CUDA capable GPU. The instructions below guide you regarding running the codes in this repository.

Environment & Libraries

The full libraries list is provided as a requirements.txt in this repo. Please create a virtual environment with conda or venv and run

(myenv) $ pip install -r requirements.txt

Training & Sampling

For training, you can reproduce the experimental results of all benchmarks by runing

(myenv) $ python main.py --name {name} --config_file {config.yaml} --gpu 0 --train

Note: We also provided the corresponding .yml files (only stocks, sines, mujoco, etth, energy and fmri) under the folder ./Config where all possible option can be altered. You may need to change some parameters in the model for different scenarios. For example, we use the whole data to train model for unconditional evaluation, then training_ratio is set to 1 by default. As for conditional generation, we need to divide data set thus it should be changed to a value < 1.

While training, the script will save check points to the results folder after a fixed number of epochs. Once trained, please use the saved model for sampling by running

Unconstrained

(myenv) $ python main.py --name {name} --config_file {config.yaml} --gpu 0 --sample 0 --milestone {checkpoint_number}

Imputation

(myenv) $ python main.py --name {name} --config_file {config.yaml} --gpu 0 --sample 1 --milestone {checkpoint_number} --mode infill --missing_ratio {missing_ratio}

Forecasting

(myenv) $ python main.py --name {dataset_name} --config_file {config.yaml} --gpu 0 --sample 1 --milestone {checkpoint_number} --mode predict --pred_len {pred_len}

Visualization and Evaluation

After sampling, synthetic data and orginal data are stored in .npy file format under the output folder, which can be directly read to calculate quantitative metrics such as discriminative, predictive, correlational and context-FID score. You can also reproduce the visualization results using t-SNE or kernel plotting, and all of these evaluational codes can be found in the folder ./Utils. Please refer to .ipynb tutorial files in this repo for more detailed implementations.

Note: All the metrics can be found in the ./Experiments folder. Additionally, by default, for datasets other than the Sine dataset (because it do not need normalization), their normalized forms are saved in {...}_norm_truth.npy. Therefore, when you run the Jupternotebook for dataset other than Sine, just uncomment and rewrite the corresponding code written at the beginning.

Main Results

Standard TS Generation

Table 1: Results of 24-length Time-series Generation.

Long-term TS Generation

Table 2: Results of Long-term Time-series Generation.

Conditional TS Generation


Figure 2: Visualizations of Time-series Imputation and Forecasting.

Authors

  • Paper Authors : Xinyu Yuan, Yan Qiao

  • Code Author : Xinyu Yuan

  • Contact : [email protected]

Citation

If you find this repo useful, please cite our paper via

@inproceedings{yuan2024diffusionts,
  title={Diffusion-{TS}: Interpretable Diffusion for General Time Series Generation},
  author={Xinyu Yuan and Yan Qiao},
  booktitle={The Twelfth International Conference on Learning Representations},
  year={2024},
  url={https://openreview.net/forum?id=4h1apFjO99}
}

Acknowledgement

We appreciate the following github repos a lot for their valuable code base:

https://github.com/lucidrains/denoising-diffusion-pytorch

https://github.com/cientgu/VQ-Diffusion

https://github.com/XiangLi1999/Diffusion-LM

https://github.com/philipperemy/n-beats

https://github.com/salesforce/ETSformer

https://github.com/ermongroup/CSDI

https://github.com/jsyoon0823/TimeGAN

diffusion-ts's People

Contributors

dependabot[bot] avatar y-debug-sys avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

diffusion-ts's Issues

关于预测数据

您好,
我最近尝试用训练好的模型进行预测分析
python main.py --name etth --config_file ETTh.yaml --gpu 0 --sample 1 --milestone 10 --mode predict --pred_len 96
他生成了一个矩阵(1732,96,7),但是我不知道该和哪个数据进行对比

关于生成的数据

问题如下:

  • 我传入的数据为(n,16)
  • 当前输出为(2001,24,16),应该如何调整生成为(n,16)形状的形式

Option to Disable Shuffling in Training and Sampling for Diffusion-TS

Hi,

I have two questions regarding the handling of training data in the Diffusion-TS framework:

  1. Disable Shuffling During Building Dataloader:

    • I want mydata.csv to be processed without shuffling during the build_dataloader call.
    • The command I use for training is:
      python main.py --name mydata --config_file Config/mydata.yaml --gpu 1 --train
    • The training data is stored as Diffusion-TS/OUTPUT/mydata/samples/mydata_ground_truth_24_train.npy.
    • Is there any way to ensure that the above .npy file is not shuffled during the build_dataloader process?
  2. Disable Shuffling During Sampling:

    • When I run the sampling command:
      python main.py --name mydata --config_file Config/mydata.yaml --gpu 0 --sample 0 --milestone 10
    • I want to confirm if the sampling uses the training data (mydata_ground_truth_24_train.npy) to generate new data.
    • Additionally, I need to generate the data without shuffling as I intend to restore it to the reverse sliding window segment.
    • Is there any way to achieve this?

Thank you!

在代码调试中遇到问题

image
作者您好,我今天在调试代码中遇到这个问题,由于我是深度学习的初学者,请问这个报错是什么意思?该如何修改?

Tutorial0 Unnormalize and Question on FFT term in loss funciton

  1. The commented code seems to work for datasets other than sine.
    ori_data = np.load(os.path.join(dataset.dir, f"{dataset_name}norm_truth{seq_length}_train.npy"))

Maybe there is something with unnormalize_to_zero_to_one?

  1. Want to confirm the FFT loss term is utilized for each feature (time series) not each time step.

生成ddpm_fake.npy与train_ground.npy相差过大

作者,您好。我对您的代码做了少许改动,无条件生成后进行可视化发现生成ddpm_fake.npy与train_ground.npy相差过大(已经进行了反归一化)
我的train_ground.npy结构为(34826,129,2)ddpm_fake.npy结构为(200000,129,2)
Uploading 归一化1.png…
Uploading 归一化图片.png…

About training detais of Context-FID score and other measures

Hi, thank you for your kind words and for noting the ease of reproducing your code.

When I ran all the configuration files in your code, I encountered serious problems without altering any part of it.

After training and sampling energy data,

image

the results of the measures have significantly different scales in your code.

image

(1) From my perspective, this misalignment could have occurred due to the training code in TS2Vec, possibly requiring adjustments to the learning rate or batch size. (maybe the code is fitted to Sine data.)

Did you use a different training approach, such as lr or batch size, for TS2Vec in the following code?

image

or should I apply some scaling techniques before calculating the evaluation scores?

(2) In the discriminative score and predictive score, did you also change the hyperparameters, such as the learning rate or batch size to train discriminator or predictor?

Please kindly correct me if I have any misunderstanding of your code. Thanks.

RuntimeError: GET was unable to find an engine to execute this computation

图片1
作者您好,当我想算context_fid的时候,遇到了这个问题,看起来好像是conv1d的问题

RuntimeError Traceback (most recent call last)
Cell In[24], line 4
1 context_fid_score = []
3 for i in range(iterations):
----> 4 context_fid = Context_FID(ori_data[:], fake_data[:ori_data.shape[0]])
5 context_fid_score.append(context_fid)
6 print(f'Iter {i}: ', 'context-fid =', context_fid, '\n')

File ~/Diffusion-TS/Experiments/../Utils/context_fid.py:25, in Context_FID(ori_data, generated_data)
22 def Context_FID(ori_data, generated_data):
23 model = TS2Vec(input_dims=ori_data.shape[-1], device=0, batch_size=8, lr=0.001, output_dims=320,
24 max_train_length=3000)
---> 25 model.fit(ori_data, verbose=False)
26 ori_represenation = model.encode(ori_data, encoding_window='full_series')
27 gen_represenation = model.encode(generated_data, encoding_window='full_series')

File ~/Diffusion-TS/Experiments/../Models/ts2vec/ts2vec.py:124, in TS2Vec.fit(self, train_data, n_epochs, n_iters, verbose)
120 crop_offset = np.random.randint(low=-crop_eleft, high=ts_l - crop_eright + 1, size=x.size(0))
122 optimizer.zero_grad()
--> 124 out1 = self._net(take_per_row(x, crop_offset + crop_eleft, crop_right - crop_eleft))
125 out1 = out1[:, -crop_l:]
127 out2 = self._net(take_per_row(x, crop_offset + crop_left, crop_eright - crop_left))

File ~/local/anaconda3/envs/Diffusion_ts/lib/python3.8/site-packages/torch/nn/modules/module.py:1501, in Module._call_impl(self, *args, **kwargs)
1496 # If we don't have any hooks, we want to skip the rest of the logic in
1497 # this function, and just call forward.
1498 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
1499 or _global_backward_pre_hooks or _global_backward_hooks
1500 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1501 return forward_call(*args, **kwargs)
1502 # Do not call functions when jit is used
1503 full_backward_hooks, non_full_backward_hooks = [], []

File ~/Diffusion-TS/Experiments/../Models/ts2vec/models/encoder.py:70, in TSEncoder.forward(self, x, mask)
68 # conv encoder
69 x = x.transpose(1, 2) # B x Ch x T
---> 70 x = self.repr_dropout(self.feature_extractor(x)) # B x Co x T
71 x = x.transpose(1, 2) # B x T x Co
73 return x

File ~/local/anaconda3/envs/Diffusion_ts/lib/python3.8/site-packages/torch/nn/modules/module.py:1501, in Module._call_impl(self, *args, **kwargs)
1496 # If we don't have any hooks, we want to skip the rest of the logic in
1497 # this function, and just call forward.
1498 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
1499 or _global_backward_pre_hooks or _global_backward_hooks
1500 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1501 return forward_call(*args, **kwargs)
1502 # Do not call functions when jit is used
1503 full_backward_hooks, non_full_backward_hooks = [], []

File ~/Diffusion-TS/Experiments/../Models/ts2vec/models/dilated_conv.py:55, in DilatedConvEncoder.forward(self, x)
54 def forward(self, x):
---> 55 return self.net(x)

File ~/local/anaconda3/envs/Diffusion_ts/lib/python3.8/site-packages/torch/nn/modules/module.py:1501, in Module._call_impl(self, *args, **kwargs)
1496 # If we don't have any hooks, we want to skip the rest of the logic in
1497 # this function, and just call forward.
1498 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
1499 or _global_backward_pre_hooks or _global_backward_hooks
1500 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1501 return forward_call(*args, **kwargs)
1502 # Do not call functions when jit is used
1503 full_backward_hooks, non_full_backward_hooks = [], []

File ~/local/anaconda3/envs/Diffusion_ts/lib/python3.8/site-packages/torch/nn/modules/container.py:217, in Sequential.forward(self, input)
215 def forward(self, input):
216 for module in self:
--> 217 input = module(input)
218 return input

File ~/local/anaconda3/envs/Diffusion_ts/lib/python3.8/site-packages/torch/nn/modules/module.py:1501, in Module._call_impl(self, *args, **kwargs)
1496 # If we don't have any hooks, we want to skip the rest of the logic in
1497 # this function, and just call forward.
1498 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
1499 or _global_backward_pre_hooks or _global_backward_hooks
1500 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1501 return forward_call(*args, **kwargs)
1502 # Do not call functions when jit is used
1503 full_backward_hooks, non_full_backward_hooks = [], []

File ~/Diffusion-TS/Experiments/../Models/ts2vec/models/dilated_conv.py:35, in ConvBlock.forward(self, x)
33 residual = x if self.projector is None else self.projector(x)
34 x = F.gelu(x)
---> 35 x = self.conv1(x)
36 x = F.gelu(x)
37 x = self.conv2(x)

File ~/local/anaconda3/envs/Diffusion_ts/lib/python3.8/site-packages/torch/nn/modules/module.py:1501, in Module._call_impl(self, *args, **kwargs)
1496 # If we don't have any hooks, we want to skip the rest of the logic in
1497 # this function, and just call forward.
1498 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
1499 or _global_backward_pre_hooks or _global_backward_hooks
1500 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1501 return forward_call(*args, **kwargs)
1502 # Do not call functions when jit is used
1503 full_backward_hooks, non_full_backward_hooks = [], []

File ~/Diffusion-TS/Experiments/../Models/ts2vec/models/dilated_conv.py:20, in SamePadConv.forward(self, x)
19 def forward(self, x):
---> 20 out = self.conv(x)
21 if self.remove > 0:
22 out = out[:, :, : -self.remove]

File ~/local/anaconda3/envs/Diffusion_ts/lib/python3.8/site-packages/torch/nn/modules/module.py:1501, in Module._call_impl(self, *args, **kwargs)
1496 # If we don't have any hooks, we want to skip the rest of the logic in
1497 # this function, and just call forward.
1498 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
1499 or _global_backward_pre_hooks or _global_backward_hooks
1500 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1501 return forward_call(*args, **kwargs)
1502 # Do not call functions when jit is used
1503 full_backward_hooks, non_full_backward_hooks = [], []

File ~/local/anaconda3/envs/Diffusion_ts/lib/python3.8/site-packages/torch/nn/modules/conv.py:313, in Conv1d.forward(self, input)
312 def forward(self, input: Tensor) -> Tensor:
--> 313 return self._conv_forward(input, self.weight, self.bias)

File ~/local/anaconda3/envs/Diffusion_ts/lib/python3.8/site-packages/torch/nn/modules/conv.py:309, in Conv1d._conv_forward(self, input, weight, bias)
305 if self.padding_mode != 'zeros':
306 return F.conv1d(F.pad(input, self._reversed_padding_repeated_twice, mode=self.padding_mode),
307 weight, bias, self.stride,
308 _single(0), self.dilation, self.groups)
--> 309 return F.conv1d(input, weight, bias, self.stride,
310 self.padding, self.dilation, self.groups)

RuntimeError: GET was unable to find an engine to execute this computation

执行序列预测任务的输出保存在何方?

作者您好,向您请教:
为了对股票数据集进行20个长度的预测时,执行如下的命令行代码:
python main.py --name StockPredict20 --config_file ./Config/stocks.yaml --gpu 0 --sample 1 --milestone 10 --mode predict --pred_len 20
输出如下图:
1

ddpm_predict_StockPredict20.npy的'shape': (366, 24, 6), } 为什么是366而不是20呢?20个长度的预测输出到哪里去了呢?
当我进行10个长度的预测时,执行如下的代码:
python main.py --name StockPredict --config_file ./Config/stocks.yaml --gpu 0 --sample 1 --milestone 10 --mode predict
ddpm_predict_StockPredict.npy的形状也未改变。请您赐教!

指标问题咨询

您好,我在用用模型生成光伏曲线的时候,用指标测试生成的效果。context-fid非常大,超过100,然后cross correlative非常小,大概是e-8次方级别。您觉得这个可能是什么问题呢?

Diffusion model not capturing cyclical nature

Hi there, thanks for your work on this,

I am just using the model to generate some synthetic PPG signal data for a project (will be sure to cite), and it seems to perform quite good, although it isn't capturing the cyclical nature of the signals enough (e.g. too much variation between cycles) which is really important in this type of data.

Just wondering as you have used and tuned the model a lot, whether you know of any tricks to guide the model towards a more cyclical and uniform output? An example of my current output is shown below (original in blue, synthetic in yellow).

graph

Thanks again

reproducing the results of Figure 6

Hello. Great research work.
I have some questions about reproducing the results of Figure 6.

  1. Do I only need to train the model once to obtain all the results in Figure 6 through inference, or do I need to train different models according to different situations?
  2. In the prediction task in Figure 6, do you always keep the history window + prediction window = 48?
  3. In code, how do I switch between Diffusion-TS-G and Diffusion-TS-R?
    Thanks.

怎么查看评估指标的结果

您好,我按照你的readme文件的要求,完成了运行和采样,也生成了output文件,但是我不知道应该怎么查看Context_FID等四项评价的数值,我运行后在终端没有出现结果,应该去哪里查看呢? 请您指点,不胜感激

Long-term TS Generation

Your paper mentions: "We randomly generate 3000 sequences with various lengths (64, 128, 256), then use the aforementioned metrics to assess the generation quality of different methods."

This means that when calculating Discriminative Score and Predictive Score, the amount of synthetic data is 3000. How much real data do you take? Is it 3000 or all?

Thank you for clarifying the confusion!

About baselines

Hi, the implementation of DiffTime is not open source (or maybe I just couldn't find it). I would like to ask you how to reproduce its results.
Thanks.

Generated data distribution seems very different from the original one

Hi, for my research project, I am trying to use your model to adapt it develop a diffusion model for NILM problem.
Specifically, through the "Tutorial_0.ipynb" notebook, I trained the model and performed the unconditional data generation and later visualized the pca/t-sne/kernel plots.
I wanted to ask your opinion regarding the result obtained, which does not seem to be generating correctly.
The dataset shape is (60000, 128, 1) and below you can see the model configuration.



I cannot understand the reason why the generated samples seem to have a very different distribution from the original. Would you have any suggestions on how to improve the generation?

Question about results in Table 1

Hi. I'm seungyun Lee.

I have a question about the results in Table 1.

Now, I'm in the process of replicating your experiment, but the results seem different. Is it possible that it's due to some hyperparameter issue, or is it simply an error in the experimental setup?

This is my result for unconditional generation using mujoco data.

image

Not just for mujoco, unconditional generation for other datasets and imputation also have little bit different results.

I'll waiting your reply. Thank you.

多支股票数据怎么处理

作者你好,我看论文里的股票数据只用了单只股票的数据。我想用多个股票数据作为训练数据,但是我看自定义的dataset里好像不支持多个股票数据作为输入。比如我有两支股票,不能把A直接拼接到B股票的后面,把他们合并成一个数据集。
并且我想问一下,你的训练硬件配置以及训练耗时。如方便告知,万分感谢。

Size mismatch of model and checkpoint

Hi,
I have trained the model with the given terminal command, which saves the pre-trained model checkpoints in the respective folder. When I try to run the saved model for sampling, it gives me the following error:

size mismatch for model.emb.sequential.1.weight: copying a param with shape torch.Size([96, 128, 3]) from checkpoint, the shape in current model is torch.Size([64, 6, 3]).

Any information on how to resolve this, or if I may be doing something wrong, would be helpful.

时间序列预测

亲爱的作者您好!我想问一个比较简单的问题,就是我现在希望用一个(1000,165)的一整条时间序列去训练模型,并且尝试生成一个长度为n的形状为(n,165)的时间序列,请问我是不是需要在yaml文件中的test_dataset指定一个空的csv文件?然后在运行时使用mode为predict对吧?在yaml配置文件中还有什么要改的嘛?谢谢作者!!

一些关于代码的问题

作者您好!非常欣赏您的工作!我有一个问题。
训练时候没有看到验证集,那直接设置如18000步训练epoch会不会难以监测到过拟合的问题呢?
image

如上图我使用了etth数据以及原始的config,它在10000步甚至之前train loss看上去已经收敛了,但是因为没有validation loss,所以难以判断有没有过拟合和之后继续训练会不会过拟合。想提问作者在使用时是如何保证没有过拟合的呢

Figure 4和Figure 15可视化的问题请教

作者你好,
非常感谢你提供论文代码,为时序领域发展做出的贡献!
在Figure 4和Figure 15中,你使用TimeGAN作为基线进行可视化:
图4
图15
TimeGAN在数据预处理时会对原始数据进行切片,并把切片随机打乱,变成三维数据ori_data(以默认stock数据集为例,会变成(3661,24,6)),生成的generated_data也是三维数据,
image
image
我想请教一下,你在使用TimeGAN时是如何处理得到的generated_data,从而进行Figure 4和Figure 15的可视化?
是否将generated_data还原回原始数据的格式(以默认stock数据集为例,得到对应生成的二维数据(3685,6))?
或者是在generated_data中取出一个切片,和原始数据对应的切片进行对比?

How to choose a trained model

Hello, there is no validation set when doing unconditional generation, so I am confused about how to select the model from training as the final model.
Will the final report results be uniformly based on the results when milestone=10? Or you evaluate the models under different milestones and choose the best one.

Question about MSE in Figure 6

Hi, I have a question about measuring MSE in Figure 6. I have adjusted the code for measuring MSE as shown below.
image

However, I obtained different results.
The first result uses data rescaled to the original scale, while the other is a scaled version ranging from 0 to 1.

image

  1. I am wondering if the results in Figure 6 are actually RMSE of the data scaled from 0 to 1. I obtained a result of 0.02698616289235689, which closely matches the results in Figure 6. However, for the Energy dataset, I obtained 0.06649003748409096. Could you clarify if any hyperparameters were changed in the energy setting?

  2. If the figure indeed shows RMSE, why didn't you use the inverse_transform method as mentioned in the MuJoCo.ipynb file?

Please correct me if I have misunderstood anything!

关于条件生成时间序列,数据格式的问题

感谢作者对模型的开源,我有一个问题,当前我的数据集是(样本数,时间长度),同时数据有0,1两种标签,那我的csv数据格式应该是什么样,才能符号模型的输入才能使用标签去引导数据的生成

生成较长时间序列

🥹🥹作者您好,我现在又有一个问题,就是假设我想要先用已有数据训练处一个模型,然后生成一个(只需要一个)很长的时间序列(比如100w长度),那我是不是要在训练时把window也设置为100w,这样您的模型就会因为数据量过大而无法训练?
如果可以的话,是否可以在训练时把window设置为合理的较小的数值比如window=200,然后在无条件生成的时候可以生成较长的时间序列?

norm

In your code, the "neg_one_to_one" attribute of all datasets is True. Does it mean that they are normalized to [-1, 1] during training? When calculating indicators such as Discriminative score, it is restored to [0, 1]. Is my understanding correct?

If it is correct, why do you need to do this? Will using [0, 1] during training have a big impact?
Thank you for your answer!

输出的总是测试集

  1. 作者您好!首先感谢您为学术界做出的贡献!其次我在测试模型的时候遇到如下问题

--name test --config_file ./Config/stocks.yaml --gpu 0 --sample 1 --milestone 10 --mode infill --missing_ratio 0.1

  1. 此处stocks数据集维度为 [3686,6],正如您在下图的redme中所言,Testing Dataset的维度为 [(3686-window+1)×proportion,window,6],Diffusion-TS在执行上述的插补任务时,接受的输入是测试集而非原stocks数据集,模型的输出是测试集维度。
    image

  2. 能否使Diffusion-TS在执行上述插补任务时,接受原stocks数据集 [3686,6] 作为输入, 输出 [3686×(1+missing_ratio),6] 的数据。在执行预测任务时则输出 [3686+pred_len,6]

  3. 最后我非常感谢您开发和维护这个项目,它对我的学习产生了积极影响。我期待着您的回复。谢谢!

Nan in training loss

Hi, I really appreciate your great contribution to time series generation. I tried your unconditional generation tutorial with changing to my own dataset. But, I sometimes face "nan" in training loss. I checked my dataset and the way of transformation does not cause nan, and nan occurrance looks occational. Do you have any idea why nan occurs in training loss.

Regarding the generation of datasets with varying time spans

Hi! First of all, thank you for your excellent work and the great implementation! Thanks to your reproducible and well-structured codebase, I was able to apply your model to various custom datasets.

I have a question about generating time sequences with Diffusion-TS. From my understanding, Diffusion-TS assumes that the dataset is evenly timestamped.

However, in some datasets, time spans can vary, and my question is about generating data that includes timestamps with Diffusion-TS in such cases. An easy and intuitive way to handle this would be to create a specific column indicating unevenly stamped time values. However, in this case, Diffusion-TS doesn't ensure that the time column will be monotonically increasing, even though it does capture the general tendency of increasing.

So, how can I ensure that a column is monotonically increasing? As the primary author who understands your work best, do you have any better ideas for handling this kind of dataset?

Here is an example of the dataset I mentioned:

time feature1 feature2 ...
0 xx yy ...
3 xx yy ...
4 xx yy ...
4 xx yy ...
7 xx yy ...
8 xx yy ...
8 xx yy ...
9 xx yy ...
...

How build_dataloader create {self.name}_ground_truth_{self.window}_test.npy

Hi,

I am currently working with the preprocessing pipeline in the project, and I need some clarification regarding the steps involved in generating the {self.name}ground_truth{self.window}_test.npy file from the original CSV file. Specifically, I am looking into the real_datasets.py file in the Utils directory but am unsure about the exact preprocessing steps that are applied to the original CSV file from Dataset.

Request:
Could you please provide detailed documentation or comments in the code explaining the preprocessing steps? It would greatly help in understanding the data transformation process and ensure that I can correctly interpret the generated files.

Thank you for your assistance.

生成后效果与初始数据很不相关,关于参数设置的改正

@3%%X{%SEENZ{OB4SZO Y{8
_ P0Z3I1EX3AY2A QZ(7U
DW%3NW1EBN (9G3HXQ4_26S
图中可以发现,在使用模型生成后,效果很差。我认为可能是参数设置错误的原因。阐述一下流程:输入数据(样本数,时间间长度),但是在训练配置中我的feature_size必须要与时间长度相等才可以进行训练,通过观察fmri数据集维度为(10000,5)个人觉得输入数据是否应该改为(时间长度,样本数)?

生成数据与原数据差别比较大

我按照您的步骤执行代码,并且根据Tutorial_0.ipynb中的代码进行作图,发现图像上显示的fake数据与原数据相差过大,想请问会不会是我因为去除了模型中一开始的归一化和后来的去归一化导致的?或者有没有可能是因为yaml上的参数设置问题?
截屏2024-07-27 16 12 18

Cross-Correlation or Cross-Covariance?

Hi, Thanks for updating the codebase frequently.

I am currently working on understanding the correlation score code. The formula in the paper looks like the Pearson correlation.
image

I also tried the correlation score in the code.
image

As you can see the first values, it gives 1.17 for feature 1 and feature 1. Should it be 1 instead? Please let me know If I miss something here.

Thank you so much for your time.

Cross correlation Loss

Hello,

For the cross correlation loss, I was wondering why there was an extra factor of 10 in this function:

def compute(self, x_fake):
cross_correl_fake = cacf_torch(self.transform(x_fake), 1).mean(0)[0]
loss = self.norm_foo(cross_correl_fake - self.cross_correl_real.to(x_fake.device))
return loss / 10.

Is this 10 hard coded? Should it be the number of features?

Thank you!

main.py issues

Hello author, I have this problem“FileNotFoundError: [Errno 2] No such file or directory: 'Checkpoints_energy_24\checkpoint-10.pt” when I run your main program, but I am sure that your data does not provide such a file. How can I get it?

metric_tensorflow.ipynb无法运行

您好,我在运行实验的metric_tensorflow.ipynb文件时,提示我当前版本的numpy,需要把numpy.object更换为object,我重新安装了tensorflow,但还是报错,请问要运行这个文件,是需要在require.txt文件的要求之外单独配置环境吗?

Diffusion Model parameter size

Hi guys, I am just using this for a project (will be sure to cite). When using the parameter config for the FMRI dataset, I am getting a parameter size of over 13M, but I think in the paper it was around 1.3M. Just wondering if this is an issue that you have encountered, or if it is something that is related to my setup. Thanks,

对Impution任务进行test时,略微修改denoiser模型,但test结果不变

作者您好,我先使用如下参数进行模型训练:main.py --train True --sample 1 --mode 'infill' --milestone 10.
然后使用如下参数进行测试:main.py --train False --sample 1 --mode 'infill' --milestone 10.
然后打印ddpm_infill_None.npy结果。

接着,我修改了模型 (对etth.yaml中的 n_layer_enc: 3 n_layer_dec: 2 改为 n_layer_enc: 6 n_layer_dec: 4 ,Transformer中forward函数中a, att = self.attn1(self.ln1(x, timestep, label_emb), mask=mask)
x = x
a, att = self.attn2(self.ln1_1(x, timestep), encoder_output, mask=mask)
x = x
改为
a, att = self.attn1(self.ln1(x, timestep, label_emb), mask=mask)
x = x + a
a, att = self.attn2(self.ln1_1(x, timestep), encoder_output, mask=mask)
x = x+ a )
然后我重新训练模型,测试模型(参数和配置同修改前)

train的结果是发生了变化,但是修改前后ddpm_infill_None.npy文件的输出一致,test结果没变。请问这是原因呢?以下是ddpm_infill_None.npy的输出(197, 24, 7)的第10个sample的结果(修改前后,图片一致):
myplot

checkpoint-10 - 修改前.pdf把.pdf改为.pt

checkpoint-10 - 修改后.pdf把.pdf改为.pt

关于修改您的模型的一些问题

作者大哥您好!我现在在尝试修改您的模型使得我能够通过模型内部的自回归去噪过程生成任意长度的时间序列(但是不是反复用pred模式自回归预测),因此我想问一下,您的模型在学习加噪去噪的过程中,是学习两个相邻时间步之间的加噪去噪,还是学习对一个给定长度下的时间序列的加噪减噪过程呢?如果是前者的话我应该就有可能修改您的sample代码来实现我的目的了,感谢!
截屏2024-08-05 15 16 03

数据集太大

作者你好,由于我的数据集过大,导致无法运行,并产生下面的错误。请问能否将数据集分成多个.csv文件来进行读取,如何可以的话能否告知在哪修改

x = np.zeros((self.sample_num_total, self.window, self.var_num))
numpy.core._exceptions.MemoryError: Unable to allocate 137. GiB for an array with shape (7174401, 1280, 2) and data type float64

数据集结构

作者,你好。我想改变训练集ground_truth_24_train.npy与无条件生成fake_24_1.npy文件的样本数量,即.npy数据结构中(n,windows,feature)中n的值,该修改config文件中的哪一个参数或代码中的哪条语句

something about sampling with what model,condition?and uncondition?

I am currently training my dataset with this code and have a few questions I don't understand:

  1. In the readme, there is only one training command, but there are three types of sampling: Unconstrained,imputation,Forecasting.
    To train conditional diffusion models and unconditional diffusion models, it is necessary to set the training set split ratio to less than 1 or equal to 1. Besides changing the training set split ratio, are there any other parameters that need to be modified?
  2. How do I generate samples without conditions? Is it by using the command :python main.py --name {name} --config_file {config.yaml} --gpu 0 --sample 0 --milestone {checkpoint_number}?
  3. Does the imputation task require training a conditional model?

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.