Contents

20260203 meeting

Background

This experiment uses the Weather2K dataset, identical to prior work, and evaluates whether, during the training process of $SSSD^{S4}$, the predicted value epsilon_theta should pass through $autoFRK$ again before being output.

sssd/training/utils.py training_loss

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# New: Integrate AutoFRK for spatial prediction
if enable_frk and loc is not None:
    temp = epsilon_theta.permute(1, 0, 2)
    #print(f"temp shape: {temp.shape}")
    epsilon_theta_fused = torch.zeros_like(epsilon_theta)
    #print(f"epsilon_theta_fused shape: {epsilon_theta_fused.shape}")
    for i in range(temp.shape[0]):
        success = False
        while not success:
            try:
                df = temp[i] + 1e-8 * torch.randn_like(temp[i])
                #print(f"df shape: {df.shape}")
                #print(f"loc shape: {loc.shape}")
                frk_model = AutoFRK(device=df.device, dtype=df.dtype, logger_level=30)
                frk_model.forward(data=df, loc=loc, requires_grad=True)
                pred_res = frk_model.predict(newloc=loc)
                frk_pred = pred_res['pred.value']
                epsilon_theta_fused[:, i, :] = frk_pred
                success = True  # successful and exit loop
            except Exception as e:
                LOGGER.warning(f"Failed to process record {i}. Retrying. Error: {e}")
elif enable_frk and loc is None:
    raise ValueError("Location data must be provided when enable_frk is True.")
else:
    epsilon_theta_fused = epsilon_theta

# Compute loss
if generate_only_missing:
    loss = loss_function(epsilon_theta_fused[loss_mask], noise[loss_mask])
else:
    loss = loss_function(epsilon_theta_fused, noise)

The input dataset has shape (locations, time, variables). After loading, the time-series dimension (2nd dimension) is standardized. The location coordinates used by $autoFRK$ have shape (n, coords), where coords $\in$ {1, 2, 3}. Here, latitude and longitude are used, i.e., (n, 2).

At the end of the experiment, to verify whether spatial standardization affects the imputation results of $autoFRK$, additional experiments are conducted by first restoring the time series, standardizing only the spatial coordinates, applying $autoFRK$, and finally restoring the data back to the original scale.

sssd/inference/generator.py DiffusionGenerator.generate()

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
if self.enable_spatial_prediction:

    # new feature for this chunk
    sp_mean = sssd_inference.mean(dim=0, keepdim=True)
    sp_std = sssd_inference.std(dim=0, unbiased=False, keepdim=True)
    sssd_inference = (sssd_inference - sp_mean) / sp_std

    autoFRK_inference = self._autoFRK_generate(
        sssd_inference = sssd_inference,
        with_known_loc = True
    )

    # new feature for this chunk
    autoFRK_inference = autoFRK_inference * sp_std + sp_mean

    results = {'imputation': autoFRK_inference.detach().cpu().numpy()}
else:
    results = {'imputation': sssd_inference.detach().cpu().numpy()}
self._save_data(results, 0)

Naming Scheme

Experiments are named using the format XXX-XXXX-XX, where XXX means whether $autoFRK$ is used during training; XXXX for number of training iterations; XX means whether spatial standardization is applied. For example, NoFRK-4000-NoSP means no $autoFRK$ during training, 4,000 iterations, no spatial normalization during inference.

Time-Series Distortion Issue

After a full inspection of the code, no abnormality was found. Thus, the earlier distortion in time-series prediction is suspected to originate from S4 layer parameter settings. The following modifications are applied:

model.yaml

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
wavenet:
  # WaveNet model parameters
  input_channels: 8  # Number of input channels
  output_channels: 8  # Number of output channels
  residual_layers: 20  # Number of residual layers
  residual_channels: 64  # Number of channels in residual blocks
  skip_channels: 64  # Number of channels in skip connections

  # Diffusion step embedding dimensions
  diffusion_step_embed_dim_input: 128  # Input dimension
  diffusion_step_embed_dim_hidden: 256  # Middle dimension
  diffusion_step_embed_dim_output: 256  # Output dimension

  # Structured State Spaces sequence model (S4) configurations
  s4_max_sequence_length: 986  # Maximum sequence length
  s4_state_dim: 128  # State dimension
  s4_dropout: 0.1  # Dropout rate
  s4_bidirectional: true  # Whether to use bidirectional layers
  s4_use_layer_norm: true  # Whether to use layer normalization

