|
|
""" |
|
|
Configuration settings for the trajectory interpolation project. |
|
|
|
|
|
This file defines a function `load_config()` which returns a dictionary |
|
|
containing various parameters grouped by their purpose (e.g., data, model, |
|
|
diffusion, training, sampling). |
|
|
""" |
|
|
from types import SimpleNamespace |
|
|
import torch |
|
|
|
|
|
def load_config(): |
|
|
config_args = { |
|
|
'data': { |
|
|
'traj_length': 256, |
|
|
'dataset': 'TKY_temporal', |
|
|
'traj_path1': './data/', |
|
|
'num_workers': 16, |
|
|
}, |
|
|
'train': { |
|
|
'batch_size': 512, |
|
|
'n_epochs': 50, |
|
|
'n_iters': 5000000, |
|
|
'snapshot_freq': 5000, |
|
|
'validation_freq': 5, |
|
|
'dis_gpu': False, |
|
|
}, |
|
|
'trans': { |
|
|
'input_dim': 3, |
|
|
'embed_dim': 512, |
|
|
'num_layers': 4, |
|
|
'num_heads': 8, |
|
|
'forward_dim': 256, |
|
|
'dropout': 0.1, |
|
|
'N_CLUSTER': 20, |
|
|
}, |
|
|
'test': { |
|
|
'batch_size': 256, |
|
|
'last_only': True, |
|
|
}, |
|
|
'diffusion': { |
|
|
'beta_schedule': 'linear', |
|
|
'beta_start': 0.0001, |
|
|
'beta_end': 0.05, |
|
|
'num_diffusion_timesteps': 500, |
|
|
}, |
|
|
'model': { |
|
|
'type': "simple", |
|
|
'attr_dim': 8, |
|
|
'guidance_scale': 2, |
|
|
'in_channels': 3, |
|
|
'out_ch': 3, |
|
|
'ch': 128, |
|
|
'ch_mult': [1, 2, 2, 2], |
|
|
'num_res_blocks': 2, |
|
|
'attn_resolutions': [16], |
|
|
'dropout': 0.1, |
|
|
'var_type': 'fixedlarge', |
|
|
'resamp_with_conv': True, |
|
|
}, |
|
|
'data_source': 'TKY', |
|
|
'data_dir': './data/TKY/manually_split/', |
|
|
'normalization_params_file': './data/TKY/normalization_params.json', |
|
|
} |
|
|
|
|
|
|
|
|
config = SimpleNamespace() |
|
|
config.training = SimpleNamespace(**config_args['train']) |
|
|
config.test = SimpleNamespace(**config_args['test']) |
|
|
config.diffusion = SimpleNamespace(**config_args['diffusion']) |
|
|
config.model = SimpleNamespace(**config_args['model']) |
|
|
config.sampling = SimpleNamespace(**config_args['test']) |
|
|
|
|
|
config.sampling.type = 'ddim' |
|
|
config.sampling.ddim_steps = 50 |
|
|
config.sampling.ddim_eta = 0.0 |
|
|
config.data = SimpleNamespace(**config_args['data']) |
|
|
config.trans = SimpleNamespace(**config_args['trans']) |
|
|
|
|
|
config.device = 'cuda' if torch.cuda.is_available() else 'cpu' |
|
|
config.masking_strategy = 'multi_segment' |
|
|
config.mask_segments = [60, 60] |
|
|
config.mask_ratio = 0.2 |
|
|
config.mask_points_per_hour = 60 |
|
|
config.z_score_normalization = False |
|
|
config.dis_gpu = False |
|
|
|
|
|
|
|
|
config.learning_rate = 1.5e-4 |
|
|
config.batch_size = config_args['train']['batch_size'] |
|
|
config.n_epochs = config_args['train']['n_epochs'] |
|
|
config.validation_freq = config_args['train']['validation_freq'] |
|
|
config.warmup_epochs = 5 |
|
|
config.contrastive_margin = 1.0 |
|
|
config.kmeans_memory_size = 15 |
|
|
config.contrastive_loss_weight = 0.1 |
|
|
config.ce_loss_weight = 0.1 |
|
|
config.diffusion_loss_weight = 1.0 |
|
|
config.device_id = 0 |
|
|
config.use_amp = True |
|
|
config.normalization_params_file = config_args['normalization_params_file'] |
|
|
config.data_source = config_args['data_source'] |
|
|
config.data_dir = config_args['data_dir'] |
|
|
config.traj_length = config_args['data']['traj_length'] |
|
|
|
|
|
return config |