From 124e6101452b18a38fe271537bcc8d0f81939770 Mon Sep 17 00:00:00 2001 From: ZX <534098964@qq.com> Date: Fri, 30 Jan 2026 12:34:14 +0800 Subject: [PATCH] add continuous TSG model Diff-MN --- Diff-MN/README.md | 42 +++++++++++++++++++ .../TorchDiffEqPack/__init__.py | 0 {MNTSG => Diff-MN}/TorchDiffEqPack/misc.py | 0 .../TorchDiffEqPack/odesolver/__init__.py | 0 .../odesolver/adaptive_grid_solver.py | 0 .../odesolver/autograd_functional.py | 0 .../TorchDiffEqPack/odesolver/base.py | 0 .../odesolver/fixed_grid_solver.py | 0 .../TorchDiffEqPack/odesolver/ode_solver.py | 0 .../odesolver/stiff_ode_solver.py | 0 .../TorchDiffEqPack/odesolver/symplectic.py | 0 .../odesolver/tuple_to_tensor_wrapper.py | 0 .../TorchDiffEqPack/odesolver_mem/__init__.py | 0 .../TorchDiffEqPack/odesolver_mem/adjoint.py | 0 .../odesolver_mem/adjoint_mem.py | 0 .../odesolver_mem/odesolver_endtime.py | 0 {MNTSG => Diff-MN}/TorchDiffEqPack/utils.py | 0 .../MNTSG.yaml => Diff-MN/configs/DiffMN.yaml | 2 +- {MNTSG => Diff-MN}/controldiffeq/__init__.py | 0 .../controldiffeq/cdeint_module.py | 0 .../controldiffeq/interpolate.py | 0 {MNTSG => Diff-MN}/controldiffeq/misc.py | 0 {MNTSG => Diff-MN}/datasets/__init__.py | 0 .../datasets/dataset_polynomial.py | 0 {MNTSG => Diff-MN}/datasets/mujoco_physics.py | 0 {MNTSG => Diff-MN}/datasets/sine_data.py | 0 .../environment_diffmn.yml | 2 +- {MNTSG => Diff-MN}/ldm/data/tsg_dataset.py | 2 +- {MNTSG => Diff-MN}/ldm/lr_scheduler.py | 0 {MNTSG => Diff-MN}/ldm/models/autoencoder.py | 0 .../ldm/models/diffusion/ddim_time.py | 0 .../ldm/models/diffusion/ddpm_time.py | 0 {MNTSG => Diff-MN}/ldm/modules/attention.py | 0 .../ldm/modules/diffusionmodules/ts_unet.py | 0 .../ldm/modules/diffusionmodules/util.py | 0 .../modules/distributions/distributions.py | 0 {MNTSG => Diff-MN}/ldm/modules/ema.py | 0 .../ldm/modules/encoders/modules.py | 0 {MNTSG => Diff-MN}/ldm/util.py | 0 {MNTSG => Diff-MN}/lib/utils.py | 0 .../metrics/discriminative_torch.py | 0 .../metrics/downstream_forecasting.py | 0 .../metrics/feature_distance_eval.py | 0 .../metrics/metrics_forecasting.py | 0 {MNTSG => Diff-MN}/metrics/metrics_sets.py | 0 .../metrics/visualization_metrics.py | 0 {MNTSG => Diff-MN}/models/kovae.py | 0 {MNTSG => Diff-MN}/models/losses.py | 0 {MNTSG => Diff-MN}/models/modules.py | 0 .../models/moe_ncde/moe_neural_cde.py | 0 {MNTSG => Diff-MN}/models/neuralCDE.py | 0 .../run_diffmn_diffsuion.py | 8 ++-- {MNTSG => Diff-MN}/run_irregular_kovae.py | 0 {MNTSG => Diff-MN}/run_irregular_moencde.py | 0 .../run_irregular_moencde_continues.py | 2 +- .../utils_diffmn}/callback_utils.py | 6 +-- .../utils_diffmn}/cli_utils.py | 2 +- .../utils_diffmn}/data_utils.py | 0 .../utils_diffmn}/dataset_polynomial.py | 0 .../utils_diffmn}/init_utils.py | 6 +-- .../utils_diffmn}/pkl_utils.py | 0 .../utils_diffmn}/test_utils.py | 0 .../utils_diffmn}/utils_data_continues.py | 0 {MNTSG => Diff-MN}/utils_kovae/datautils.py | 0 {MNTSG => Diff-MN}/utils_kovae/utils.py | 0 {MNTSG => Diff-MN}/utils_kovae/utils_data.py | 2 +- {MNTSG => Diff-MN}/utils_kovae/utils_model.py | 0 MNTSG/README.md | 32 -------------- 68 files changed, 58 insertions(+), 48 deletions(-) create mode 100644 Diff-MN/README.md rename {MNTSG => Diff-MN}/TorchDiffEqPack/__init__.py (100%) rename {MNTSG => Diff-MN}/TorchDiffEqPack/misc.py (100%) rename {MNTSG => Diff-MN}/TorchDiffEqPack/odesolver/__init__.py (100%) rename {MNTSG => Diff-MN}/TorchDiffEqPack/odesolver/adaptive_grid_solver.py (100%) rename {MNTSG => Diff-MN}/TorchDiffEqPack/odesolver/autograd_functional.py (100%) rename {MNTSG => Diff-MN}/TorchDiffEqPack/odesolver/base.py (100%) rename {MNTSG => Diff-MN}/TorchDiffEqPack/odesolver/fixed_grid_solver.py (100%) rename {MNTSG => Diff-MN}/TorchDiffEqPack/odesolver/ode_solver.py (100%) rename {MNTSG => Diff-MN}/TorchDiffEqPack/odesolver/stiff_ode_solver.py (100%) rename {MNTSG => Diff-MN}/TorchDiffEqPack/odesolver/symplectic.py (100%) rename {MNTSG => Diff-MN}/TorchDiffEqPack/odesolver/tuple_to_tensor_wrapper.py (100%) rename {MNTSG => Diff-MN}/TorchDiffEqPack/odesolver_mem/__init__.py (100%) rename {MNTSG => Diff-MN}/TorchDiffEqPack/odesolver_mem/adjoint.py (100%) rename {MNTSG => Diff-MN}/TorchDiffEqPack/odesolver_mem/adjoint_mem.py (100%) rename {MNTSG => Diff-MN}/TorchDiffEqPack/odesolver_mem/odesolver_endtime.py (100%) rename {MNTSG => Diff-MN}/TorchDiffEqPack/utils.py (100%) rename MNTSG/configs/MNTSG.yaml => Diff-MN/configs/DiffMN.yaml (98%) rename {MNTSG => Diff-MN}/controldiffeq/__init__.py (100%) rename {MNTSG => Diff-MN}/controldiffeq/cdeint_module.py (100%) rename {MNTSG => Diff-MN}/controldiffeq/interpolate.py (100%) rename {MNTSG => Diff-MN}/controldiffeq/misc.py (100%) rename {MNTSG => Diff-MN}/datasets/__init__.py (100%) rename {MNTSG => Diff-MN}/datasets/dataset_polynomial.py (100%) rename {MNTSG => Diff-MN}/datasets/mujoco_physics.py (100%) rename {MNTSG => Diff-MN}/datasets/sine_data.py (100%) rename MNTSG/environment_mntsg.yml => Diff-MN/environment_diffmn.yml (99%) rename {MNTSG => Diff-MN}/ldm/data/tsg_dataset.py (99%) rename {MNTSG => Diff-MN}/ldm/lr_scheduler.py (100%) rename {MNTSG => Diff-MN}/ldm/models/autoencoder.py (100%) rename {MNTSG => Diff-MN}/ldm/models/diffusion/ddim_time.py (100%) rename {MNTSG => Diff-MN}/ldm/models/diffusion/ddpm_time.py (100%) rename {MNTSG => Diff-MN}/ldm/modules/attention.py (100%) rename {MNTSG => Diff-MN}/ldm/modules/diffusionmodules/ts_unet.py (100%) rename {MNTSG => Diff-MN}/ldm/modules/diffusionmodules/util.py (100%) rename {MNTSG => Diff-MN}/ldm/modules/distributions/distributions.py (100%) rename {MNTSG => Diff-MN}/ldm/modules/ema.py (100%) rename {MNTSG => Diff-MN}/ldm/modules/encoders/modules.py (100%) rename {MNTSG => Diff-MN}/ldm/util.py (100%) rename {MNTSG => Diff-MN}/lib/utils.py (100%) rename {MNTSG => Diff-MN}/metrics/discriminative_torch.py (100%) rename {MNTSG => Diff-MN}/metrics/downstream_forecasting.py (100%) rename {MNTSG => Diff-MN}/metrics/feature_distance_eval.py (100%) rename {MNTSG => Diff-MN}/metrics/metrics_forecasting.py (100%) rename {MNTSG => Diff-MN}/metrics/metrics_sets.py (100%) rename {MNTSG => Diff-MN}/metrics/visualization_metrics.py (100%) rename {MNTSG => Diff-MN}/models/kovae.py (100%) rename {MNTSG => Diff-MN}/models/losses.py (100%) rename {MNTSG => Diff-MN}/models/modules.py (100%) rename {MNTSG => Diff-MN}/models/moe_ncde/moe_neural_cde.py (100%) rename {MNTSG => Diff-MN}/models/neuralCDE.py (100%) rename MNTSG/run_mntsg_diffsuion.py => Diff-MN/run_diffmn_diffsuion.py (84%) rename {MNTSG => Diff-MN}/run_irregular_kovae.py (100%) rename {MNTSG => Diff-MN}/run_irregular_moencde.py (100%) rename {MNTSG => Diff-MN}/run_irregular_moencde_continues.py (99%) rename {MNTSG/utils_mntsg => Diff-MN/utils_diffmn}/callback_utils.py (98%) rename {MNTSG/utils_mntsg => Diff-MN/utils_diffmn}/cli_utils.py (98%) rename {MNTSG/utils_mntsg => Diff-MN/utils_diffmn}/data_utils.py (100%) rename {MNTSG/utils_mntsg => Diff-MN/utils_diffmn}/dataset_polynomial.py (100%) rename {MNTSG/utils_mntsg => Diff-MN/utils_diffmn}/init_utils.py (98%) rename {MNTSG/utils_mntsg => Diff-MN/utils_diffmn}/pkl_utils.py (100%) rename {MNTSG/utils_mntsg => Diff-MN/utils_diffmn}/test_utils.py (100%) rename {MNTSG/utils_mntsg => Diff-MN/utils_diffmn}/utils_data_continues.py (100%) rename {MNTSG => Diff-MN}/utils_kovae/datautils.py (100%) rename {MNTSG => Diff-MN}/utils_kovae/utils.py (100%) rename {MNTSG => Diff-MN}/utils_kovae/utils_data.py (99%) rename {MNTSG => Diff-MN}/utils_kovae/utils_model.py (100%) delete mode 100644 MNTSG/README.md diff --git a/Diff-MN/README.md b/Diff-MN/README.md new file mode 100644 index 0000000..34ee81a --- /dev/null +++ b/Diff-MN/README.md @@ -0,0 +1,42 @@ +# Diff-MN + +Time series generation (TSG) is widely used across domains, yet most existing methods assume regular sampling and fixed output resolutions. These assumptions are often violated in practice, where observations are irregular and sparse, while downstream applications require continuous and high-resolution TS. + +Although Neural Controlled Differential Equation (NCDE) is promising for modeling irregular TS, it is constrained by a single dynamics function, tightly coupled optimization, and limited ability to adapt learned dynamics to newly generated samples from the generative model. + +We propose Diff-MN, a continuous TSG framework that enhances NCDE with a Mixture-of-Experts (MoE) dynamics function and a decoupled architectural design for dynamics-focused training. + +To further enable NCDE to generalize to newly generated samples, Diff-MN employs a diffusion model to parameterize the NCDE temporal dynamics parameters (MoE weights), i.e., +jointly learn the distribution of TS data and MoE weights. This design allows sample-specific NCDE parameters to be generated for continuous TS generation. + +Experiments on ten public and synthetic datasets demonstrate that Diff-MN consistently outperforms strong baselines on both irregular-to-regular and irregular-to-continuous TSG tasks. + + + +## Environment + +Install the environment using the YAML file: `./environment_diffmn.yml`: + +```bash +conda env create -f environment_diffmn.yml --force --no-deps +``` + +## Data +Stocks and Energy data are located in `./datasets`. Sine, MuJoCo, polynomial datasets are generated and the scripts are included in `./datasets` folder. + +`utils_data.py` provides functions for loading data in both regular and irregular settings. In particular, irregular data are preprocessed using the Python class `TimeDataset_irregular`, which may take some time to run. Once preprocessing is complete, the processed data are saved in the `./datasets` directory for future use. + + +## Reproducing the paper results +By setting the time series length and missing values within the script, the results in the paper can be reproduced: + + +**Step 1:** The initial MoE NeuralCDE can be trained by `run_irregular_moencde.py`. + +--- + +**Step 2:** Parameterizing the MoE weights can be achieved by jointly training the TS samples and their corresponding MoE weights through script `run_diffmn_diffsuion.py`. + +--- + +**Step 3:** Through Step 2, we generate new samples along with their corresponding MoE weights. These weights are then fed into the pretrained MoE Neural CDE to perform continuous time series generation for each new sample. Finally, the refined high-frequency continuous time series are obtained using the script `run_irregular_moencde_continues.py`, providing richer temporal information and improving the accuracy of downstream tasks. diff --git a/MNTSG/TorchDiffEqPack/__init__.py b/Diff-MN/TorchDiffEqPack/__init__.py similarity index 100% rename from MNTSG/TorchDiffEqPack/__init__.py rename to Diff-MN/TorchDiffEqPack/__init__.py diff --git a/MNTSG/TorchDiffEqPack/misc.py b/Diff-MN/TorchDiffEqPack/misc.py similarity index 100% rename from MNTSG/TorchDiffEqPack/misc.py rename to Diff-MN/TorchDiffEqPack/misc.py diff --git a/MNTSG/TorchDiffEqPack/odesolver/__init__.py b/Diff-MN/TorchDiffEqPack/odesolver/__init__.py similarity index 100% rename from MNTSG/TorchDiffEqPack/odesolver/__init__.py rename to Diff-MN/TorchDiffEqPack/odesolver/__init__.py diff --git a/MNTSG/TorchDiffEqPack/odesolver/adaptive_grid_solver.py b/Diff-MN/TorchDiffEqPack/odesolver/adaptive_grid_solver.py similarity index 100% rename from MNTSG/TorchDiffEqPack/odesolver/adaptive_grid_solver.py rename to Diff-MN/TorchDiffEqPack/odesolver/adaptive_grid_solver.py diff --git a/MNTSG/TorchDiffEqPack/odesolver/autograd_functional.py b/Diff-MN/TorchDiffEqPack/odesolver/autograd_functional.py similarity index 100% rename from MNTSG/TorchDiffEqPack/odesolver/autograd_functional.py rename to Diff-MN/TorchDiffEqPack/odesolver/autograd_functional.py diff --git a/MNTSG/TorchDiffEqPack/odesolver/base.py b/Diff-MN/TorchDiffEqPack/odesolver/base.py similarity index 100% rename from MNTSG/TorchDiffEqPack/odesolver/base.py rename to Diff-MN/TorchDiffEqPack/odesolver/base.py diff --git a/MNTSG/TorchDiffEqPack/odesolver/fixed_grid_solver.py b/Diff-MN/TorchDiffEqPack/odesolver/fixed_grid_solver.py similarity index 100% rename from MNTSG/TorchDiffEqPack/odesolver/fixed_grid_solver.py rename to Diff-MN/TorchDiffEqPack/odesolver/fixed_grid_solver.py diff --git a/MNTSG/TorchDiffEqPack/odesolver/ode_solver.py b/Diff-MN/TorchDiffEqPack/odesolver/ode_solver.py similarity index 100% rename from MNTSG/TorchDiffEqPack/odesolver/ode_solver.py rename to Diff-MN/TorchDiffEqPack/odesolver/ode_solver.py diff --git a/MNTSG/TorchDiffEqPack/odesolver/stiff_ode_solver.py b/Diff-MN/TorchDiffEqPack/odesolver/stiff_ode_solver.py similarity index 100% rename from MNTSG/TorchDiffEqPack/odesolver/stiff_ode_solver.py rename to Diff-MN/TorchDiffEqPack/odesolver/stiff_ode_solver.py diff --git a/MNTSG/TorchDiffEqPack/odesolver/symplectic.py b/Diff-MN/TorchDiffEqPack/odesolver/symplectic.py similarity index 100% rename from MNTSG/TorchDiffEqPack/odesolver/symplectic.py rename to Diff-MN/TorchDiffEqPack/odesolver/symplectic.py diff --git a/MNTSG/TorchDiffEqPack/odesolver/tuple_to_tensor_wrapper.py b/Diff-MN/TorchDiffEqPack/odesolver/tuple_to_tensor_wrapper.py similarity index 100% rename from MNTSG/TorchDiffEqPack/odesolver/tuple_to_tensor_wrapper.py rename to Diff-MN/TorchDiffEqPack/odesolver/tuple_to_tensor_wrapper.py diff --git a/MNTSG/TorchDiffEqPack/odesolver_mem/__init__.py b/Diff-MN/TorchDiffEqPack/odesolver_mem/__init__.py similarity index 100% rename from MNTSG/TorchDiffEqPack/odesolver_mem/__init__.py rename to Diff-MN/TorchDiffEqPack/odesolver_mem/__init__.py diff --git a/MNTSG/TorchDiffEqPack/odesolver_mem/adjoint.py b/Diff-MN/TorchDiffEqPack/odesolver_mem/adjoint.py similarity index 100% rename from MNTSG/TorchDiffEqPack/odesolver_mem/adjoint.py rename to Diff-MN/TorchDiffEqPack/odesolver_mem/adjoint.py diff --git a/MNTSG/TorchDiffEqPack/odesolver_mem/adjoint_mem.py b/Diff-MN/TorchDiffEqPack/odesolver_mem/adjoint_mem.py similarity index 100% rename from MNTSG/TorchDiffEqPack/odesolver_mem/adjoint_mem.py rename to Diff-MN/TorchDiffEqPack/odesolver_mem/adjoint_mem.py diff --git a/MNTSG/TorchDiffEqPack/odesolver_mem/odesolver_endtime.py b/Diff-MN/TorchDiffEqPack/odesolver_mem/odesolver_endtime.py similarity index 100% rename from MNTSG/TorchDiffEqPack/odesolver_mem/odesolver_endtime.py rename to Diff-MN/TorchDiffEqPack/odesolver_mem/odesolver_endtime.py diff --git a/MNTSG/TorchDiffEqPack/utils.py b/Diff-MN/TorchDiffEqPack/utils.py similarity index 100% rename from MNTSG/TorchDiffEqPack/utils.py rename to Diff-MN/TorchDiffEqPack/utils.py diff --git a/MNTSG/configs/MNTSG.yaml b/Diff-MN/configs/DiffMN.yaml similarity index 98% rename from MNTSG/configs/MNTSG.yaml rename to Diff-MN/configs/DiffMN.yaml index 53a254e..5bcbd31 100644 --- a/MNTSG/configs/MNTSG.yaml +++ b/Diff-MN/configs/DiffMN.yaml @@ -94,7 +94,7 @@ lightning: # image_logger: -# target: utils_mntsg.callback_utils.TSLogger +# target: utils_diffmn.callback_utils.TSLogger # params: # batch_frequency: 2000 # max_images: 8 diff --git a/MNTSG/controldiffeq/__init__.py b/Diff-MN/controldiffeq/__init__.py similarity index 100% rename from MNTSG/controldiffeq/__init__.py rename to Diff-MN/controldiffeq/__init__.py diff --git a/MNTSG/controldiffeq/cdeint_module.py b/Diff-MN/controldiffeq/cdeint_module.py similarity index 100% rename from MNTSG/controldiffeq/cdeint_module.py rename to Diff-MN/controldiffeq/cdeint_module.py diff --git a/MNTSG/controldiffeq/interpolate.py b/Diff-MN/controldiffeq/interpolate.py similarity index 100% rename from MNTSG/controldiffeq/interpolate.py rename to Diff-MN/controldiffeq/interpolate.py diff --git a/MNTSG/controldiffeq/misc.py b/Diff-MN/controldiffeq/misc.py similarity index 100% rename from MNTSG/controldiffeq/misc.py rename to Diff-MN/controldiffeq/misc.py diff --git a/MNTSG/datasets/__init__.py b/Diff-MN/datasets/__init__.py similarity index 100% rename from MNTSG/datasets/__init__.py rename to Diff-MN/datasets/__init__.py diff --git a/MNTSG/datasets/dataset_polynomial.py b/Diff-MN/datasets/dataset_polynomial.py similarity index 100% rename from MNTSG/datasets/dataset_polynomial.py rename to Diff-MN/datasets/dataset_polynomial.py diff --git a/MNTSG/datasets/mujoco_physics.py b/Diff-MN/datasets/mujoco_physics.py similarity index 100% rename from MNTSG/datasets/mujoco_physics.py rename to Diff-MN/datasets/mujoco_physics.py diff --git a/MNTSG/datasets/sine_data.py b/Diff-MN/datasets/sine_data.py similarity index 100% rename from MNTSG/datasets/sine_data.py rename to Diff-MN/datasets/sine_data.py diff --git a/MNTSG/environment_mntsg.yml b/Diff-MN/environment_diffmn.yml similarity index 99% rename from MNTSG/environment_mntsg.yml rename to Diff-MN/environment_diffmn.yml index e510aa6..1999ef5 100644 --- a/MNTSG/environment_mntsg.yml +++ b/Diff-MN/environment_diffmn.yml @@ -1,4 +1,4 @@ -name: mntsg +name: diffmn channels: - defaults dependencies: diff --git a/MNTSG/ldm/data/tsg_dataset.py b/Diff-MN/ldm/data/tsg_dataset.py similarity index 99% rename from MNTSG/ldm/data/tsg_dataset.py rename to Diff-MN/ldm/data/tsg_dataset.py index eed3b92..04e05ca 100644 --- a/MNTSG/ldm/data/tsg_dataset.py +++ b/Diff-MN/ldm/data/tsg_dataset.py @@ -121,7 +121,7 @@ def prepare_data(self,) -> None: data_path = f'./logs_irgen_moencde_final_ECG_womoe_baseline/{self.args.d_name}/MoeNcdeIrreg-seed=42-miss={self.args.miss_}seqlen=24epochs=30' data_path_fix = f'./logs_irgen_moencde_final_ECG/{self.args.d_name}/MoeNcdeIrreg-seed=42-miss={self.args.miss_}seqlen=24epochs=30' else: - data_path=f'./logs_irgen_moencde_mntsg/{self.args.d_name}/MoeNcdeIrreg-seed=42-miss={self.args.miss_}seqlen={self.args.seq_len}epochs=30' + data_path=f'./logs_irgen_moencde_diffmn/{self.args.d_name}/MoeNcdeIrreg-seed=42-miss={self.args.miss_}seqlen={self.args.seq_len}epochs=30' data_path_fix = f'./logs_irgen_moencde_final/{self.args.d_name}/MoeNcdeIrreg-seed=42-miss={self.args.miss_}seqlen={self.args.seq_len}epochs=30' else: diff --git a/MNTSG/ldm/lr_scheduler.py b/Diff-MN/ldm/lr_scheduler.py similarity index 100% rename from MNTSG/ldm/lr_scheduler.py rename to Diff-MN/ldm/lr_scheduler.py diff --git a/MNTSG/ldm/models/autoencoder.py b/Diff-MN/ldm/models/autoencoder.py similarity index 100% rename from MNTSG/ldm/models/autoencoder.py rename to Diff-MN/ldm/models/autoencoder.py diff --git a/MNTSG/ldm/models/diffusion/ddim_time.py b/Diff-MN/ldm/models/diffusion/ddim_time.py similarity index 100% rename from MNTSG/ldm/models/diffusion/ddim_time.py rename to Diff-MN/ldm/models/diffusion/ddim_time.py diff --git a/MNTSG/ldm/models/diffusion/ddpm_time.py b/Diff-MN/ldm/models/diffusion/ddpm_time.py similarity index 100% rename from MNTSG/ldm/models/diffusion/ddpm_time.py rename to Diff-MN/ldm/models/diffusion/ddpm_time.py diff --git a/MNTSG/ldm/modules/attention.py b/Diff-MN/ldm/modules/attention.py similarity index 100% rename from MNTSG/ldm/modules/attention.py rename to Diff-MN/ldm/modules/attention.py diff --git a/MNTSG/ldm/modules/diffusionmodules/ts_unet.py b/Diff-MN/ldm/modules/diffusionmodules/ts_unet.py similarity index 100% rename from MNTSG/ldm/modules/diffusionmodules/ts_unet.py rename to Diff-MN/ldm/modules/diffusionmodules/ts_unet.py diff --git a/MNTSG/ldm/modules/diffusionmodules/util.py b/Diff-MN/ldm/modules/diffusionmodules/util.py similarity index 100% rename from MNTSG/ldm/modules/diffusionmodules/util.py rename to Diff-MN/ldm/modules/diffusionmodules/util.py diff --git a/MNTSG/ldm/modules/distributions/distributions.py b/Diff-MN/ldm/modules/distributions/distributions.py similarity index 100% rename from MNTSG/ldm/modules/distributions/distributions.py rename to Diff-MN/ldm/modules/distributions/distributions.py diff --git a/MNTSG/ldm/modules/ema.py b/Diff-MN/ldm/modules/ema.py similarity index 100% rename from MNTSG/ldm/modules/ema.py rename to Diff-MN/ldm/modules/ema.py diff --git a/MNTSG/ldm/modules/encoders/modules.py b/Diff-MN/ldm/modules/encoders/modules.py similarity index 100% rename from MNTSG/ldm/modules/encoders/modules.py rename to Diff-MN/ldm/modules/encoders/modules.py diff --git a/MNTSG/ldm/util.py b/Diff-MN/ldm/util.py similarity index 100% rename from MNTSG/ldm/util.py rename to Diff-MN/ldm/util.py diff --git a/MNTSG/lib/utils.py b/Diff-MN/lib/utils.py similarity index 100% rename from MNTSG/lib/utils.py rename to Diff-MN/lib/utils.py diff --git a/MNTSG/metrics/discriminative_torch.py b/Diff-MN/metrics/discriminative_torch.py similarity index 100% rename from MNTSG/metrics/discriminative_torch.py rename to Diff-MN/metrics/discriminative_torch.py diff --git a/MNTSG/metrics/downstream_forecasting.py b/Diff-MN/metrics/downstream_forecasting.py similarity index 100% rename from MNTSG/metrics/downstream_forecasting.py rename to Diff-MN/metrics/downstream_forecasting.py diff --git a/MNTSG/metrics/feature_distance_eval.py b/Diff-MN/metrics/feature_distance_eval.py similarity index 100% rename from MNTSG/metrics/feature_distance_eval.py rename to Diff-MN/metrics/feature_distance_eval.py diff --git a/MNTSG/metrics/metrics_forecasting.py b/Diff-MN/metrics/metrics_forecasting.py similarity index 100% rename from MNTSG/metrics/metrics_forecasting.py rename to Diff-MN/metrics/metrics_forecasting.py diff --git a/MNTSG/metrics/metrics_sets.py b/Diff-MN/metrics/metrics_sets.py similarity index 100% rename from MNTSG/metrics/metrics_sets.py rename to Diff-MN/metrics/metrics_sets.py diff --git a/MNTSG/metrics/visualization_metrics.py b/Diff-MN/metrics/visualization_metrics.py similarity index 100% rename from MNTSG/metrics/visualization_metrics.py rename to Diff-MN/metrics/visualization_metrics.py diff --git a/MNTSG/models/kovae.py b/Diff-MN/models/kovae.py similarity index 100% rename from MNTSG/models/kovae.py rename to Diff-MN/models/kovae.py diff --git a/MNTSG/models/losses.py b/Diff-MN/models/losses.py similarity index 100% rename from MNTSG/models/losses.py rename to Diff-MN/models/losses.py diff --git a/MNTSG/models/modules.py b/Diff-MN/models/modules.py similarity index 100% rename from MNTSG/models/modules.py rename to Diff-MN/models/modules.py diff --git a/MNTSG/models/moe_ncde/moe_neural_cde.py b/Diff-MN/models/moe_ncde/moe_neural_cde.py similarity index 100% rename from MNTSG/models/moe_ncde/moe_neural_cde.py rename to Diff-MN/models/moe_ncde/moe_neural_cde.py diff --git a/MNTSG/models/neuralCDE.py b/Diff-MN/models/neuralCDE.py similarity index 100% rename from MNTSG/models/neuralCDE.py rename to Diff-MN/models/neuralCDE.py diff --git a/MNTSG/run_mntsg_diffsuion.py b/Diff-MN/run_diffmn_diffsuion.py similarity index 84% rename from MNTSG/run_mntsg_diffsuion.py rename to Diff-MN/run_diffmn_diffsuion.py index 51e57d8..ab9e435 100644 --- a/MNTSG/run_mntsg_diffsuion.py +++ b/Diff-MN/run_diffmn_diffsuion.py @@ -13,14 +13,14 @@ import time from pytorch_lightning.trainer import Trainer -from utils_mntsg.cli_utils import get_parser -from utils_mntsg.init_utils import init_model_data_trainer -from utils_mntsg.test_utils import test_model_with_diffcde +from utils_diffmn.cli_utils import get_parser +from utils_diffmn.init_utils import init_model_data_trainer +from utils_diffmn.test_utils import test_model_with_diffcde if __name__ == "__main__": sys.argv = [ - "--base", "configs/MNTSG.yaml", + "--base", "configs/Diff-MN.yaml", "--gpus", "0,", "--logdir", "./logs/", "-sl", "28", diff --git a/MNTSG/run_irregular_kovae.py b/Diff-MN/run_irregular_kovae.py similarity index 100% rename from MNTSG/run_irregular_kovae.py rename to Diff-MN/run_irregular_kovae.py diff --git a/MNTSG/run_irregular_moencde.py b/Diff-MN/run_irregular_moencde.py similarity index 100% rename from MNTSG/run_irregular_moencde.py rename to Diff-MN/run_irregular_moencde.py diff --git a/MNTSG/run_irregular_moencde_continues.py b/Diff-MN/run_irregular_moencde_continues.py similarity index 99% rename from MNTSG/run_irregular_moencde_continues.py rename to Diff-MN/run_irregular_moencde_continues.py index 7d0e7c9..6e29527 100644 --- a/MNTSG/run_irregular_moencde_continues.py +++ b/Diff-MN/run_irregular_moencde_continues.py @@ -25,7 +25,7 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import logging -from utils_mntsg.utils_data_continues import TimeDataset_irregular +from utils_diffmn.utils_data_continues import TimeDataset_irregular import torch import torch.nn as nn import torch.nn.functional as F diff --git a/MNTSG/utils_mntsg/callback_utils.py b/Diff-MN/utils_diffmn/callback_utils.py similarity index 98% rename from MNTSG/utils_mntsg/callback_utils.py rename to Diff-MN/utils_diffmn/callback_utils.py index fe602e4..802662a 100644 --- a/MNTSG/utils_mntsg/callback_utils.py +++ b/Diff-MN/utils_diffmn/callback_utils.py @@ -233,7 +233,7 @@ def prepare_trainer_configs(nowname, logdir, opt, lightning_config, ckptdir, mod "save_dir": logdir, "offline": opt.debug, "id": f"{nowname}_{now}", - "project": "MNTSG", + "project": "Diff-MN", } } } @@ -280,7 +280,7 @@ def prepare_trainer_configs(nowname, logdir, opt, lightning_config, ckptdir, mod # add callback which sets up log directory default_callbacks_cfg = { "setup_callback": { - "target": "utils_mntsg.callback_utils.SetupCallback", + "target": "utils_diffmn.callback_utils.SetupCallback", "params": { "resume": opt.resume, "now": now, @@ -298,7 +298,7 @@ def prepare_trainer_configs(nowname, logdir, opt, lightning_config, ckptdir, mod } }, "cuda_callback": { - "target": "utils_mntsg.callback_utils.CUDACallback" + "target": "utils_diffmn.callback_utils.CUDACallback" }, } if version.parse(pl.__version__) >= version.parse('1.4.0'): diff --git a/MNTSG/utils_mntsg/cli_utils.py b/Diff-MN/utils_diffmn/cli_utils.py similarity index 98% rename from MNTSG/utils_mntsg/cli_utils.py rename to Diff-MN/utils_diffmn/cli_utils.py index 3f9b0b1..279dcba 100644 --- a/MNTSG/utils_mntsg/cli_utils.py +++ b/Diff-MN/utils_diffmn/cli_utils.py @@ -44,7 +44,7 @@ def parse_args_with_defaults(): # 模拟命令行参数 default_args = [ - "--base", "configs/MNTSG.yaml", + "--base", "configs/Diff-MN.yaml", "--gpus", "6", "--logdir", "./logs/", "-sl", "168", diff --git a/MNTSG/utils_mntsg/data_utils.py b/Diff-MN/utils_diffmn/data_utils.py similarity index 100% rename from MNTSG/utils_mntsg/data_utils.py rename to Diff-MN/utils_diffmn/data_utils.py diff --git a/MNTSG/utils_mntsg/dataset_polynomial.py b/Diff-MN/utils_diffmn/dataset_polynomial.py similarity index 100% rename from MNTSG/utils_mntsg/dataset_polynomial.py rename to Diff-MN/utils_diffmn/dataset_polynomial.py diff --git a/MNTSG/utils_mntsg/init_utils.py b/Diff-MN/utils_diffmn/init_utils.py similarity index 98% rename from MNTSG/utils_mntsg/init_utils.py rename to Diff-MN/utils_diffmn/init_utils.py index 04a3148..39e94b9 100644 --- a/MNTSG/utils_mntsg/init_utils.py +++ b/Diff-MN/utils_diffmn/init_utils.py @@ -9,13 +9,13 @@ from pytorch_lightning import Trainer from omegaconf import OmegaConf -from utils_mntsg.cli_utils import nondefault_trainer_args -from utils_mntsg.callback_utils import prepare_trainer_configs +from utils_diffmn.cli_utils import nondefault_trainer_args +from utils_diffmn.callback_utils import prepare_trainer_configs from pytorch_lightning import seed_everything from ldm.util import instantiate_from_config from pathlib import Path import datetime -from utils_mntsg.cli_utils import nondefault_trainer_args +from utils_diffmn.cli_utils import nondefault_trainer_args # data_root = os.environ['DATA_ROOT'] data_root='./data' diff --git a/MNTSG/utils_mntsg/pkl_utils.py b/Diff-MN/utils_diffmn/pkl_utils.py similarity index 100% rename from MNTSG/utils_mntsg/pkl_utils.py rename to Diff-MN/utils_diffmn/pkl_utils.py diff --git a/MNTSG/utils_mntsg/test_utils.py b/Diff-MN/utils_diffmn/test_utils.py similarity index 100% rename from MNTSG/utils_mntsg/test_utils.py rename to Diff-MN/utils_diffmn/test_utils.py diff --git a/MNTSG/utils_mntsg/utils_data_continues.py b/Diff-MN/utils_diffmn/utils_data_continues.py similarity index 100% rename from MNTSG/utils_mntsg/utils_data_continues.py rename to Diff-MN/utils_diffmn/utils_data_continues.py diff --git a/MNTSG/utils_kovae/datautils.py b/Diff-MN/utils_kovae/datautils.py similarity index 100% rename from MNTSG/utils_kovae/datautils.py rename to Diff-MN/utils_kovae/datautils.py diff --git a/MNTSG/utils_kovae/utils.py b/Diff-MN/utils_kovae/utils.py similarity index 100% rename from MNTSG/utils_kovae/utils.py rename to Diff-MN/utils_kovae/utils.py diff --git a/MNTSG/utils_kovae/utils_data.py b/Diff-MN/utils_kovae/utils_data.py similarity index 99% rename from MNTSG/utils_kovae/utils_data.py rename to Diff-MN/utils_kovae/utils_data.py index e878f58..5f2d1e2 100644 --- a/MNTSG/utils_kovae/utils_data.py +++ b/Diff-MN/utils_kovae/utils_data.py @@ -18,7 +18,7 @@ import torch import controldiffeq import pathlib -from utils_mntsg.dataset_polynomial import generate_polynomial_dataset +from utils_diffmn.dataset_polynomial import generate_polynomial_dataset from utils_kovae import datautils PROJECT_DIR = pathlib.Path(__file__).resolve().parent.parent diff --git a/MNTSG/utils_kovae/utils_model.py b/Diff-MN/utils_kovae/utils_model.py similarity index 100% rename from MNTSG/utils_kovae/utils_model.py rename to Diff-MN/utils_kovae/utils_model.py diff --git a/MNTSG/README.md b/MNTSG/README.md deleted file mode 100644 index cc308b9..0000000 --- a/MNTSG/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# MNTSG - -We propose MN-TSG, a framework that explores MOE (Mixture of Experts)-NCDE and integrates it with existing TSG models for irregular or continuous TSG tasks. The key designs of MOE-NCDE are the dynamic functions with mixture of experts and the decoupled design to better optimize the MOE dynamics. Further, we employ the existing TSG model to learn the joint distribution of the mixture of experts and the time series. In this way, the model can not only generate new samples but also produce suitable experts for them to enable MOE-NCDE for refined continuous TSG tasks. - - - -## Environment -Install the environment from the yaml file given here: environment_mntsg.yml - -```bash -conda env create -f environment.yml --force --no-deps -``` - -## Data -Stocks and Energy data are located in /datasets. Sine, MuJoCo, polynomial datasets are generated and the scripts are included in datasets folder. -utils_data.py contains functions to load the data both in regular and irregular setups. Specifically, the irregular data is pre-processed by the TimeDataset_irregular class, -and it might take a while. Once the data pre-processing is done, it is saved in the /datasets folder. - - -## Reproducing the paper results -By setting the time series length and missing values within the script, the results in the paper can be reproduced: - - -**Step1:** The MOE NeuralCDE can be trained by `run_irregular_moencde.py`. - ---- - -**Step2:** The training of the joint distribution of MOE expert weights and time series samples can be implemented through script `run_mntsg_diffsuion.py`. - ---- - -**Step3:** By using the initially trained MOE-NeuralCDE, each newly generated sample, and the corresponding generated MOE weights, fine-grained and refined continuous time series generation can be achieved through script `run_irregular_moencde_continues.py`, thereby enhancing the accuracy of downstream tasks with richer temporal information.