diffusion:
  # Diffusion model parameters
  T: 500  # Number of diffusion steps
  beta_0: 0.0008  # Initial beta value
  beta_T: 0.08  # Final beta value

To improve temporal prediction accuracy, the main adjustment increases s4_state_dim, making it larger than residual_layers, and introduces s4_dropout = 0.1 instead of 0.0. The intuition is that dropout may improve robustness to missing values. Future work may further increase s4_state_dim, s4_dropout, and the number of iterations.

To understand whether diffusion hyperparameters impact performance, two settings are tested:

  • T200beta_00.0001beta_T0.01

    • T: 200
    • beta_0: 0.0001
    • beta_T: 0.01
  • T500beta_00.0008beta_T0.08

    • T: 500
    • beta_0: 0.0008
    • beta_T: 0.08

These two settings aim to provide direction for model tuning.

training.yaml

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Training configuration
batch_size: 50  # Batch size
output_directory: "/home/u6025091/SSSD_CP/results/Weather2k-fast-rectangular"  # Output directory for checkpoints and logs
ckpt_iter: "max"  # Checkpoint mode (max or min)
iters_per_ckpt: 500  # Checkpoint frequency (number of epochs)
iters_per_logging: 200  # Log frequency (number of iterations)
n_iters: 38000  # Maximum number of iterations
learning_rate: 0.0005  # Learning rate

# Additional training settings
only_generate_missing: true  # Generate missing values only
use_model: 2  # Model to use for training
masking: "forecast"  # Masking strategy for missing values
missing_k: 33  # Number of missing values

# Data paths
data:
  train_path: "/home/u6025091/SSSD_CP/datasets/Weather2k/data_train_known_real.npy"  # Path to training data

# autoFRK config
enable_spatial_training: false  # Enable spatial training step
location_path: "/home/u6025091/SSSD_CP/datasets/Weather2k/stations_known_locations.npy"  # Path to known locations
AFRK_method: "fast"  # waitting for adding into the model
AFRK_tps_method: "rectangular"  # waitting for adding into the model

inference.yaml

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Inference configuration
batch_size: 50  # Batch size for inference
output_directory: "/home/u6025091/SSSD_CP/results/Weather2k-fast-rectangular/inference"  # Output directory for inference results
ckpt_path: "/home/u6025091/SSSD_CP/results/Weather2k-fast-rectangular"  # Path to checkpoint for inference
trials: 1 # Replications

# Additional training settings
only_generate_missing: true  # Generate missing values only
use_model: 2  # Model to use for training
masking: "forecast"  # Masking strategy for missing values
missing_k: 33  # Number of missing values

# Data paths
data:
  test_path: "/home/u6025091/SSSD_CP/datasets/Weather2k/data_test_missing.npy"  # Path to test data

# autoFRK config
enable_spatial_inference: true  # Enable spatial prediction step
known_location_path: "/home/u6025091/SSSD_CP/datasets/Weather2k/stations_known_locations.npy"  # Path to known locations
unknown_location_path: "/home/u6025091/SSSD_CP/datasets/Weather2k/stations_unknown_locations.npy"  # Path to unknown locations
AFRK_method: "fast"
AFRK_tps_method: "rectangular"

Both files contain autoFRK configuration. In future work, AFRK_method and AFRK_tps_method should be merged into model.yaml for unified configuration. In training.yaml, these two parameters are not yet adjustable and currently always use prediction values; this should be corrected later.

T200beta_00.0001beta_T0.01

FRK-4000-SP

ALL Locs & All TimeKnown Locs & All TimeUnknown Locs & All TimeALL Locs & FutureKnown Locs & FutureUnknown Locs & FutureALL Locs & PastKnown Locs & PastUnknown Locs & Past
MSPE3.673955e+001.0446962.69138511.6928193.4823214.2168172.372992e-014.597242e-082.037628
RMSPE1.916756e+001.0221041.6405443.4194761.8660982.0534894.871336e-012.144118e-041.427455
MSPE%4.622483e+080.0378580.0997240.6272270.1261930.1580126.603546e+082.081493e-090.074743
RMSPE%2.149996e+040.1945710.3157910.7919770.3552370.3975072.569737e+044.562338e-050.273392
MAPE8.162235e-010.4497981.1453632.5355521.4989691.4271237.936824e-021.531350e-041.024609
MAPE%7.451615e+070.0163510.0412990.1256510.0544870.0512971.064516e+086.598459e-060.037015

FRK-4000-NoSP

ALL Locs & All TimeKnown Locs & All TimeUnknown Locs & All TimeALL Locs & FutureKnown Locs & FutureUnknown Locs & FutureALL Locs & PastKnown Locs & PastUnknown Locs & Past
MSPE3.683970e+001.0767512.56066711.7148673.5891694.0423102.421567e-016.761885e-081.925678
RMSPE1.919367e+001.0376661.6002093.4226991.8945102.0105504.920942e-012.600363e-041.387688
MSPE%5.535801e+080.0390820.0925550.6289240.1302730.1483567.908287e+083.082764e-090.068640
RMSPE%2.352828e+040.1976910.3042280.7930480.3609330.3851702.812168e+045.552264e-050.261992
MAPE8.178309e-010.4612131.1044912.5396161.5370051.4246047.992314e-021.600120e-040.967299
MAPE%8.074776e+070.0167660.0391640.1257620.0558700.0504491.153539e+086.924418e-060.034328

NoFRK-4000-SP

ALL Locs & All TimeKnown Locs & All TimeUnknown Locs & All TimeALL Locs & FutureKnown Locs & FutureUnknown Locs & FutureALL Locs & PastKnown Locs & PastUnknown Locs & Past
MSPE3.913162e+000.9521132.77369912.4806333.1661374.5127712.413884e-010.0032452.028383
RMSPE1.978171e+000.9757631.6654433.5327941.7793642.1243284.913130e-010.0569681.424213
MSPE%4.778024e+080.0347270.1030890.6835270.1154520.1699126.825749e+080.0001310.074450
RMSPE%2.185869e+040.1863520.3210740.8267570.3397830.4122042.612613e+040.0114360.272855
MAPE8.732765e-010.4488291.1693942.6214751.3911521.5103151.240487e-010.0449761.023285
MAPE%7.806765e+070.0165140.0422640.1314710.0507830.0546261.115252e+080.0018270.036966

NoFRK-4000-NoSP

ALL Locs & All TimeKnown Locs & All TimeUnknown Locs & All TimeALL Locs & FutureKnown Locs & FutureUnknown Locs & FutureALL Locs & PastKnown Locs & PastUnknown Locs & Past
MSPE3.942854e+000.9477103.33311812.5162423.1511535.1881182.685454e-010.0033772.538118
RMSPE1.985662e+000.9735041.8256833.5378301.7751492.2777445.182137e-010.0581091.593147
MSPE%6.130173e+080.0345900.1209540.6850740.1149830.1909498.757390e+080.0001370.090956
RMSPE%2.475919e+040.1859850.3477850.8276920.3390910.4369782.959289e+040.0116870.301589
MAPE8.781141e-010.4468071.3105922.6246471.3824121.6355971.296001e-010.0458331.171304
MAPE%8.724114e+070.0164650.0466930.1315660.0505270.0582641.246302e+080.0018660.041733

T500beta_00.0008beta_T0.08

FRK-4000-SP

ALL Locs & All TimeKnown Locs & All TimeUnknown Locs & All TimeALL Locs & FutureKnown Locs & FutureUnknown Locs & FutureALL Locs & PastKnown Locs & PastUnknown Locs & Past
MSPE3.623991e+001.0835292.48759611.5457503.6117593.6210182.289513e-012.038718e-062.001843
RMSPE1.903678e+001.0409271.5772113.3979041.9004631.9028974.784885e-011.427837e-031.414865
MSPE%3.975542e+080.0395860.0909900.6167650.1319530.1345225.679346e+089.251824e-080.072333
RMSPE%1.993876e+040.1989620.3016450.7853440.3632540.3667732.383138e+043.041681e-040.268947
MAPE8.185870e-010.4478911.1053512.5421921.4903101.3251187.989899e-021.140664e-031.011165
MAPE%6.858757e+070.0163390.0394400.1253690.0543500.0471749.798224e+074.903483e-050.036126

FRK-4000-NoSP

ALL Locs & All TimeKnown Locs & All TimeUnknown Locs & All TimeALL Locs & FutureKnown Locs & FutureUnknown Locs & FutureALL Locs & PastKnown Locs & PastUnknown Locs & Past
MSPE3.658965e+000.9661373.05832011.6095903.2204524.7992632.515544e-012.038718e-062.312201
RMSPE1.912842e+000.9829231.7488053.4072851.7945622.1907225.015520e-011.427837e-031.520592
MSPE%5.324177e+080.0353670.1115540.6192980.1178880.1769987.605967e+089.251824e-080.083506
RMSPE%2.307418e+040.1880600.3339960.7869550.3433490.4207112.757892e+043.041681e-040.288974
MAPE8.238042e-010.4297661.2546552.5517951.4298921.5779628.323673e-021.140664e-031.116094
MAPE%7.873417e+070.0156840.0448450.1257260.0521640.0563131.124774e+084.903483e-050.039930

NoFRK-4000-SP

ALL Locs & All TimeKnown Locs & All TimeUnknown Locs & All TimeALL Locs & FutureKnown Locs & FutureUnknown Locs & FutureALL Locs & PastKnown Locs & PastUnknown Locs & Past
MSPE3.949662e+001.0471182.77268412.5558503.4419944.5116092.612950e-010.0207432.027430
RMSPE1.987376e+001.0232881.6651383.5434241.8552612.1240555.111702e-010.1440231.423879
MSPE%4.903674e+080.0388520.1030590.6855410.1275530.1696497.005249e+080.0008370.074521
RMSPE%2.214424e+040.1971090.3210280.8279740.3571460.4118842.646743e+040.0289380.272985
MAPE9.255151e-010.5219301.1697302.6311511.4685951.5097871.945285e-010.1162161.023991
MAPE%8.165531e+070.0194740.0422670.1319050.0539170.0545541.166504e+080.0047120.037001

NoFRK-4000-NoSP

ALL Locs & All TimeKnown Locs & All TimeUnknown Locs & All TimeALL Locs & FutureKnown Locs & FutureUnknown Locs & FutureALL Locs & PastKnown Locs & PastUnknown Locs & Past
MSPE3.950400e+001.0192672.68463612.5372923.3484974.4169782.703033e-010.0210261.942204
RMSPE1.987561e+001.0095881.6384863.5408041.8298902.1016615.199070e-010.1450021.393630
MSPE%6.183450e+080.0379560.0982160.6867960.1245340.1641168.833500e+080.0008500.069974
RMSPE%2.486654e+040.1948220.3133950.8287310.3528940.4051132.972120e+040.0291600.264525
MAPE9.257683e-010.5170471.1587092.6291341.4493431.5293621.957544e-010.1174920.999858
MAPE%9.063959e+070.0193320.0415420.1318960.0533250.0549031.294851e+080.0047640.035816

Conclusion

Diffusion Steps and Parameter Adjustments (T500 vs T200)

Experimental results indicate that moderately increasing the diffusion steps T and tuning the beta parameters have a significant impact on the stability of future predictions:

  • Improved Prediction Accuracy: In the evaluation of Unknown Locs & Future, the T500 configuration (T500-beta_0.0008) demonstrates better convergence compared to T200. For example, under the FRK-4000-SP setup, the MSPE of T500 is 3.621, outperforming T200’s 4.217.

  • Better Future Trend Modeling: The increase in s4_state_dim (128) along with s4_dropout (0.1) effectively mitigates the temporal distortion observed in earlier versions. These adjustments enhance the model’s generalization capability for future unseen segments.

Contribution of FRK Spatial Imputation to Unknown Locations

Across both known and unknown locations, FRK spatial imputation does not exhibit large differences. The best MSPE appears in the T500beta_0.0008beta_T0.08 – FRK-4000-SP configuration, while the worst MSPE similarly appears in the T500beta_0.0008beta_T0.08 – FRK-4000-NoSP configuration.

This suggests that while FRK contributes meaningfully to spatial consistency, its effectiveness is sensitive to preprocessing choices, particularly spatial normalization.

Spatial Standardization (SP)

Spatial standardization shows mild instability in this experiment. Results differ notably between T500 and T200 configurations, indicating that SP may introduce additional variance and does not consistently enhance model performance.

References

  • Zhu X, Xiong Y, Wu M, et al. Weather2K: A Multivariate Spatio-Temporal Benchmark Dataset for Meteorological Forecasting Based on Real-Time Observation Data from Ground Weather Stations[C]//International Conference on Artificial Intelligence and Statistics. PMLR, 2023: 2704-2722.
  • Juan Lopez Alcaraz, Nils Strodthoff (2022). Diffusion-based time series imputation and forecasting with structured state space models. Transactions on Machine Learning Research. Retrieved from https://openreview.net/forum?id=hHiIbk7ApW
  • SSSD (2022). GitHub. Retrieved from https://github.com/AI4HealthUOL/SSSD