easylearning commited on
Commit
1ee2b6d
·
verified ·
1 Parent(s): 61e4226

Upload 44 files

Browse files
Files changed (44) hide show
  1. Exp1_Global_weather_forecasting/.DS_Store +0 -0
  2. Exp1_Global_weather_forecasting/checkpoints/.DS_Store +0 -0
  3. Exp1_Global_weather_forecasting/checkpoints/baselines_Fuxi_exp4_1105_best_model.pth +3 -0
  4. Exp1_Global_weather_forecasting/checkpoints/baselines_Pangu_exp_1101_best_model.pth +3 -0
  5. Exp1_Global_weather_forecasting/checkpoints/checkpoint.md +1 -0
  6. Exp1_Global_weather_forecasting/checkpoints/triton_weather_20250326_v1_best_model.pth +3 -0
  7. Exp1_Global_weather_forecasting/dataloader_api/dataloader.py +159 -0
  8. Exp1_Global_weather_forecasting/inference.py +230 -0
  9. Exp1_Global_weather_forecasting/logs/baselines_Pangu_exp_1101_training_log.log +1009 -0
  10. Exp1_Global_weather_forecasting/logs/triton_weather_20250326_v1.log +0 -0
  11. Exp1_Global_weather_forecasting/model/Triton_model.py +516 -0
  12. Exp1_Global_weather_forecasting/model_baselines/fuxi_model.py +242 -0
  13. Exp1_Global_weather_forecasting/model_baselines/pangu_model.py +1218 -0
  14. Exp1_Global_weather_forecasting/plt_triton/.DS_Store +0 -0
  15. Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/.DS_Store +0 -0
  16. Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2018/.DS_Store +0 -0
  17. Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2018/Fuxi_210.npy +3 -0
  18. Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2018/Pangu_210.npy +3 -0
  19. Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2018/SFNO_210.npy +3 -0
  20. Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2018/Triton_210_day.npy +3 -0
  21. Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2018/groundtruth_210.npy +3 -0
  22. Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2018/initial_input.npy +3 -0
  23. Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2018/vis.ipynb +0 -0
  24. Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/.DS_Store +0 -0
  25. Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_initial_input.npy +3 -0
  26. Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_prediction_step_0.npy +3 -0
  27. Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_prediction_step_13.npy +3 -0
  28. Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_prediction_step_179.npy +3 -0
  29. Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_prediction_step_2.npy +3 -0
  30. Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_prediction_step_29.npy +3 -0
  31. Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_prediction_step_4.npy +3 -0
  32. Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_prediction_step_6.npy +3 -0
  33. Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_prediction_step_9.npy +3 -0
  34. Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_true_label_step_0.npy +3 -0
  35. Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_true_label_step_13.npy +3 -0
  36. Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_true_label_step_179.npy +3 -0
  37. Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_true_label_step_2.npy +3 -0
  38. Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_true_label_step_29.npy +3 -0
  39. Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_true_label_step_4.npy +3 -0
  40. Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_true_label_step_6.npy +3 -0
  41. Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_true_label_step_9.npy +3 -0
  42. Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/vis_triton_weather.ipynb +0 -0
  43. Exp1_Global_weather_forecasting/results_2018/vis_2018.ipynb +0 -0
  44. Exp1_Global_weather_forecasting/train.py +203 -0
Exp1_Global_weather_forecasting/.DS_Store ADDED
Binary file (8.2 kB). View file
 
Exp1_Global_weather_forecasting/checkpoints/.DS_Store ADDED
Binary file (6.15 kB). View file
 
Exp1_Global_weather_forecasting/checkpoints/baselines_Fuxi_exp4_1105_best_model.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1245b58a1561f3780c520d472d1963e2a4b435014af1895c79835a041c81012a
3
+ size 2651148796
Exp1_Global_weather_forecasting/checkpoints/baselines_Pangu_exp_1101_best_model.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:02f4c1efa18f39d4e36faacacbfb4836e616a8f5d8f09c84e813ae0e28c54248
3
+ size 213092916
Exp1_Global_weather_forecasting/checkpoints/checkpoint.md ADDED
@@ -0,0 +1 @@
 
 
1
+ download from https://huggingface.co/easylearning/Triton_Earth_V1/tree/main
Exp1_Global_weather_forecasting/checkpoints/triton_weather_20250326_v1_best_model.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f9b180ca01e99be49e74263245200d9d1119b11c26a3b5bebee09675e7b4b1da
3
+ size 112341818
Exp1_Global_weather_forecasting/dataloader_api/dataloader.py ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import netCDF4 as nc
3
+ import torch
4
+ import torch.utils.data as data
5
+
6
+ class train_Dataset(data.Dataset):
7
+ def __init__(self, args):
8
+ super(train_Dataset, self).__init__()
9
+ self.args = args
10
+ self.years = range(1993, 2018)
11
+ self.dates = range(12, 357, 3)
12
+ self.indices = []
13
+
14
+ for m in self.years:
15
+ train_data = nc.Dataset(f'{self.args["data_path"]}/{m}_norm.nc')
16
+ max_time_index = train_data.variables['atmosphere_variables'].shape[0] - 1
17
+ train_data.close()
18
+
19
+ for n in self.dates:
20
+ input_start = n - self.args['atmosphere_lead_time'] + 1
21
+ target_end = n + self.args['ocean_lead_time'] + 1
22
+
23
+ if input_start >= 0 and target_end <= max_time_index:
24
+ self.indices.append((m, n))
25
+
26
+ def __getitem__(self, index):
27
+ year, date = self.indices[index]
28
+ train_data = nc.Dataset(f'{self.args["data_path"]}/{year}_norm.nc')
29
+
30
+ # Calculate indices
31
+ input_start = date - self.args['atmosphere_lead_time'] + 1
32
+ input_end = date + 1
33
+ target_start = date + 1
34
+ target_end = date + self.args['ocean_lead_time'] + 1
35
+
36
+ # Load input data
37
+ input = train_data.variables['atmosphere_variables'][
38
+ input_start:input_end,
39
+ self.args['variables_input'],
40
+ self.args['lat_start']:self.args['lat_end']:self.args['ds_factor'],
41
+ self.args['lon_start']:self.args['lon_end']:self.args['ds_factor']
42
+ ]
43
+
44
+ # Load target data
45
+ target = train_data.variables['atmosphere_variables'][
46
+ target_start:target_end,
47
+ self.args['variables_output'],
48
+ self.args['lat_start']:self.args['lat_end']:self.args['ds_factor'],
49
+ self.args['lon_start']:self.args['lon_end']:self.args['ds_factor']
50
+ ]
51
+
52
+ train_data.close() # Close the dataset after use
53
+
54
+ # Convert to tensors and handle NaNs
55
+ input = torch.tensor(input, dtype=torch.float32)
56
+ target = torch.tensor(target, dtype=torch.float32)
57
+ input = torch.nan_to_num(input, nan=0.0)
58
+ target = torch.nan_to_num(target, nan=0.0)
59
+
60
+ # Ensure matching time dimensions
61
+ min_time_steps = min(input.shape[0], target.shape[0])
62
+ input = input[:min_time_steps]
63
+ target = target[:min_time_steps]
64
+
65
+ return input, target
66
+
67
+ def __len__(self):
68
+ return len(self.indices)
69
+
70
+ class test_Dataset(data.Dataset):
71
+ def __init__(self, args):
72
+ super(test_Dataset, self).__init__()
73
+ self.args = args
74
+ self.years = range(2018, 2022)
75
+ self.dates = range(12, 357, 3)
76
+ self.indices = []
77
+
78
+ # Build valid indices to avoid out-of-bounds errors
79
+ for m in self.years:
80
+ test_data = nc.Dataset(f'{self.args["data_path"]}/{m}_norm.nc')
81
+ max_time_index = test_data.variables['atmosphere_variables'].shape[0] - 1 # Adjust for zero-based indexing
82
+ test_data.close() # Close the dataset after use
83
+
84
+ for n in self.dates:
85
+ input_start = n - self.args['atmosphere_lead_time'] + 1
86
+ target_end = n + self.args['ocean_lead_time'] + 1
87
+
88
+ # Ensure indices are within bounds
89
+ if input_start >= 0 and target_end <= max_time_index:
90
+ self.indices.append((m, n))
91
+
92
+ def __getitem__(self, index):
93
+ year, date = self.indices[index]
94
+ test_data = nc.Dataset(f'{self.args["data_path"]}/{year}_norm.nc')
95
+
96
+ # Calculate indices
97
+ input_start = date - self.args['atmosphere_lead_time'] + 1
98
+ input_end = date + 1
99
+ target_start = date + 1
100
+ target_end = date + self.args['ocean_lead_time'] + 1
101
+
102
+ # Load input data
103
+ input = test_data.variables['atmosphere_variables'][
104
+ input_start:input_end,
105
+ self.args['variables_input'],
106
+ self.args['lat_start']:self.args['lat_end']:self.args['ds_factor'],
107
+ self.args['lon_start']:self.args['lon_end']:self.args['ds_factor']
108
+ ]
109
+
110
+ # Load target data
111
+ target = test_data.variables['atmosphere_variables'][
112
+ target_start:target_end,
113
+ self.args['variables_output'],
114
+ self.args['lat_start']:self.args['lat_end']:self.args['ds_factor'],
115
+ self.args['lon_start']:self.args['lon_end']:self.args['ds_factor']
116
+ ]
117
+
118
+ test_data.close() # Close the dataset after use
119
+
120
+ # Convert to tensors and handle NaNs
121
+ input = torch.tensor(input, dtype=torch.float32)
122
+ target = torch.tensor(target, dtype=torch.float32)
123
+ input = torch.nan_to_num(input, nan=0.0)
124
+ target = torch.nan_to_num(target, nan=0.0)
125
+
126
+ # Ensure matching time dimensions
127
+ min_time_steps = min(input.shape[0], target.shape[0])
128
+ input = input[:min_time_steps]
129
+ target = target[:min_time_steps]
130
+
131
+ return input, target
132
+
133
+ def __len__(self):
134
+ return len(self.indices)
135
+
136
+ if __name__ == '__main__':
137
+ args = {
138
+ 'data_path': '/jizhicfs/easyluwu/scaling_law/ft_local/low_res',
139
+ 'ocean_lead_time': 1,
140
+ 'atmosphere_lead_time': 1,
141
+ 'shuffle': True,
142
+ 'variables_input': list(range(69)),
143
+ 'variables_output': list(range(69)),
144
+ 'lon_start': 0,
145
+ 'lat_start': 0,
146
+ 'lon_end': 1440,
147
+ 'lat_end': 720,
148
+ 'ds_factor': 1,
149
+ }
150
+
151
+ train_dataset = train_Dataset(args)
152
+ test_dataset = test_Dataset(args)
153
+
154
+ train_loader = data.DataLoader(train_dataset, batch_size=1)
155
+ test_loader = data.DataLoader(test_dataset, batch_size=1)
156
+
157
+ for inputs, targets in iter(train_loader):
158
+ print(inputs.shape, targets.shape)
159
+ break
Exp1_Global_weather_forecasting/inference.py ADDED
@@ -0,0 +1,230 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import random
3
+ import torch
4
+ import numpy as np
5
+ import torch.nn as nn
6
+ from torch.utils.data import Dataset, DataLoader
7
+ import netCDF4 as nc
8
+ import logging
9
+ import argparse
10
+ from tqdm import tqdm
11
+ from collections import OrderedDict
12
+
13
+ years = 2018
14
+ # ==========================================
15
+ # dataset
16
+ # ==========================================
17
+ class TestInferenceDataset(Dataset):
18
+ def __init__(self, args, target_year, target_date):
19
+ super(TestInferenceDataset, self).__init__()
20
+ self.args = args
21
+ self.target_year = target_year
22
+ self.target_date = target_date
23
+
24
+ self.data_path = os.path.join(self.args["data_path"], f'{self.target_year}_norm.nc')
25
+ self.dataset = nc.Dataset(self.data_path)
26
+ self.atm_vars = self.dataset.variables['atmosphere_variables']
27
+ self.max_time_index = self.atm_vars.shape[0]
28
+
29
+ self.initial_time = self.target_date
30
+ if self.initial_time >= self.max_time_index:
31
+ raise ValueError("Initial time index exceeds data range.")
32
+
33
+ self.rollout_steps = args['rollout_steps']
34
+ self.true_labels = []
35
+ for step in range(self.rollout_steps):
36
+ time_index = self.initial_time + step + 1
37
+ if time_index >= self.max_time_index:
38
+ break
39
+ true_label = self.atm_vars[
40
+ time_index,
41
+ self.args['variables_output'],
42
+ self.args['lat_start']:self.args['lat_end']:self.args['ds_factor'],
43
+ self.args['lon_start']:self.args['lon_end']:self.args['ds_factor']
44
+ ]
45
+ true_label = torch.tensor(true_label, dtype=torch.float32)
46
+ true_label = torch.nan_to_num(true_label, nan=0.0)
47
+ self.true_labels.append(true_label)
48
+
49
+ self.initial_input = self.atm_vars[
50
+ self.initial_time,
51
+ self.args['variables_input'],
52
+ self.args['lat_start']:self.args['lat_end']:self.args['ds_factor'],
53
+ self.args['lon_start']:self.args['lon_end']:self.args['ds_factor']
54
+ ]
55
+ self.initial_input = torch.tensor(self.initial_input, dtype=torch.float32)
56
+ self.initial_input = torch.nan_to_num(self.initial_input, nan=0.0)
57
+
58
+ self.dataset.close()
59
+
60
+ def __len__(self):
61
+ return 1
62
+
63
+ def __getitem__(self, index):
64
+ return self.initial_input, self.true_labels
65
+
66
+ # ==========================================
67
+ # define model
68
+ # ==========================================
69
+ from model.Triton_model import *
70
+ from model_baselines.fuxi_model import *
71
+ from model_baselines.pangu_model import *
72
+
73
+ def set_seed(seed):
74
+ random.seed(seed)
75
+ np.random.seed(seed)
76
+ torch.manual_seed(seed)
77
+ torch.cuda.manual_seed(seed)
78
+ torch.cuda.manual_seed_all(seed)
79
+ torch.backends.cudnn.deterministic = True
80
+ torch.backends.cudnn.benchmark = False
81
+
82
+ # ==========================================
83
+ # delete "module."
84
+ # ==========================================
85
+ def load_model(model, model_path, device):
86
+ state_dict = torch.load(model_path, map_location=device)
87
+
88
+ new_state_dict = OrderedDict()
89
+ for k, v in state_dict.items():
90
+ if k.startswith("module."):
91
+ new_key = k[7:]
92
+ else:
93
+ new_key = k
94
+ new_state_dict[new_key] = v
95
+
96
+ # load new state_dict
97
+ model.load_state_dict(new_state_dict)
98
+ return model
99
+
100
+ # ==========================================
101
+ # Main inference function
102
+ # ==========================================
103
+ def main():
104
+ # ==========================================
105
+ # Parameter parsing.
106
+ # ==========================================
107
+ parser = argparse.ArgumentParser(description='Incremental Inference')
108
+ parser.add_argument('--start_step', type=int, default=0, help='The initial prediction step starts from 0.')
109
+ args_parsed = parser.parse_args()
110
+
111
+ # ==========================================
112
+ # Parameters seetting
113
+ # ==========================================
114
+ backbone = 'triton_weather_20250326_v1'
115
+ #backbone = 'baselines_Pangu_exp_1101'
116
+ #backbone = 'baselines_Fuxi_exp4_1105'
117
+ args = {
118
+ 'data_path': '/jizhicfs/easyluwu/scaling_law/ft_local/low_res',
119
+ 'variables_input': list(range(69)),
120
+ 'variables_output': list(range(69)),
121
+ 'lon_start': 0,
122
+ 'lat_start': 0,
123
+ 'lon_end': 1440,
124
+ 'lat_end': 720,
125
+ 'ds_factor': 1,
126
+ 'model_path': f'/jizhicfs/easyluwu/ocean_project/NPJ_baselines/Exp_0_Weather/checkpoints/{backbone}_best_model.pth',
127
+ 'results_path': f'/jizhicfs/easyluwu/ocean_project/NPJ_baselines/Exp_0_Weather/results_{years}',
128
+ 'log_path': f'/jizhicfs/easyluwu/ocean_project/NPJ_baselines/Exp_0_Weather/logs//inference_log_{backbone}.log',
129
+ 'backbone': backbone,
130
+ 'start_step': args_parsed.start_step,
131
+ 'rollout_steps': 364,
132
+ }
133
+
134
+ # ==========================================
135
+ # Set logs
136
+ # ==========================================
137
+ os.makedirs(os.path.dirname(args['log_path']), exist_ok=True)
138
+ logging.basicConfig(
139
+ filename=os.path.join(args['log_path']),
140
+ level=logging.INFO,
141
+ format='%(asctime)s %(message)s'
142
+ )
143
+ logging.info(f"The inference script starts running, with the initial step: {args['start_step']}。")
144
+
145
+ seed = 42
146
+ set_seed(seed)
147
+ logging.info(f"The random seed is set to {seed}.")
148
+
149
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
150
+ logging.info(f"The device used is: {device}")
151
+
152
+
153
+ target_year = years
154
+ target_date = 0
155
+
156
+ dataset = TestInferenceDataset(args, target_year, target_date)
157
+ initial_input, true_labels = dataset[0]
158
+
159
+
160
+ model = Triton(
161
+ shape_in=(1, 69, 180, 360),
162
+ spatial_hidden_dim=256,
163
+ output_channels=69,
164
+ temporal_hidden_dim=512,
165
+ num_spatial_layers=4,
166
+ num_temporal_layers=8)
167
+ # model = Pangu(in_shape=(1, 69, 180, 360))
168
+ #model = Fuxi(in_shape=(1, 69, 180, 360))
169
+
170
+
171
+ model = model.to(device)
172
+ if os.path.exists(args['model_path']):
173
+ model = load_model(model, args['model_path'], device)
174
+ logging.info(f"Successfully loaded the model weights: {args['model_path']}")
175
+ else:
176
+ logging.error(f"The model weight file does not exist: {args['model_path']}")
177
+ return
178
+
179
+ model.eval()
180
+
181
+
182
+ os.makedirs(args['results_path'], exist_ok=True)
183
+
184
+ # Save the initial input (only at step 0).
185
+ if args['start_step'] == 0:
186
+ input_data_np = initial_input.cpu().numpy() # shape: [69, H, W]
187
+ np.save(os.path.join(args['results_path'], f'{backbone}_initial_input.npy'), input_data_np)
188
+ logging.info("Initial input has been saved!")
189
+ current_input = initial_input.unsqueeze(0).unsqueeze(0).to(device) # shape: [1, 1, 69, H, W]
190
+ else:
191
+ # Load the prediction result from the previous step as input.
192
+ previous_step = args['start_step'] - 1
193
+ prediction_path = os.path.join(args['results_path'], f"{args['backbone']}_prediction_step_{previous_step}.npy")
194
+ if not os.path.exists(prediction_path):
195
+ raise FileNotFoundError(f"The prediction result file does not exist: {prediction_path}")
196
+ input_data = np.load(prediction_path)
197
+ input_data = torch.from_numpy(input_data).float()
198
+ current_input = input_data.unsqueeze(0).unsqueeze(0).to(device) # shape: [1, 1, 69, H, W]
199
+
200
+ # ==========================================
201
+ # Predict the remaining steps.
202
+ # ==========================================
203
+ total_steps = args['rollout_steps']
204
+ start_step = args['start_step']
205
+
206
+ logging.info(f"Start multi-step prediction, from step {start_step} to step {total_steps - 1}.")
207
+
208
+ for step in tqdm(range(start_step, total_steps), desc="Prediction progress."):
209
+ with torch.no_grad():
210
+ output = model(current_input) # [B, T, C, H, W]
211
+
212
+ output_cpu = output.squeeze(0).squeeze(0).cpu().numpy() # [69, H, W]
213
+ np.save(os.path.join(args['results_path'], f'{backbone}_prediction_step_{step}.npy'), output_cpu)
214
+ logging.info(f"The prediction result for step {step} has been saved.")
215
+
216
+ if step < len(true_labels):
217
+ true_label = true_labels[step]
218
+ true_label_np = true_label.cpu().numpy() # [69, H, W]
219
+ np.save(os.path.join(args['results_path'], f'{backbone}_true_label_step_{step}.npy'), true_label_np)
220
+ logging.info(f"The ground truth for step {step} has been saved.")
221
+
222
+ current_input = output # [B, T, C, H, W]
223
+
224
+ del output, output_cpu
225
+ torch.cuda.empty_cache()
226
+
227
+ logging.info("The inference script has finished running!")
228
+
229
+ if __name__ == '__main__':
230
+ main()
Exp1_Global_weather_forecasting/logs/baselines_Pangu_exp_1101_training_log.log ADDED
@@ -0,0 +1,1009 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 2024-11-01 22:32:47,608 Added key: store_based_barrier_key:1 to store for rank: 4
2
+ 2024-11-01 22:32:47,675 Added key: store_based_barrier_key:1 to store for rank: 6
3
+ 2024-11-01 22:32:47,685 Added key: store_based_barrier_key:1 to store for rank: 3
4
+ 2024-11-01 22:32:47,744 Added key: store_based_barrier_key:1 to store for rank: 2
5
+ 2024-11-01 22:32:47,783 Added key: store_based_barrier_key:1 to store for rank: 1
6
+ 2024-11-01 22:32:47,787 Added key: store_based_barrier_key:1 to store for rank: 7
7
+ 2024-11-01 22:32:47,797 Added key: store_based_barrier_key:1 to store for rank: 0
8
+ 2024-11-01 22:32:47,799 Added key: store_based_barrier_key:1 to store for rank: 5
9
+ 2024-11-01 22:32:58,177 Epoch 1/500
10
+ 2024-11-01 22:36:48,329 Train Loss: 0.3393386, Val Loss: 0.3220887
11
+ 2024-11-01 22:36:48,329 Epoch 2/500
12
+ 2024-11-01 22:39:45,369 Train Loss: 0.2781288, Val Loss: 0.2668692
13
+ 2024-11-01 22:39:45,369 Epoch 3/500
14
+ 2024-11-01 22:42:42,141 Train Loss: 0.2454370, Val Loss: 0.2530480
15
+ 2024-11-01 22:42:42,142 Epoch 4/500
16
+ 2024-11-01 22:45:38,544 Train Loss: 0.2375871, Val Loss: 0.2429137
17
+ 2024-11-01 22:45:38,545 Epoch 5/500
18
+ 2024-11-01 22:48:35,081 Train Loss: 0.2293101, Val Loss: 0.2459308
19
+ 2024-11-01 22:48:35,082 Epoch 6/500
20
+ 2024-11-01 22:51:35,690 Train Loss: 0.2499209, Val Loss: 0.2446073
21
+ 2024-11-01 22:51:35,690 Epoch 7/500
22
+ 2024-11-01 22:55:06,835 Train Loss: 0.2254287, Val Loss: 0.2320574
23
+ 2024-11-01 22:55:06,835 Epoch 8/500
24
+ 2024-11-01 22:58:27,740 Train Loss: 0.2210108, Val Loss: 0.2273720
25
+ 2024-11-01 22:58:27,740 Epoch 9/500
26
+ 2024-11-01 23:01:24,161 Train Loss: 0.2468199, Val Loss: 0.4042651
27
+ 2024-11-01 23:01:24,162 Epoch 10/500
28
+ 2024-11-01 23:04:20,531 Train Loss: 0.2563252, Val Loss: 0.2427646
29
+ 2024-11-01 23:04:20,531 Epoch 11/500
30
+ 2024-11-01 23:08:04,461 Train Loss: 0.2679949, Val Loss: 0.2636970
31
+ 2024-11-01 23:08:04,461 Epoch 12/500
32
+ 2024-11-01 23:11:09,234 Train Loss: 0.2427460, Val Loss: 0.2439406
33
+ 2024-11-01 23:11:09,235 Epoch 13/500
34
+ 2024-11-01 23:14:07,114 Train Loss: 0.2308594, Val Loss: 0.2488305
35
+ 2024-11-01 23:14:07,115 Epoch 14/500
36
+ 2024-11-01 23:17:41,962 Train Loss: 0.2259252, Val Loss: 0.2308795
37
+ 2024-11-01 23:17:41,963 Epoch 15/500
38
+ 2024-11-01 23:20:54,036 Train Loss: 0.2176581, Val Loss: 0.2268587
39
+ 2024-11-01 23:20:54,037 Epoch 16/500
40
+ 2024-11-01 23:23:49,267 Train Loss: 0.2149763, Val Loss: 0.2229864
41
+ 2024-11-01 23:23:49,268 Epoch 17/500
42
+ 2024-11-01 23:26:46,421 Train Loss: 0.2111791, Val Loss: 0.2197903
43
+ 2024-11-01 23:26:46,421 Epoch 18/500
44
+ 2024-11-01 23:30:03,002 Train Loss: 0.2088235, Val Loss: 0.2167981
45
+ 2024-11-01 23:30:03,003 Epoch 19/500
46
+ 2024-11-01 23:33:36,194 Train Loss: 0.2053072, Val Loss: 0.2560215
47
+ 2024-11-01 23:33:36,195 Epoch 20/500
48
+ 2024-11-01 23:36:34,536 Train Loss: 0.2153548, Val Loss: 0.2151310
49
+ 2024-11-01 23:36:34,536 Epoch 21/500
50
+ 2024-11-01 23:39:30,739 Train Loss: 0.2027424, Val Loss: 0.2105217
51
+ 2024-11-01 23:39:30,740 Epoch 22/500
52
+ 2024-11-01 23:43:05,622 Train Loss: 0.1991113, Val Loss: 0.2074818
53
+ 2024-11-01 23:43:05,622 Epoch 23/500
54
+ 2024-11-01 23:46:14,766 Train Loss: 0.1965938, Val Loss: 0.2052977
55
+ 2024-11-01 23:46:14,766 Epoch 24/500
56
+ 2024-11-01 23:49:07,925 Train Loss: 0.1934247, Val Loss: 0.2011687
57
+ 2024-11-01 23:49:07,925 Epoch 25/500
58
+ 2024-11-01 23:52:07,221 Train Loss: 0.1923476, Val Loss: 0.1988174
59
+ 2024-11-01 23:52:07,222 Epoch 26/500
60
+ 2024-11-01 23:55:46,855 Train Loss: 0.1881408, Val Loss: 0.1952849
61
+ 2024-11-01 23:55:46,855 Epoch 27/500
62
+ 2024-11-01 23:58:41,678 Train Loss: 0.1847844, Val Loss: 0.1891340
63
+ 2024-11-01 23:58:41,678 Epoch 28/500
64
+ 2024-11-02 00:01:36,087 Train Loss: 0.1800828, Val Loss: 0.1869565
65
+ 2024-11-02 00:01:36,088 Epoch 29/500
66
+ 2024-11-02 00:04:58,764 Train Loss: 0.1782210, Val Loss: 0.1811197
67
+ 2024-11-02 00:04:58,765 Epoch 30/500
68
+ 2024-11-02 00:08:19,607 Train Loss: 0.1921593, Val Loss: 0.1920962
69
+ 2024-11-02 00:08:19,607 Epoch 31/500
70
+ 2024-11-02 00:11:15,193 Train Loss: 0.1762932, Val Loss: 0.1823277
71
+ 2024-11-02 00:11:15,193 Epoch 32/500
72
+ 2024-11-02 00:14:08,767 Train Loss: 0.1699919, Val Loss: 0.1760677
73
+ 2024-11-02 00:14:08,767 Epoch 33/500
74
+ 2024-11-02 00:17:39,167 Train Loss: 0.1654732, Val Loss: 0.1722326
75
+ 2024-11-02 00:17:39,167 Epoch 34/500
76
+ 2024-11-02 00:20:50,363 Train Loss: 0.1618466, Val Loss: 0.1679600
77
+ 2024-11-02 00:20:50,363 Epoch 35/500
78
+ 2024-11-02 00:23:44,109 Train Loss: 0.1574945, Val Loss: 0.1657941
79
+ 2024-11-02 00:23:44,110 Epoch 36/500
80
+ 2024-11-02 00:26:37,831 Train Loss: 0.1544017, Val Loss: 0.1591567
81
+ 2024-11-02 00:26:37,831 Epoch 37/500
82
+ 2024-11-02 00:30:15,523 Train Loss: 0.1502963, Val Loss: 0.1556753
83
+ 2024-11-02 00:30:15,524 Epoch 38/500
84
+ 2024-11-02 00:33:19,846 Train Loss: 0.1466441, Val Loss: 0.1537005
85
+ 2024-11-02 00:33:19,846 Epoch 39/500
86
+ 2024-11-02 00:36:13,018 Train Loss: 0.1430042, Val Loss: 0.1481737
87
+ 2024-11-02 00:36:13,018 Epoch 40/500
88
+ 2024-11-02 00:39:07,355 Train Loss: 0.1399938, Val Loss: 0.1456805
89
+ 2024-11-02 00:39:07,355 Epoch 41/500
90
+ 2024-11-02 00:42:41,010 Train Loss: 0.1365716, Val Loss: 0.1413665
91
+ 2024-11-02 00:42:41,010 Epoch 42/500
92
+ 2024-11-02 00:45:47,828 Train Loss: 0.1322632, Val Loss: 0.1386961
93
+ 2024-11-02 00:45:47,828 Epoch 43/500
94
+ 2024-11-02 00:48:42,524 Train Loss: 0.1288553, Val Loss: 0.1360033
95
+ 2024-11-02 00:48:42,524 Epoch 44/500
96
+ 2024-11-02 00:51:36,386 Train Loss: 0.1247489, Val Loss: 0.1287927
97
+ 2024-11-02 00:51:36,387 Epoch 45/500
98
+ 2024-11-02 00:55:09,713 Train Loss: 0.1218066, Val Loss: 0.1267299
99
+ 2024-11-02 00:55:09,713 Epoch 46/500
100
+ 2024-11-02 00:58:18,841 Train Loss: 0.1161698, Val Loss: 0.1209997
101
+ 2024-11-02 00:58:18,842 Epoch 47/500
102
+ 2024-11-02 01:01:14,148 Train Loss: 0.1135935, Val Loss: 0.1202596
103
+ 2024-11-02 01:01:14,149 Epoch 48/500
104
+ 2024-11-02 01:04:30,094 Train Loss: 0.1102138, Val Loss: 0.1151412
105
+ 2024-11-02 01:04:30,094 Epoch 49/500
106
+ 2024-11-02 01:07:57,493 Train Loss: 0.1063219, Val Loss: 0.1144434
107
+ 2024-11-02 01:07:57,493 Epoch 50/500
108
+ 2024-11-02 01:10:53,439 Train Loss: 0.1010124, Val Loss: 0.1092527
109
+ 2024-11-02 01:10:53,440 Epoch 51/500
110
+ 2024-11-02 01:13:48,620 Train Loss: 0.0991657, Val Loss: 0.1075171
111
+ 2024-11-02 01:13:48,620 Epoch 52/500
112
+ 2024-11-02 01:17:14,513 Train Loss: 0.0967080, Val Loss: 0.1075075
113
+ 2024-11-02 01:17:14,514 Epoch 53/500
114
+ 2024-11-02 01:20:29,546 Train Loss: 0.0951037, Val Loss: 0.1009655
115
+ 2024-11-02 01:20:29,547 Epoch 54/500
116
+ 2024-11-02 01:23:23,869 Train Loss: 0.0923058, Val Loss: 0.0997770
117
+ 2024-11-02 01:23:23,870 Epoch 55/500
118
+ 2024-11-02 01:26:18,705 Train Loss: 0.0909707, Val Loss: 0.1003375
119
+ 2024-11-02 01:26:18,706 Epoch 56/500
120
+ 2024-11-02 01:30:02,134 Train Loss: 0.0893479, Val Loss: 0.0970299
121
+ 2024-11-02 01:30:02,134 Epoch 57/500
122
+ 2024-11-02 01:32:57,133 Train Loss: 0.0872361, Val Loss: 0.0955624
123
+ 2024-11-02 01:32:57,133 Epoch 58/500
124
+ 2024-11-02 01:35:52,270 Train Loss: 0.0838744, Val Loss: 0.0920488
125
+ 2024-11-02 01:35:52,271 Epoch 59/500
126
+ 2024-11-02 01:38:45,063 Train Loss: 0.0858515, Val Loss: 0.0930179
127
+ 2024-11-02 01:38:45,063 Epoch 60/500
128
+ 2024-11-02 01:41:40,540 Train Loss: 0.0826247, Val Loss: 0.0905150
129
+ 2024-11-02 01:41:40,540 Epoch 61/500
130
+ 2024-11-02 01:45:12,644 Train Loss: 0.0802455, Val Loss: 0.0889550
131
+ 2024-11-02 01:45:12,644 Epoch 62/500
132
+ 2024-11-02 01:48:23,459 Train Loss: 0.0794286, Val Loss: 0.0892659
133
+ 2024-11-02 01:48:23,459 Epoch 63/500
134
+ 2024-11-02 01:51:18,331 Train Loss: 0.0780315, Val Loss: 0.0879602
135
+ 2024-11-02 01:51:18,331 Epoch 64/500
136
+ 2024-11-02 01:54:22,801 Train Loss: 0.0792677, Val Loss: 0.0879937
137
+ 2024-11-02 01:54:22,801 Epoch 65/500
138
+ 2024-11-02 01:57:58,042 Train Loss: 0.0767234, Val Loss: 0.0871325
139
+ 2024-11-02 01:57:58,042 Epoch 66/500
140
+ 2024-11-02 02:00:51,952 Train Loss: 0.0754895, Val Loss: 0.0903317
141
+ 2024-11-02 02:00:51,953 Epoch 67/500
142
+ 2024-11-02 02:03:47,396 Train Loss: 0.0769478, Val Loss: 0.0840936
143
+ 2024-11-02 02:03:47,396 Epoch 68/500
144
+ 2024-11-02 02:07:24,754 Train Loss: 0.0731464, Val Loss: 0.0821182
145
+ 2024-11-02 02:07:24,755 Epoch 69/500
146
+ 2024-11-02 02:10:31,792 Train Loss: 0.0717625, Val Loss: 0.0837215
147
+ 2024-11-02 02:10:31,792 Epoch 70/500
148
+ 2024-11-02 02:13:25,519 Train Loss: 0.0723670, Val Loss: 0.0840463
149
+ 2024-11-02 02:13:25,520 Epoch 71/500
150
+ 2024-11-02 02:16:30,851 Train Loss: 0.0716797, Val Loss: 0.0841287
151
+ 2024-11-02 02:16:30,851 Epoch 72/500
152
+ 2024-11-02 02:20:06,947 Train Loss: 0.0719864, Val Loss: 0.0821745
153
+ 2024-11-02 02:20:06,948 Epoch 73/500
154
+ 2024-11-02 02:23:01,045 Train Loss: 0.0709139, Val Loss: 0.0822000
155
+ 2024-11-02 02:23:01,046 Epoch 74/500
156
+ 2024-11-02 02:26:22,373 Train Loss: 0.0714848, Val Loss: 0.0835459
157
+ 2024-11-02 02:26:22,374 Epoch 75/500
158
+ 2024-11-02 02:29:42,360 Train Loss: 0.0700932, Val Loss: 0.0810901
159
+ 2024-11-02 02:29:42,360 Epoch 76/500
160
+ 2024-11-02 02:32:37,776 Train Loss: 0.0681059, Val Loss: 0.0796930
161
+ 2024-11-02 02:32:37,776 Epoch 77/500
162
+ 2024-11-02 02:35:33,585 Train Loss: 0.0670243, Val Loss: 0.0786079
163
+ 2024-11-02 02:35:33,585 Epoch 78/500
164
+ 2024-11-02 02:38:43,407 Train Loss: 0.0680468, Val Loss: 0.0823137
165
+ 2024-11-02 02:38:43,407 Epoch 79/500
166
+ 2024-11-02 02:42:14,663 Train Loss: 0.0679627, Val Loss: 0.0846882
167
+ 2024-11-02 02:42:14,664 Epoch 80/500
168
+ 2024-11-02 02:45:10,893 Train Loss: 0.0667835, Val Loss: 0.0789247
169
+ 2024-11-02 02:45:10,893 Epoch 81/500
170
+ 2024-11-02 02:48:39,083 Train Loss: 0.0661981, Val Loss: 0.0775821
171
+ 2024-11-02 02:48:39,083 Epoch 82/500
172
+ 2024-11-02 02:51:54,924 Train Loss: 0.0655681, Val Loss: 0.0776079
173
+ 2024-11-02 02:51:54,925 Epoch 83/500
174
+ 2024-11-02 02:54:51,080 Train Loss: 0.0655806, Val Loss: 0.0774218
175
+ 2024-11-02 02:54:51,080 Epoch 84/500
176
+ 2024-11-02 02:57:57,987 Train Loss: 0.0660661, Val Loss: 0.0763914
177
+ 2024-11-02 02:57:57,987 Epoch 85/500
178
+ 2024-11-02 03:01:36,071 Train Loss: 0.0657679, Val Loss: 0.0773331
179
+ 2024-11-02 03:01:36,071 Epoch 86/500
180
+ 2024-11-02 03:04:32,307 Train Loss: 0.0649654, Val Loss: 0.0758529
181
+ 2024-11-02 03:04:32,308 Epoch 87/500
182
+ 2024-11-02 03:07:26,943 Train Loss: 0.0641380, Val Loss: 0.0760526
183
+ 2024-11-02 03:07:26,944 Epoch 88/500
184
+ 2024-11-02 03:11:05,940 Train Loss: 0.0636658, Val Loss: 0.0762487
185
+ 2024-11-02 03:11:05,940 Epoch 89/500
186
+ 2024-11-02 03:14:11,694 Train Loss: 0.0624945, Val Loss: 0.0751162
187
+ 2024-11-02 03:14:11,695 Epoch 90/500
188
+ 2024-11-02 03:17:06,334 Train Loss: 0.0623680, Val Loss: 0.0770866
189
+ 2024-11-02 03:17:06,335 Epoch 91/500
190
+ 2024-11-02 03:20:05,448 Train Loss: 0.0614920, Val Loss: 0.0776452
191
+ 2024-11-02 03:20:05,449 Epoch 92/500
192
+ 2024-11-02 03:23:42,244 Train Loss: 0.0612183, Val Loss: 0.0754166
193
+ 2024-11-02 03:23:42,244 Epoch 93/500
194
+ 2024-11-02 03:26:51,782 Train Loss: 0.0613547, Val Loss: 0.0752543
195
+ 2024-11-02 03:26:51,783 Epoch 94/500
196
+ 2024-11-02 03:29:49,505 Train Loss: 0.0616766, Val Loss: 0.0742125
197
+ 2024-11-02 03:29:49,508 Epoch 95/500
198
+ 2024-11-02 03:33:37,808 Train Loss: 0.0616243, Val Loss: 0.0736905
199
+ 2024-11-02 03:33:37,809 Epoch 96/500
200
+ 2024-11-02 03:36:33,700 Train Loss: 0.0600223, Val Loss: 0.0741078
201
+ 2024-11-02 03:36:33,701 Epoch 97/500
202
+ 2024-11-02 03:39:28,205 Train Loss: 0.0602433, Val Loss: 0.0743693
203
+ 2024-11-02 03:39:28,206 Epoch 98/500
204
+ 2024-11-02 03:42:23,230 Train Loss: 0.0601597, Val Loss: 0.0753404
205
+ 2024-11-02 03:42:23,231 Epoch 99/500
206
+ 2024-11-02 03:45:18,314 Train Loss: 0.0598806, Val Loss: 0.0763513
207
+ 2024-11-02 03:45:18,315 Epoch 100/500
208
+ 2024-11-02 03:49:04,332 Train Loss: 0.0601263, Val Loss: 0.0766172
209
+ 2024-11-02 03:49:04,333 Epoch 101/500
210
+ 2024-11-02 03:52:01,731 Train Loss: 0.0605062, Val Loss: 0.0754650
211
+ 2024-11-02 03:52:01,732 Epoch 102/500
212
+ 2024-11-02 03:54:56,792 Train Loss: 0.0610919, Val Loss: 0.0740705
213
+ 2024-11-02 03:54:56,793 Epoch 103/500
214
+ 2024-11-02 03:58:20,398 Train Loss: 0.0611019, Val Loss: 0.0739564
215
+ 2024-11-02 03:58:20,398 Epoch 104/500
216
+ 2024-11-02 04:01:43,215 Train Loss: 0.0604177, Val Loss: 0.0733520
217
+ 2024-11-02 04:01:43,216 Epoch 105/500
218
+ 2024-11-02 04:04:38,575 Train Loss: 0.0608769, Val Loss: 0.0736601
219
+ 2024-11-02 04:04:38,576 Epoch 106/500
220
+ 2024-11-02 04:07:34,017 Train Loss: 0.0599312, Val Loss: 0.0722742
221
+ 2024-11-02 04:07:34,017 Epoch 107/500
222
+ 2024-11-02 04:10:41,422 Train Loss: 0.0589203, Val Loss: 0.0726186
223
+ 2024-11-02 04:10:41,422 Epoch 108/500
224
+ 2024-11-02 04:14:19,472 Train Loss: 0.0579503, Val Loss: 0.0735207
225
+ 2024-11-02 04:14:19,473 Epoch 109/500
226
+ 2024-11-02 04:17:14,423 Train Loss: 0.0581012, Val Loss: 0.0714958
227
+ 2024-11-02 04:17:14,424 Epoch 110/500
228
+ 2024-11-02 04:20:08,309 Train Loss: 0.0579907, Val Loss: 0.0717349
229
+ 2024-11-02 04:20:08,310 Epoch 111/500
230
+ 2024-11-02 04:23:02,975 Train Loss: 0.0577467, Val Loss: 0.0720986
231
+ 2024-11-02 04:23:02,975 Epoch 112/500
232
+ 2024-11-02 04:26:49,225 Train Loss: 0.0578204, Val Loss: 0.0730009
233
+ 2024-11-02 04:26:49,225 Epoch 113/500
234
+ 2024-11-02 04:29:48,972 Train Loss: 0.0573403, Val Loss: 0.0730425
235
+ 2024-11-02 04:29:48,973 Epoch 114/500
236
+ 2024-11-02 04:32:43,706 Train Loss: 0.0566198, Val Loss: 0.0714370
237
+ 2024-11-02 04:32:43,706 Epoch 115/500
238
+ 2024-11-02 04:35:40,347 Train Loss: 0.0560507, Val Loss: 0.0723706
239
+ 2024-11-02 04:35:40,347 Epoch 116/500
240
+ 2024-11-02 04:38:46,719 Train Loss: 0.0556752, Val Loss: 0.0724244
241
+ 2024-11-02 04:38:46,720 Epoch 117/500
242
+ 2024-11-02 04:42:24,673 Train Loss: 0.0560471, Val Loss: 0.0721737
243
+ 2024-11-02 04:42:24,673 Epoch 118/500
244
+ 2024-11-02 04:45:21,173 Train Loss: 0.0566246, Val Loss: 0.0711538
245
+ 2024-11-02 04:45:21,173 Epoch 119/500
246
+ 2024-11-02 04:48:16,343 Train Loss: 0.0557365, Val Loss: 0.0720810
247
+ 2024-11-02 04:48:16,343 Epoch 120/500
248
+ 2024-11-02 04:51:19,198 Train Loss: 0.0567784, Val Loss: 0.0748137
249
+ 2024-11-02 04:51:19,199 Epoch 121/500
250
+ 2024-11-02 04:55:01,327 Train Loss: 0.0561503, Val Loss: 0.0713575
251
+ 2024-11-02 04:55:01,328 Epoch 122/500
252
+ 2024-11-02 04:57:58,098 Train Loss: 0.0555640, Val Loss: 0.0728168
253
+ 2024-11-02 04:57:58,099 Epoch 123/500
254
+ 2024-11-02 05:01:12,518 Train Loss: 0.0563995, Val Loss: 0.0762140
255
+ 2024-11-02 05:01:12,519 Epoch 124/500
256
+ 2024-11-02 05:04:43,916 Train Loss: 0.0563220, Val Loss: 0.0753405
257
+ 2024-11-02 05:04:43,916 Epoch 125/500
258
+ 2024-11-02 05:07:42,416 Train Loss: 0.0553528, Val Loss: 0.0710970
259
+ 2024-11-02 05:07:42,417 Epoch 126/500
260
+ 2024-11-02 05:10:37,391 Train Loss: 0.0541343, Val Loss: 0.0701048
261
+ 2024-11-02 05:10:37,391 Epoch 127/500
262
+ 2024-11-02 05:13:32,917 Train Loss: 0.0537019, Val Loss: 0.0690071
263
+ 2024-11-02 05:13:32,918 Epoch 128/500
264
+ 2024-11-02 05:17:13,596 Train Loss: 0.0535811, Val Loss: 0.0699223
265
+ 2024-11-02 05:17:13,597 Epoch 129/500
266
+ 2024-11-02 05:20:41,754 Train Loss: 0.0538931, Val Loss: 0.0697886
267
+ 2024-11-02 05:20:41,754 Epoch 130/500
268
+ 2024-11-02 05:23:38,978 Train Loss: 0.0538820, Val Loss: 0.0720680
269
+ 2024-11-02 05:23:38,978 Epoch 131/500
270
+ 2024-11-02 05:26:36,020 Train Loss: 0.0533926, Val Loss: 0.0707530
271
+ 2024-11-02 05:26:36,021 Epoch 132/500
272
+ 2024-11-02 05:30:23,620 Train Loss: 0.0541864, Val Loss: 0.0718147
273
+ 2024-11-02 05:30:23,620 Epoch 133/500
274
+ 2024-11-02 05:33:19,293 Train Loss: 0.0539408, Val Loss: 0.0724074
275
+ 2024-11-02 05:33:19,294 Epoch 134/500
276
+ 2024-11-02 05:36:15,728 Train Loss: 0.0543938, Val Loss: 0.0706563
277
+ 2024-11-02 05:36:15,728 Epoch 135/500
278
+ 2024-11-02 05:39:11,085 Train Loss: 0.0544816, Val Loss: 0.0697631
279
+ 2024-11-02 05:39:11,086 Epoch 136/500
280
+ 2024-11-02 05:42:24,250 Train Loss: 0.0539293, Val Loss: 0.0671413
281
+ 2024-11-02 05:42:24,251 Epoch 137/500
282
+ 2024-11-02 05:45:57,339 Train Loss: 0.0545293, Val Loss: 0.0680161
283
+ 2024-11-02 05:45:57,340 Epoch 138/500
284
+ 2024-11-02 05:48:53,781 Train Loss: 0.0535397, Val Loss: 0.0673363
285
+ 2024-11-02 05:48:53,782 Epoch 139/500
286
+ 2024-11-02 05:51:58,520 Train Loss: 0.0523529, Val Loss: 0.0677837
287
+ 2024-11-02 05:51:58,521 Epoch 140/500
288
+ 2024-11-02 05:55:42,861 Train Loss: 0.0523778, Val Loss: 0.0711356
289
+ 2024-11-02 05:55:42,862 Epoch 141/500
290
+ 2024-11-02 05:58:39,971 Train Loss: 0.0522159, Val Loss: 0.0695408
291
+ 2024-11-02 05:58:39,972 Epoch 142/500
292
+ 2024-11-02 06:01:52,701 Train Loss: 0.0521605, Val Loss: 0.0693376
293
+ 2024-11-02 06:01:52,702 Epoch 143/500
294
+ 2024-11-02 06:05:25,882 Train Loss: 0.0524033, Val Loss: 0.0707938
295
+ 2024-11-02 06:05:25,883 Epoch 144/500
296
+ 2024-11-02 06:08:23,382 Train Loss: 0.0523694, Val Loss: 0.0729530
297
+ 2024-11-02 06:08:23,383 Epoch 145/500
298
+ 2024-11-02 06:11:34,371 Train Loss: 0.0528824, Val Loss: 0.0739885
299
+ 2024-11-02 06:11:34,371 Epoch 146/500
300
+ 2024-11-02 06:15:08,465 Train Loss: 0.0531252, Val Loss: 0.0730783
301
+ 2024-11-02 06:15:08,466 Epoch 147/500
302
+ 2024-11-02 06:18:05,443 Train Loss: 0.0536842, Val Loss: 0.0712743
303
+ 2024-11-02 06:18:05,443 Epoch 148/500
304
+ 2024-11-02 06:21:24,906 Train Loss: 0.0529959, Val Loss: 0.0689067
305
+ 2024-11-02 06:21:24,906 Epoch 149/500
306
+ 2024-11-02 06:24:53,840 Train Loss: 0.0528019, Val Loss: 0.0693257
307
+ 2024-11-02 06:24:53,840 Epoch 150/500
308
+ 2024-11-02 06:27:50,296 Train Loss: 0.0527336, Val Loss: 0.0665483
309
+ 2024-11-02 06:27:50,296 Epoch 151/500
310
+ 2024-11-02 06:30:48,375 Train Loss: 0.0515403, Val Loss: 0.0665039
311
+ 2024-11-02 06:30:48,376 Epoch 152/500
312
+ 2024-11-02 06:33:48,230 Train Loss: 0.0514301, Val Loss: 0.0664525
313
+ 2024-11-02 06:33:48,230 Epoch 153/500
314
+ 2024-11-02 06:37:23,158 Train Loss: 0.0502824, Val Loss: 0.0667181
315
+ 2024-11-02 06:37:23,158 Epoch 154/500
316
+ 2024-11-02 06:40:36,383 Train Loss: 0.0501546, Val Loss: 0.0660617
317
+ 2024-11-02 06:40:36,384 Epoch 155/500
318
+ 2024-11-02 06:43:33,510 Train Loss: 0.0498832, Val Loss: 0.0658859
319
+ 2024-11-02 06:43:33,510 Epoch 156/500
320
+ 2024-11-02 06:46:29,803 Train Loss: 0.0502388, Val Loss: 0.0655429
321
+ 2024-11-02 06:46:29,803 Epoch 157/500
322
+ 2024-11-02 06:49:59,003 Train Loss: 0.0492547, Val Loss: 0.0657720
323
+ 2024-11-02 06:49:59,004 Epoch 158/500
324
+ 2024-11-02 06:53:11,722 Train Loss: 0.0492462, Val Loss: 0.0664155
325
+ 2024-11-02 06:53:11,723 Epoch 159/500
326
+ 2024-11-02 06:56:26,585 Train Loss: 0.0491800, Val Loss: 0.0658636
327
+ 2024-11-02 06:56:26,586 Epoch 160/500
328
+ 2024-11-02 06:59:56,914 Train Loss: 0.0492121, Val Loss: 0.0654231
329
+ 2024-11-02 06:59:56,914 Epoch 161/500
330
+ 2024-11-02 07:02:53,001 Train Loss: 0.0490022, Val Loss: 0.0659616
331
+ 2024-11-02 07:02:53,002 Epoch 162/500
332
+ 2024-11-02 07:05:50,147 Train Loss: 0.0498532, Val Loss: 0.0654533
333
+ 2024-11-02 07:05:50,147 Epoch 163/500
334
+ 2024-11-02 07:08:47,335 Train Loss: 0.0498590, Val Loss: 0.0656108
335
+ 2024-11-02 07:08:47,335 Epoch 164/500
336
+ 2024-11-02 07:12:34,392 Train Loss: 0.0500707, Val Loss: 0.0664991
337
+ 2024-11-02 07:12:34,392 Epoch 165/500
338
+ 2024-11-02 07:15:33,278 Train Loss: 0.0496684, Val Loss: 0.0680532
339
+ 2024-11-02 07:15:33,279 Epoch 166/500
340
+ 2024-11-02 07:18:29,103 Train Loss: 0.0497037, Val Loss: 0.0705230
341
+ 2024-11-02 07:18:29,104 Epoch 167/500
342
+ 2024-11-02 07:21:49,710 Train Loss: 0.0497541, Val Loss: 0.0696145
343
+ 2024-11-02 07:21:49,710 Epoch 168/500
344
+ 2024-11-02 07:25:17,195 Train Loss: 0.0506631, Val Loss: 0.0681238
345
+ 2024-11-02 07:25:17,195 Epoch 169/500
346
+ 2024-11-02 07:28:15,290 Train Loss: 0.0504000, Val Loss: 0.0659585
347
+ 2024-11-02 07:28:15,290 Epoch 170/500
348
+ 2024-11-02 07:31:42,140 Train Loss: 0.0506047, Val Loss: 0.0670450
349
+ 2024-11-02 07:31:42,140 Epoch 171/500
350
+ 2024-11-02 07:35:05,931 Train Loss: 0.0497379, Val Loss: 0.0677675
351
+ 2024-11-02 07:35:05,931 Epoch 172/500
352
+ 2024-11-02 07:38:11,060 Train Loss: 0.0491124, Val Loss: 0.0653436
353
+ 2024-11-02 07:38:11,060 Epoch 173/500
354
+ 2024-11-02 07:41:53,370 Train Loss: 0.0487102, Val Loss: 0.0651903
355
+ 2024-11-02 07:41:53,371 Epoch 174/500
356
+ 2024-11-02 07:44:50,307 Train Loss: 0.0486504, Val Loss: 0.0657341
357
+ 2024-11-02 07:44:50,307 Epoch 175/500
358
+ 2024-11-02 07:47:45,543 Train Loss: 0.0493187, Val Loss: 0.0650808
359
+ 2024-11-02 07:47:45,543 Epoch 176/500
360
+ 2024-11-02 07:51:17,406 Train Loss: 0.0486104, Val Loss: 0.0661398
361
+ 2024-11-02 07:51:17,407 Epoch 177/500
362
+ 2024-11-02 07:54:31,081 Train Loss: 0.0485303, Val Loss: 0.0670544
363
+ 2024-11-02 07:54:31,081 Epoch 178/500
364
+ 2024-11-02 07:57:25,651 Train Loss: 0.0486693, Val Loss: 0.0662146
365
+ 2024-11-02 07:57:25,651 Epoch 179/500
366
+ 2024-11-02 08:00:42,067 Train Loss: 0.0484047, Val Loss: 0.0641130
367
+ 2024-11-02 08:00:42,067 Epoch 180/500
368
+ 2024-11-02 08:04:13,337 Train Loss: 0.0485809, Val Loss: 0.0640709
369
+ 2024-11-02 08:04:13,337 Epoch 181/500
370
+ 2024-11-02 08:07:09,021 Train Loss: 0.0486762, Val Loss: 0.0652326
371
+ 2024-11-02 08:07:09,021 Epoch 182/500
372
+ 2024-11-02 08:10:05,790 Train Loss: 0.0488563, Val Loss: 0.0653231
373
+ 2024-11-02 08:10:05,790 Epoch 183/500
374
+ 2024-11-02 08:13:47,143 Train Loss: 0.0484229, Val Loss: 0.0651319
375
+ 2024-11-02 08:13:47,143 Epoch 184/500
376
+ 2024-11-02 08:16:50,728 Train Loss: 0.0478725, Val Loss: 0.0647483
377
+ 2024-11-02 08:16:50,728 Epoch 185/500
378
+ 2024-11-02 08:19:46,697 Train Loss: 0.0480297, Val Loss: 0.0654461
379
+ 2024-11-02 08:19:46,697 Epoch 186/500
380
+ 2024-11-02 08:23:20,862 Train Loss: 0.0480581, Val Loss: 0.0673987
381
+ 2024-11-02 08:23:20,862 Epoch 187/500
382
+ 2024-11-02 08:26:52,726 Train Loss: 0.0481855, Val Loss: 0.0666781
383
+ 2024-11-02 08:26:52,727 Epoch 188/500
384
+ 2024-11-02 08:29:48,905 Train Loss: 0.0484823, Val Loss: 0.0646197
385
+ 2024-11-02 08:29:48,906 Epoch 189/500
386
+ 2024-11-02 08:32:44,729 Train Loss: 0.0486292, Val Loss: 0.0667414
387
+ 2024-11-02 08:32:44,729 Epoch 190/500
388
+ 2024-11-02 08:36:05,764 Train Loss: 0.0486706, Val Loss: 0.0637663
389
+ 2024-11-02 08:36:05,764 Epoch 191/500
390
+ 2024-11-02 08:39:33,395 Train Loss: 0.0490878, Val Loss: 0.0633622
391
+ 2024-11-02 08:39:33,395 Epoch 192/500
392
+ 2024-11-02 08:42:28,960 Train Loss: 0.0478180, Val Loss: 0.0631506
393
+ 2024-11-02 08:42:28,961 Epoch 193/500
394
+ 2024-11-02 08:45:24,319 Train Loss: 0.0476836, Val Loss: 0.0635802
395
+ 2024-11-02 08:45:24,320 Epoch 194/500
396
+ 2024-11-02 08:48:53,799 Train Loss: 0.0476446, Val Loss: 0.0637492
397
+ 2024-11-02 08:48:53,800 Epoch 195/500
398
+ 2024-11-02 08:52:11,795 Train Loss: 0.0473838, Val Loss: 0.0624369
399
+ 2024-11-02 08:52:11,795 Epoch 196/500
400
+ 2024-11-02 08:55:07,417 Train Loss: 0.0469079, Val Loss: 0.0624948
401
+ 2024-11-02 08:55:07,418 Epoch 197/500
402
+ 2024-11-02 08:58:05,082 Train Loss: 0.0466404, Val Loss: 0.0633061
403
+ 2024-11-02 08:58:05,082 Epoch 198/500
404
+ 2024-11-02 09:01:33,582 Train Loss: 0.0468184, Val Loss: 0.0630486
405
+ 2024-11-02 09:01:33,583 Epoch 199/500
406
+ 2024-11-02 09:04:50,847 Train Loss: 0.0469254, Val Loss: 0.0629758
407
+ 2024-11-02 09:04:50,847 Epoch 200/500
408
+ 2024-11-02 09:07:47,306 Train Loss: 0.0467479, Val Loss: 0.0639387
409
+ 2024-11-02 09:07:47,307 Epoch 201/500
410
+ 2024-11-02 09:11:07,587 Train Loss: 0.0476059, Val Loss: 0.0643309
411
+ 2024-11-02 09:11:07,587 Epoch 202/500
412
+ 2024-11-02 09:14:32,691 Train Loss: 0.0470280, Val Loss: 0.0645014
413
+ 2024-11-02 09:14:32,691 Epoch 203/500
414
+ 2024-11-02 09:17:27,006 Train Loss: 0.0467279, Val Loss: 0.0640839
415
+ 2024-11-02 09:17:27,006 Epoch 204/500
416
+ 2024-11-02 09:20:32,603 Train Loss: 0.0464497, Val Loss: 0.0623920
417
+ 2024-11-02 09:20:32,603 Epoch 205/500
418
+ 2024-11-02 09:24:11,428 Train Loss: 0.0462260, Val Loss: 0.0627812
419
+ 2024-11-02 09:24:11,428 Epoch 206/500
420
+ 2024-11-02 09:27:06,928 Train Loss: 0.0460674, Val Loss: 0.0627784
421
+ 2024-11-02 09:27:06,929 Epoch 207/500
422
+ 2024-11-02 09:30:01,700 Train Loss: 0.0466174, Val Loss: 0.0642107
423
+ 2024-11-02 09:30:01,700 Epoch 208/500
424
+ 2024-11-02 09:33:39,722 Train Loss: 0.0464228, Val Loss: 0.0643455
425
+ 2024-11-02 09:33:39,722 Epoch 209/500
426
+ 2024-11-02 09:36:46,911 Train Loss: 0.0472782, Val Loss: 0.0638260
427
+ 2024-11-02 09:36:46,911 Epoch 210/500
428
+ 2024-11-02 09:39:41,318 Train Loss: 0.0475625, Val Loss: 0.0642031
429
+ 2024-11-02 09:39:41,319 Epoch 211/500
430
+ 2024-11-02 09:42:57,921 Train Loss: 0.0468253, Val Loss: 0.0650402
431
+ 2024-11-02 09:42:57,921 Epoch 212/500
432
+ 2024-11-02 09:46:26,197 Train Loss: 0.0470743, Val Loss: 0.0656636
433
+ 2024-11-02 09:46:26,198 Epoch 213/500
434
+ 2024-11-02 09:49:23,816 Train Loss: 0.0463564, Val Loss: 0.0664696
435
+ 2024-11-02 09:49:23,816 Epoch 214/500
436
+ 2024-11-02 09:53:09,256 Train Loss: 0.0467241, Val Loss: 0.0639718
437
+ 2024-11-02 09:53:09,256 Epoch 215/500
438
+ 2024-11-02 09:56:04,259 Train Loss: 0.0464902, Val Loss: 0.0639500
439
+ 2024-11-02 09:56:04,259 Epoch 216/500
440
+ 2024-11-02 09:58:57,620 Train Loss: 0.0462107, Val Loss: 0.0656044
441
+ 2024-11-02 09:58:57,620 Epoch 217/500
442
+ 2024-11-02 10:01:51,349 Train Loss: 0.0463994, Val Loss: 0.0677382
443
+ 2024-11-02 10:01:51,349 Epoch 218/500
444
+ 2024-11-02 10:05:00,887 Train Loss: 0.0466101, Val Loss: 0.0665351
445
+ 2024-11-02 10:05:00,887 Epoch 219/500
446
+ 2024-11-02 10:08:36,590 Train Loss: 0.0467272, Val Loss: 0.0654004
447
+ 2024-11-02 10:08:36,591 Epoch 220/500
448
+ 2024-11-02 10:11:33,107 Train Loss: 0.0470429, Val Loss: 0.0643636
449
+ 2024-11-02 10:11:33,107 Epoch 221/500
450
+ 2024-11-02 10:15:10,544 Train Loss: 0.0473663, Val Loss: 0.0636239
451
+ 2024-11-02 10:15:10,545 Epoch 222/500
452
+ 2024-11-02 10:18:19,683 Train Loss: 0.0468482, Val Loss: 0.0644520
453
+ 2024-11-02 10:18:19,683 Epoch 223/500
454
+ 2024-11-02 10:21:15,355 Train Loss: 0.0465695, Val Loss: 0.0641441
455
+ 2024-11-02 10:21:15,355 Epoch 224/500
456
+ 2024-11-02 10:24:57,099 Train Loss: 0.0459439, Val Loss: 0.0636620
457
+ 2024-11-02 10:24:57,099 Epoch 225/500
458
+ 2024-11-02 10:28:00,668 Train Loss: 0.0457703, Val Loss: 0.0644640
459
+ 2024-11-02 10:28:00,668 Epoch 226/500
460
+ 2024-11-02 10:30:57,621 Train Loss: 0.0452521, Val Loss: 0.0636580
461
+ 2024-11-02 10:30:57,621 Epoch 227/500
462
+ 2024-11-02 10:34:38,824 Train Loss: 0.0461391, Val Loss: 0.0628136
463
+ 2024-11-02 10:34:38,824 Epoch 228/500
464
+ 2024-11-02 10:37:41,907 Train Loss: 0.0445184, Val Loss: 0.0619271
465
+ 2024-11-02 10:37:41,907 Epoch 229/500
466
+ 2024-11-02 10:40:37,588 Train Loss: 0.0442432, Val Loss: 0.0627570
467
+ 2024-11-02 10:40:37,588 Epoch 230/500
468
+ 2024-11-02 10:43:35,210 Train Loss: 0.0439133, Val Loss: 0.0619078
469
+ 2024-11-02 10:43:35,210 Epoch 231/500
470
+ 2024-11-02 10:47:01,896 Train Loss: 0.0443042, Val Loss: 0.0618501
471
+ 2024-11-02 10:47:01,896 Epoch 232/500
472
+ 2024-11-02 10:50:22,728 Train Loss: 0.0445646, Val Loss: 0.0618263
473
+ 2024-11-02 10:50:22,728 Epoch 233/500
474
+ 2024-11-02 10:53:17,480 Train Loss: 0.0447499, Val Loss: 0.0619369
475
+ 2024-11-02 10:53:17,481 Epoch 234/500
476
+ 2024-11-02 10:56:12,094 Train Loss: 0.0444229, Val Loss: 0.0623105
477
+ 2024-11-02 10:56:12,094 Epoch 235/500
478
+ 2024-11-02 10:59:07,060 Train Loss: 0.0452141, Val Loss: 0.0624512
479
+ 2024-11-02 10:59:07,061 Epoch 236/500
480
+ 2024-11-02 11:02:02,684 Train Loss: 0.0451271, Val Loss: 0.0612406
481
+ 2024-11-02 11:02:02,685 Epoch 237/500
482
+ 2024-11-02 11:04:57,798 Train Loss: 0.0457152, Val Loss: 0.0630288
483
+ 2024-11-02 11:04:57,799 Epoch 238/500
484
+ 2024-11-02 11:07:51,540 Train Loss: 0.0458026, Val Loss: 0.0632026
485
+ 2024-11-02 11:07:51,541 Epoch 239/500
486
+ 2024-11-02 11:11:33,098 Train Loss: 0.0461623, Val Loss: 0.0626708
487
+ 2024-11-02 11:11:33,098 Epoch 240/500
488
+ 2024-11-02 11:14:37,824 Train Loss: 0.0462476, Val Loss: 0.0638611
489
+ 2024-11-02 11:14:37,824 Epoch 241/500
490
+ 2024-11-02 11:17:32,953 Train Loss: 0.0462913, Val Loss: 0.0634115
491
+ 2024-11-02 11:17:32,954 Epoch 242/500
492
+ 2024-11-02 11:20:34,928 Train Loss: 0.0463102, Val Loss: 0.0619711
493
+ 2024-11-02 11:20:34,929 Epoch 243/500
494
+ 2024-11-02 11:24:18,892 Train Loss: 0.0455850, Val Loss: 0.0623656
495
+ 2024-11-02 11:24:18,893 Epoch 244/500
496
+ 2024-11-02 11:27:15,059 Train Loss: 0.0450101, Val Loss: 0.0621282
497
+ 2024-11-02 11:27:15,059 Epoch 245/500
498
+ 2024-11-02 11:30:35,128 Train Loss: 0.0445481, Val Loss: 0.0608157
499
+ 2024-11-02 11:30:35,128 Epoch 246/500
500
+ 2024-11-02 11:34:02,769 Train Loss: 0.0439732, Val Loss: 0.0600980
501
+ 2024-11-02 11:34:02,769 Epoch 247/500
502
+ 2024-11-02 11:36:59,101 Train Loss: 0.0433323, Val Loss: 0.0602155
503
+ 2024-11-02 11:36:59,102 Epoch 248/500
504
+ 2024-11-02 11:39:55,311 Train Loss: 0.0438761, Val Loss: 0.0608776
505
+ 2024-11-02 11:39:55,311 Epoch 249/500
506
+ 2024-11-02 11:43:38,910 Train Loss: 0.0435855, Val Loss: 0.0602582
507
+ 2024-11-02 11:43:38,910 Epoch 250/500
508
+ 2024-11-02 11:46:44,047 Train Loss: 0.0436407, Val Loss: 0.0607103
509
+ 2024-11-02 11:46:44,047 Epoch 251/500
510
+ 2024-11-02 11:49:55,315 Train Loss: 0.0438314, Val Loss: 0.0602874
511
+ 2024-11-02 11:49:55,315 Epoch 252/500
512
+ 2024-11-02 11:53:29,607 Train Loss: 0.0434018, Val Loss: 0.0606785
513
+ 2024-11-02 11:53:29,607 Epoch 253/500
514
+ 2024-11-02 11:56:25,404 Train Loss: 0.0436848, Val Loss: 0.0602507
515
+ 2024-11-02 11:56:25,405 Epoch 254/500
516
+ 2024-11-02 11:59:53,906 Train Loss: 0.0432789, Val Loss: 0.0607832
517
+ 2024-11-02 11:59:53,907 Epoch 255/500
518
+ 2024-11-02 12:03:14,922 Train Loss: 0.0435869, Val Loss: 0.0613487
519
+ 2024-11-02 12:03:14,923 Epoch 256/500
520
+ 2024-11-02 12:06:12,148 Train Loss: 0.0440070, Val Loss: 0.0605806
521
+ 2024-11-02 12:06:12,148 Epoch 257/500
522
+ 2024-11-02 12:09:38,145 Train Loss: 0.0438834, Val Loss: 0.0606783
523
+ 2024-11-02 12:09:38,145 Epoch 258/500
524
+ 2024-11-02 12:13:05,703 Train Loss: 0.0432112, Val Loss: 0.0607154
525
+ 2024-11-02 12:13:05,703 Epoch 259/500
526
+ 2024-11-02 12:16:04,319 Train Loss: 0.0435320, Val Loss: 0.0602177
527
+ 2024-11-02 12:16:04,319 Epoch 260/500
528
+ 2024-11-02 12:19:44,577 Train Loss: 0.0442541, Val Loss: 0.0605268
529
+ 2024-11-02 12:19:44,578 Epoch 261/500
530
+ 2024-11-02 12:23:06,594 Train Loss: 0.0436440, Val Loss: 0.0608823
531
+ 2024-11-02 12:23:06,594 Epoch 262/500
532
+ 2024-11-02 12:26:40,181 Train Loss: 0.0439424, Val Loss: 0.0609285
533
+ 2024-11-02 12:26:40,182 Epoch 263/500
534
+ 2024-11-02 12:30:07,036 Train Loss: 0.0441003, Val Loss: 0.0614702
535
+ 2024-11-02 12:30:07,037 Epoch 264/500
536
+ 2024-11-02 12:33:17,103 Train Loss: 0.0443392, Val Loss: 0.0613654
537
+ 2024-11-02 12:33:17,104 Epoch 265/500
538
+ 2024-11-02 12:36:58,419 Train Loss: 0.0449716, Val Loss: 0.0604724
539
+ 2024-11-02 12:36:58,420 Epoch 266/500
540
+ 2024-11-02 12:39:58,737 Train Loss: 0.0452770, Val Loss: 0.0606473
541
+ 2024-11-02 12:39:58,737 Epoch 267/500
542
+ 2024-11-02 12:43:20,531 Train Loss: 0.0445917, Val Loss: 0.0604431
543
+ 2024-11-02 12:43:20,532 Epoch 268/500
544
+ 2024-11-02 12:46:53,001 Train Loss: 0.0445921, Val Loss: 0.0606213
545
+ 2024-11-02 12:46:53,001 Epoch 269/500
546
+ 2024-11-02 12:49:52,948 Train Loss: 0.0442547, Val Loss: 0.0610656
547
+ 2024-11-02 12:49:52,948 Epoch 270/500
548
+ 2024-11-02 12:53:40,502 Train Loss: 0.0436127, Val Loss: 0.0616169
549
+ 2024-11-02 12:53:40,503 Epoch 271/500
550
+ 2024-11-02 12:56:45,999 Train Loss: 0.0437103, Val Loss: 0.0608491
551
+ 2024-11-02 12:56:45,999 Epoch 272/500
552
+ 2024-11-02 12:59:45,955 Train Loss: 0.0427906, Val Loss: 0.0613495
553
+ 2024-11-02 12:59:45,956 Epoch 273/500
554
+ 2024-11-02 13:03:29,888 Train Loss: 0.0426337, Val Loss: 0.0601556
555
+ 2024-11-02 13:03:29,889 Epoch 274/500
556
+ 2024-11-02 13:06:41,654 Train Loss: 0.0434502, Val Loss: 0.0593469
557
+ 2024-11-02 13:06:41,654 Epoch 275/500
558
+ 2024-11-02 13:09:42,127 Train Loss: 0.0434018, Val Loss: 0.0595080
559
+ 2024-11-02 13:09:42,128 Epoch 276/500
560
+ 2024-11-02 13:12:47,399 Train Loss: 0.0432626, Val Loss: 0.0602453
561
+ 2024-11-02 13:12:47,399 Epoch 277/500
562
+ 2024-11-02 13:16:23,394 Train Loss: 0.0431200, Val Loss: 0.0601694
563
+ 2024-11-02 13:16:23,395 Epoch 278/500
564
+ 2024-11-02 13:19:50,280 Train Loss: 0.0423720, Val Loss: 0.0600633
565
+ 2024-11-02 13:19:50,281 Epoch 279/500
566
+ 2024-11-02 13:23:05,036 Train Loss: 0.0419733, Val Loss: 0.0589951
567
+ 2024-11-02 13:23:05,037 Epoch 280/500
568
+ 2024-11-02 13:26:44,725 Train Loss: 0.0420052, Val Loss: 0.0590216
569
+ 2024-11-02 13:26:44,726 Epoch 281/500
570
+ 2024-11-02 13:29:44,214 Train Loss: 0.0416629, Val Loss: 0.0587665
571
+ 2024-11-02 13:29:44,214 Epoch 282/500
572
+ 2024-11-02 13:32:42,448 Train Loss: 0.0415587, Val Loss: 0.0591061
573
+ 2024-11-02 13:32:42,449 Epoch 283/500
574
+ 2024-11-02 13:36:37,899 Train Loss: 0.0417753, Val Loss: 0.0589201
575
+ 2024-11-02 13:36:37,899 Epoch 284/500
576
+ 2024-11-02 13:39:39,564 Train Loss: 0.0417630, Val Loss: 0.0590874
577
+ 2024-11-02 13:39:39,564 Epoch 285/500
578
+ 2024-11-02 13:42:39,028 Train Loss: 0.0415218, Val Loss: 0.0591461
579
+ 2024-11-02 13:42:39,028 Epoch 286/500
580
+ 2024-11-02 13:45:42,033 Train Loss: 0.0417465, Val Loss: 0.0600360
581
+ 2024-11-02 13:45:42,033 Epoch 287/500
582
+ 2024-11-02 13:49:32,992 Train Loss: 0.0420417, Val Loss: 0.0601999
583
+ 2024-11-02 13:49:32,992 Epoch 288/500
584
+ 2024-11-02 13:52:33,846 Train Loss: 0.0420656, Val Loss: 0.0598516
585
+ 2024-11-02 13:52:33,846 Epoch 289/500
586
+ 2024-11-02 13:55:32,240 Train Loss: 0.0415406, Val Loss: 0.0591464
587
+ 2024-11-02 13:55:32,240 Epoch 290/500
588
+ 2024-11-02 13:58:33,550 Train Loss: 0.0425317, Val Loss: 0.0601851
589
+ 2024-11-02 13:58:33,551 Epoch 291/500
590
+ 2024-11-02 14:01:55,772 Train Loss: 0.0421410, Val Loss: 0.0604017
591
+ 2024-11-02 14:01:55,772 Epoch 292/500
592
+ 2024-11-02 14:05:30,545 Train Loss: 0.0417393, Val Loss: 0.0591543
593
+ 2024-11-02 14:05:30,545 Epoch 293/500
594
+ 2024-11-02 14:08:32,246 Train Loss: 0.0415275, Val Loss: 0.0585560
595
+ 2024-11-02 14:08:32,246 Epoch 294/500
596
+ 2024-11-02 14:11:31,316 Train Loss: 0.0414154, Val Loss: 0.0591052
597
+ 2024-11-02 14:11:31,316 Epoch 295/500
598
+ 2024-11-02 14:14:30,206 Train Loss: 0.0420112, Val Loss: 0.0602253
599
+ 2024-11-02 14:14:30,206 Epoch 296/500
600
+ 2024-11-02 14:17:28,202 Train Loss: 0.0422841, Val Loss: 0.0610316
601
+ 2024-11-02 14:17:28,202 Epoch 297/500
602
+ 2024-11-02 14:20:26,173 Train Loss: 0.0428998, Val Loss: 0.0588401
603
+ 2024-11-02 14:20:26,173 Epoch 298/500
604
+ 2024-11-02 14:23:47,174 Train Loss: 0.0422060, Val Loss: 0.0594055
605
+ 2024-11-02 14:23:47,174 Epoch 299/500
606
+ 2024-11-02 14:27:20,952 Train Loss: 0.0416644, Val Loss: 0.0595470
607
+ 2024-11-02 14:27:20,953 Epoch 300/500
608
+ 2024-11-02 14:30:19,386 Train Loss: 0.0418225, Val Loss: 0.0589879
609
+ 2024-11-02 14:30:19,387 Epoch 301/500
610
+ 2024-11-02 14:33:15,452 Train Loss: 0.0415816, Val Loss: 0.0594943
611
+ 2024-11-02 14:33:15,453 Epoch 302/500
612
+ 2024-11-02 14:36:50,207 Train Loss: 0.0419323, Val Loss: 0.0594391
613
+ 2024-11-02 14:36:50,207 Epoch 303/500
614
+ 2024-11-02 14:40:07,813 Train Loss: 0.0419379, Val Loss: 0.0600717
615
+ 2024-11-02 14:40:07,814 Epoch 304/500
616
+ 2024-11-02 14:43:13,206 Train Loss: 0.0423009, Val Loss: 0.0595942
617
+ 2024-11-02 14:43:13,207 Epoch 305/500
618
+ 2024-11-02 14:46:16,218 Train Loss: 0.0416932, Val Loss: 0.0597923
619
+ 2024-11-02 14:46:16,218 Epoch 306/500
620
+ 2024-11-02 14:49:19,229 Train Loss: 0.0418825, Val Loss: 0.0597237
621
+ 2024-11-02 14:49:19,229 Epoch 307/500
622
+ 2024-11-02 14:52:23,987 Train Loss: 0.0419184, Val Loss: 0.0602407
623
+ 2024-11-02 14:52:23,988 Epoch 308/500
624
+ 2024-11-02 14:55:31,509 Train Loss: 0.0419676, Val Loss: 0.0610514
625
+ 2024-11-02 14:55:31,509 Epoch 309/500
626
+ 2024-11-02 14:59:19,151 Train Loss: 0.0422856, Val Loss: 0.0615857
627
+ 2024-11-02 14:59:19,152 Epoch 310/500
628
+ 2024-11-02 15:02:17,619 Train Loss: 0.0419358, Val Loss: 0.0618955
629
+ 2024-11-02 15:02:17,619 Epoch 311/500
630
+ 2024-11-02 15:05:15,218 Train Loss: 0.0419437, Val Loss: 0.0604494
631
+ 2024-11-02 15:05:15,219 Epoch 312/500
632
+ 2024-11-02 15:08:13,784 Train Loss: 0.0415363, Val Loss: 0.0605207
633
+ 2024-11-02 15:08:13,785 Epoch 313/500
634
+ 2024-11-02 15:11:13,682 Train Loss: 0.0415161, Val Loss: 0.0600125
635
+ 2024-11-02 15:11:13,682 Epoch 314/500
636
+ 2024-11-02 15:14:12,237 Train Loss: 0.0410120, Val Loss: 0.0596264
637
+ 2024-11-02 15:14:12,238 Epoch 315/500
638
+ 2024-11-02 15:17:24,820 Train Loss: 0.0412453, Val Loss: 0.0588437
639
+ 2024-11-02 15:17:24,820 Epoch 316/500
640
+ 2024-11-02 15:21:06,222 Train Loss: 0.0407807, Val Loss: 0.0597100
641
+ 2024-11-02 15:21:06,222 Epoch 317/500
642
+ 2024-11-02 15:24:04,940 Train Loss: 0.0406798, Val Loss: 0.0594845
643
+ 2024-11-02 15:24:04,940 Epoch 318/500
644
+ 2024-11-02 15:27:03,695 Train Loss: 0.0409038, Val Loss: 0.0593843
645
+ 2024-11-02 15:27:03,695 Epoch 319/500
646
+ 2024-11-02 15:30:01,087 Train Loss: 0.0403016, Val Loss: 0.0592302
647
+ 2024-11-02 15:30:01,087 Epoch 320/500
648
+ 2024-11-02 15:33:03,522 Train Loss: 0.0410438, Val Loss: 0.0602990
649
+ 2024-11-02 15:33:03,522 Epoch 321/500
650
+ 2024-11-02 15:36:01,446 Train Loss: 0.0409603, Val Loss: 0.0601965
651
+ 2024-11-02 15:36:01,446 Epoch 322/500
652
+ 2024-11-02 15:39:01,771 Train Loss: 0.0412127, Val Loss: 0.0597409
653
+ 2024-11-02 15:39:01,771 Epoch 323/500
654
+ 2024-11-02 15:42:01,298 Train Loss: 0.0417300, Val Loss: 0.0597532
655
+ 2024-11-02 15:42:01,299 Epoch 324/500
656
+ 2024-11-02 15:45:30,788 Train Loss: 0.0418059, Val Loss: 0.0599914
657
+ 2024-11-02 15:45:30,788 Epoch 325/500
658
+ 2024-11-02 15:48:56,593 Train Loss: 0.0418212, Val Loss: 0.0594606
659
+ 2024-11-02 15:48:56,593 Epoch 326/500
660
+ 2024-11-02 15:51:55,467 Train Loss: 0.0411545, Val Loss: 0.0596464
661
+ 2024-11-02 15:51:55,468 Epoch 327/500
662
+ 2024-11-02 15:55:28,297 Train Loss: 0.0410273, Val Loss: 0.0599024
663
+ 2024-11-02 15:55:28,298 Epoch 328/500
664
+ 2024-11-02 15:58:49,204 Train Loss: 0.0407685, Val Loss: 0.0587076
665
+ 2024-11-02 15:58:49,204 Epoch 329/500
666
+ 2024-11-02 16:01:56,308 Train Loss: 0.0405287, Val Loss: 0.0585450
667
+ 2024-11-02 16:01:56,308 Epoch 330/500
668
+ 2024-11-02 16:05:38,900 Train Loss: 0.0408748, Val Loss: 0.0579685
669
+ 2024-11-02 16:05:38,900 Epoch 331/500
670
+ 2024-11-02 16:08:39,207 Train Loss: 0.0409528, Val Loss: 0.0580340
671
+ 2024-11-02 16:08:39,208 Epoch 332/500
672
+ 2024-11-02 16:11:38,415 Train Loss: 0.0413668, Val Loss: 0.0586145
673
+ 2024-11-02 16:11:38,416 Epoch 333/500
674
+ 2024-11-02 16:15:30,627 Train Loss: 0.0415958, Val Loss: 0.0582683
675
+ 2024-11-02 16:15:30,628 Epoch 334/500
676
+ 2024-11-02 16:18:28,255 Train Loss: 0.0419676, Val Loss: 0.0592931
677
+ 2024-11-02 16:18:28,256 Epoch 335/500
678
+ 2024-11-02 16:21:24,581 Train Loss: 0.0414313, Val Loss: 0.0581618
679
+ 2024-11-02 16:21:24,581 Epoch 336/500
680
+ 2024-11-02 16:24:24,059 Train Loss: 0.0414570, Val Loss: 0.0577461
681
+ 2024-11-02 16:24:24,059 Epoch 337/500
682
+ 2024-11-02 16:27:22,446 Train Loss: 0.0423431, Val Loss: 0.0578982
683
+ 2024-11-02 16:27:22,447 Epoch 338/500
684
+ 2024-11-02 16:30:19,873 Train Loss: 0.0419595, Val Loss: 0.0576586
685
+ 2024-11-02 16:30:19,873 Epoch 339/500
686
+ 2024-11-02 16:33:56,030 Train Loss: 0.0411537, Val Loss: 0.0575664
687
+ 2024-11-02 16:33:56,030 Epoch 340/500
688
+ 2024-11-02 16:37:12,219 Train Loss: 0.0410217, Val Loss: 0.0573184
689
+ 2024-11-02 16:37:12,219 Epoch 341/500
690
+ 2024-11-02 16:40:13,544 Train Loss: 0.0410328, Val Loss: 0.0578781
691
+ 2024-11-02 16:40:13,545 Epoch 342/500
692
+ 2024-11-02 16:43:18,809 Train Loss: 0.0411319, Val Loss: 0.0586561
693
+ 2024-11-02 16:43:18,809 Epoch 343/500
694
+ 2024-11-02 16:47:08,796 Train Loss: 0.0411878, Val Loss: 0.0590822
695
+ 2024-11-02 16:47:08,796 Epoch 344/500
696
+ 2024-11-02 16:50:10,317 Train Loss: 0.0409471, Val Loss: 0.0590031
697
+ 2024-11-02 16:50:10,318 Epoch 345/500
698
+ 2024-11-02 16:53:07,772 Train Loss: 0.0403242, Val Loss: 0.0582457
699
+ 2024-11-02 16:53:07,772 Epoch 346/500
700
+ 2024-11-02 16:56:06,252 Train Loss: 0.0398690, Val Loss: 0.0583578
701
+ 2024-11-02 16:56:06,252 Epoch 347/500
702
+ 2024-11-02 16:59:22,260 Train Loss: 0.0397748, Val Loss: 0.0579849
703
+ 2024-11-02 16:59:22,260 Epoch 348/500
704
+ 2024-11-02 17:03:01,150 Train Loss: 0.0400483, Val Loss: 0.0584467
705
+ 2024-11-02 17:03:01,151 Epoch 349/500
706
+ 2024-11-02 17:05:59,962 Train Loss: 0.0401085, Val Loss: 0.0580592
707
+ 2024-11-02 17:05:59,962 Epoch 350/500
708
+ 2024-11-02 17:09:43,899 Train Loss: 0.0397280, Val Loss: 0.0584481
709
+ 2024-11-02 17:09:43,900 Epoch 351/500
710
+ 2024-11-02 17:12:52,647 Train Loss: 0.0403896, Val Loss: 0.0580628
711
+ 2024-11-02 17:12:52,648 Epoch 352/500
712
+ 2024-11-02 17:15:53,901 Train Loss: 0.0398922, Val Loss: 0.0579900
713
+ 2024-11-02 17:15:53,902 Epoch 353/500
714
+ 2024-11-02 17:19:40,538 Train Loss: 0.0399874, Val Loss: 0.0584608
715
+ 2024-11-02 17:19:40,539 Epoch 354/500
716
+ 2024-11-02 17:22:44,212 Train Loss: 0.0401203, Val Loss: 0.0573071
717
+ 2024-11-02 17:22:44,212 Epoch 355/500
718
+ 2024-11-02 17:25:42,570 Train Loss: 0.0406190, Val Loss: 0.0592341
719
+ 2024-11-02 17:25:42,571 Epoch 356/500
720
+ 2024-11-02 17:28:41,767 Train Loss: 0.0408931, Val Loss: 0.0589838
721
+ 2024-11-02 17:28:41,768 Epoch 357/500
722
+ 2024-11-02 17:32:07,679 Train Loss: 0.0409831, Val Loss: 0.0590234
723
+ 2024-11-02 17:32:07,679 Epoch 358/500
724
+ 2024-11-02 17:35:29,489 Train Loss: 0.0405867, Val Loss: 0.0579176
725
+ 2024-11-02 17:35:29,489 Epoch 359/500
726
+ 2024-11-02 17:38:27,832 Train Loss: 0.0405270, Val Loss: 0.0578312
727
+ 2024-11-02 17:38:27,834 Epoch 360/500
728
+ 2024-11-02 17:42:03,325 Train Loss: 0.0410094, Val Loss: 0.0579466
729
+ 2024-11-02 17:42:03,325 Epoch 361/500
730
+ 2024-11-02 17:45:16,224 Train Loss: 0.0408926, Val Loss: 0.0582639
731
+ 2024-11-02 17:45:16,224 Epoch 362/500
732
+ 2024-11-02 17:48:35,811 Train Loss: 0.0409729, Val Loss: 0.0580129
733
+ 2024-11-02 17:48:35,811 Epoch 363/500
734
+ 2024-11-02 17:52:07,111 Train Loss: 0.0404854, Val Loss: 0.0581374
735
+ 2024-11-02 17:52:07,111 Epoch 364/500
736
+ 2024-11-02 17:55:04,740 Train Loss: 0.0402474, Val Loss: 0.0577086
737
+ 2024-11-02 17:55:04,740 Epoch 365/500
738
+ 2024-11-02 17:58:31,194 Train Loss: 0.0400140, Val Loss: 0.0573770
739
+ 2024-11-02 17:58:31,194 Epoch 366/500
740
+ 2024-11-02 18:01:54,779 Train Loss: 0.0394420, Val Loss: 0.0575861
741
+ 2024-11-02 18:01:54,779 Epoch 367/500
742
+ 2024-11-02 18:04:51,633 Train Loss: 0.0390195, Val Loss: 0.0571440
743
+ 2024-11-02 18:04:51,633 Epoch 368/500
744
+ 2024-11-02 18:07:48,145 Train Loss: 0.0390252, Val Loss: 0.0575364
745
+ 2024-11-02 18:07:48,145 Epoch 369/500
746
+ 2024-11-02 18:10:45,667 Train Loss: 0.0391279, Val Loss: 0.0573542
747
+ 2024-11-02 18:10:45,668 Epoch 370/500
748
+ 2024-11-02 18:14:32,875 Train Loss: 0.0392613, Val Loss: 0.0577171
749
+ 2024-11-02 18:14:32,876 Epoch 371/500
750
+ 2024-11-02 18:18:05,367 Train Loss: 0.0390012, Val Loss: 0.0582181
751
+ 2024-11-02 18:18:05,368 Epoch 372/500
752
+ 2024-11-02 18:21:28,554 Train Loss: 0.0396738, Val Loss: 0.0588587
753
+ 2024-11-02 18:21:28,554 Epoch 373/500
754
+ 2024-11-02 18:24:25,270 Train Loss: 0.0394583, Val Loss: 0.0588800
755
+ 2024-11-02 18:24:25,271 Epoch 374/500
756
+ 2024-11-02 18:27:40,406 Train Loss: 0.0399388, Val Loss: 0.0589896
757
+ 2024-11-02 18:27:40,406 Epoch 375/500
758
+ 2024-11-02 18:31:16,299 Train Loss: 0.0399578, Val Loss: 0.0598740
759
+ 2024-11-02 18:31:16,300 Epoch 376/500
760
+ 2024-11-02 18:34:16,167 Train Loss: 0.0394974, Val Loss: 0.0580215
761
+ 2024-11-02 18:34:16,167 Epoch 377/500
762
+ 2024-11-02 18:38:00,190 Train Loss: 0.0396564, Val Loss: 0.0579727
763
+ 2024-11-02 18:38:00,191 Epoch 378/500
764
+ 2024-11-02 18:41:11,688 Train Loss: 0.0402715, Val Loss: 0.0584190
765
+ 2024-11-02 18:41:11,689 Epoch 379/500
766
+ 2024-11-02 18:44:11,388 Train Loss: 0.0405642, Val Loss: 0.0580653
767
+ 2024-11-02 18:44:11,389 Epoch 380/500
768
+ 2024-11-02 18:47:11,544 Train Loss: 0.0398939, Val Loss: 0.0587236
769
+ 2024-11-02 18:47:11,545 Epoch 381/500
770
+ 2024-11-02 18:50:46,785 Train Loss: 0.0401086, Val Loss: 0.0597313
771
+ 2024-11-02 18:50:46,786 Epoch 382/500
772
+ 2024-11-02 18:54:06,428 Train Loss: 0.0401842, Val Loss: 0.0590873
773
+ 2024-11-02 18:54:06,429 Epoch 383/500
774
+ 2024-11-02 18:57:07,851 Train Loss: 0.0403904, Val Loss: 0.0588594
775
+ 2024-11-02 18:57:07,851 Epoch 384/500
776
+ 2024-11-02 19:00:57,965 Train Loss: 0.0406806, Val Loss: 0.0588065
777
+ 2024-11-02 19:00:57,965 Epoch 385/500
778
+ 2024-11-02 19:04:06,347 Train Loss: 0.0405931, Val Loss: 0.0579386
779
+ 2024-11-02 19:04:06,347 Epoch 386/500
780
+ 2024-11-02 19:07:15,003 Train Loss: 0.0406293, Val Loss: 0.0585173
781
+ 2024-11-02 19:07:15,003 Epoch 387/500
782
+ 2024-11-02 19:10:16,047 Train Loss: 0.0397994, Val Loss: 0.0583322
783
+ 2024-11-02 19:10:16,048 Epoch 388/500
784
+ 2024-11-02 19:13:42,369 Train Loss: 0.0401114, Val Loss: 0.0588679
785
+ 2024-11-02 19:13:42,369 Epoch 389/500
786
+ 2024-11-02 19:17:06,873 Train Loss: 0.0400305, Val Loss: 0.0579988
787
+ 2024-11-02 19:17:06,873 Epoch 390/500
788
+ 2024-11-02 19:20:03,609 Train Loss: 0.0400819, Val Loss: 0.0579372
789
+ 2024-11-02 19:20:03,610 Epoch 391/500
790
+ 2024-11-02 19:23:40,201 Train Loss: 0.0400527, Val Loss: 0.0584015
791
+ 2024-11-02 19:23:40,202 Epoch 392/500
792
+ 2024-11-02 19:27:14,838 Train Loss: 0.0399731, Val Loss: 0.0586223
793
+ 2024-11-02 19:27:14,838 Epoch 393/500
794
+ 2024-11-02 19:30:13,107 Train Loss: 0.0393839, Val Loss: 0.0579094
795
+ 2024-11-02 19:30:13,108 Epoch 394/500
796
+ 2024-11-02 19:33:10,386 Train Loss: 0.0397058, Val Loss: 0.0577166
797
+ 2024-11-02 19:33:10,387 Epoch 395/500
798
+ 2024-11-02 19:36:53,632 Train Loss: 0.0389187, Val Loss: 0.0574457
799
+ 2024-11-02 19:36:53,632 Epoch 396/500
800
+ 2024-11-02 19:39:58,259 Train Loss: 0.0393241, Val Loss: 0.0581951
801
+ 2024-11-02 19:39:58,259 Epoch 397/500
802
+ 2024-11-02 19:42:54,344 Train Loss: 0.0387192, Val Loss: 0.0579340
803
+ 2024-11-02 19:42:54,344 Epoch 398/500
804
+ 2024-11-02 19:46:24,509 Train Loss: 0.0388178, Val Loss: 0.0577731
805
+ 2024-11-02 19:46:24,509 Epoch 399/500
806
+ 2024-11-02 19:49:46,061 Train Loss: 0.0389307, Val Loss: 0.0578627
807
+ 2024-11-02 19:49:46,062 Epoch 400/500
808
+ 2024-11-02 19:52:44,098 Train Loss: 0.0386144, Val Loss: 0.0579973
809
+ 2024-11-02 19:52:44,098 Epoch 401/500
810
+ 2024-11-02 19:56:05,667 Train Loss: 0.0392295, Val Loss: 0.0579757
811
+ 2024-11-02 19:56:05,667 Epoch 402/500
812
+ 2024-11-02 19:59:32,372 Train Loss: 0.0388906, Val Loss: 0.0591460
813
+ 2024-11-02 19:59:32,373 Epoch 403/500
814
+ 2024-11-02 20:02:30,281 Train Loss: 0.0383377, Val Loss: 0.0599615
815
+ 2024-11-02 20:02:30,281 Epoch 404/500
816
+ 2024-11-02 20:06:06,921 Train Loss: 0.0388708, Val Loss: 0.0586047
817
+ 2024-11-02 20:06:06,921 Epoch 405/500
818
+ 2024-11-02 20:09:21,189 Train Loss: 0.0387721, Val Loss: 0.0578503
819
+ 2024-11-02 20:09:21,190 Epoch 406/500
820
+ 2024-11-02 20:12:18,575 Train Loss: 0.0389045, Val Loss: 0.0578896
821
+ 2024-11-02 20:12:18,576 Epoch 407/500
822
+ 2024-11-02 20:15:30,692 Train Loss: 0.0390265, Val Loss: 0.0577000
823
+ 2024-11-02 20:15:30,692 Epoch 408/500
824
+ 2024-11-02 20:19:08,119 Train Loss: 0.0393684, Val Loss: 0.0574350
825
+ 2024-11-02 20:19:08,119 Epoch 409/500
826
+ 2024-11-02 20:22:09,171 Train Loss: 0.0395314, Val Loss: 0.0575468
827
+ 2024-11-02 20:22:09,172 Epoch 410/500
828
+ 2024-11-02 20:25:39,665 Train Loss: 0.0391024, Val Loss: 0.0580800
829
+ 2024-11-02 20:25:39,666 Epoch 411/500
830
+ 2024-11-02 20:29:03,500 Train Loss: 0.0390637, Val Loss: 0.0579825
831
+ 2024-11-02 20:29:03,500 Epoch 412/500
832
+ 2024-11-02 20:32:10,281 Train Loss: 0.0389488, Val Loss: 0.0583745
833
+ 2024-11-02 20:32:10,282 Epoch 413/500
834
+ 2024-11-02 20:35:48,152 Train Loss: 0.0388941, Val Loss: 0.0577608
835
+ 2024-11-02 20:35:48,152 Epoch 414/500
836
+ 2024-11-02 20:39:07,289 Train Loss: 0.0388513, Val Loss: 0.0578232
837
+ 2024-11-02 20:39:07,289 Epoch 415/500
838
+ 2024-11-02 20:42:15,604 Train Loss: 0.0390740, Val Loss: 0.0584172
839
+ 2024-11-02 20:42:15,604 Epoch 416/500
840
+ 2024-11-02 20:45:59,260 Train Loss: 0.0393258, Val Loss: 0.0587398
841
+ 2024-11-02 20:45:59,261 Epoch 417/500
842
+ 2024-11-02 20:48:59,119 Train Loss: 0.0397258, Val Loss: 0.0582443
843
+ 2024-11-02 20:48:59,119 Epoch 418/500
844
+ 2024-11-02 20:52:20,613 Train Loss: 0.0402310, Val Loss: 0.0576836
845
+ 2024-11-02 20:52:20,613 Epoch 419/500
846
+ 2024-11-02 20:55:48,145 Train Loss: 0.0392868, Val Loss: 0.0577936
847
+ 2024-11-02 20:55:48,146 Epoch 420/500
848
+ 2024-11-02 20:58:46,201 Train Loss: 0.0398394, Val Loss: 0.0568674
849
+ 2024-11-02 20:58:46,201 Epoch 421/500
850
+ 2024-11-02 21:01:45,445 Train Loss: 0.0391285, Val Loss: 0.0567561
851
+ 2024-11-02 21:01:45,445 Epoch 422/500
852
+ 2024-11-02 21:04:42,728 Train Loss: 0.0391262, Val Loss: 0.0567382
853
+ 2024-11-02 21:04:42,728 Epoch 423/500
854
+ 2024-11-02 21:08:27,228 Train Loss: 0.0387613, Val Loss: 0.0571007
855
+ 2024-11-02 21:08:27,228 Epoch 424/500
856
+ 2024-11-02 21:11:35,389 Train Loss: 0.0388678, Val Loss: 0.0569020
857
+ 2024-11-02 21:11:35,389 Epoch 425/500
858
+ 2024-11-02 21:14:49,880 Train Loss: 0.0387865, Val Loss: 0.0574812
859
+ 2024-11-02 21:14:49,881 Epoch 426/500
860
+ 2024-11-02 21:18:25,639 Train Loss: 0.0387229, Val Loss: 0.0571121
861
+ 2024-11-02 21:18:25,640 Epoch 427/500
862
+ 2024-11-02 21:21:45,145 Train Loss: 0.0390190, Val Loss: 0.0567339
863
+ 2024-11-02 21:21:45,146 Epoch 428/500
864
+ 2024-11-02 21:25:23,734 Train Loss: 0.0392649, Val Loss: 0.0566259
865
+ 2024-11-02 21:25:23,734 Epoch 429/500
866
+ 2024-11-02 21:28:21,801 Train Loss: 0.0388042, Val Loss: 0.0570679
867
+ 2024-11-02 21:28:21,802 Epoch 430/500
868
+ 2024-11-02 21:31:20,899 Train Loss: 0.0388690, Val Loss: 0.0575413
869
+ 2024-11-02 21:31:20,900 Epoch 431/500
870
+ 2024-11-02 21:35:06,997 Train Loss: 0.0383034, Val Loss: 0.0579443
871
+ 2024-11-02 21:35:06,998 Epoch 432/500
872
+ 2024-11-02 21:38:14,242 Train Loss: 0.0381320, Val Loss: 0.0577746
873
+ 2024-11-02 21:38:14,242 Epoch 433/500
874
+ 2024-11-02 21:41:17,206 Train Loss: 0.0388885, Val Loss: 0.0582790
875
+ 2024-11-02 21:41:17,206 Epoch 434/500
876
+ 2024-11-02 21:45:03,712 Train Loss: 0.0389449, Val Loss: 0.0576361
877
+ 2024-11-02 21:45:03,712 Epoch 435/500
878
+ 2024-11-02 21:48:24,850 Train Loss: 0.0389969, Val Loss: 0.0576007
879
+ 2024-11-02 21:48:24,850 Epoch 436/500
880
+ 2024-11-02 21:51:53,680 Train Loss: 0.0391282, Val Loss: 0.0565848
881
+ 2024-11-02 21:51:53,681 Epoch 437/500
882
+ 2024-11-02 21:54:53,127 Train Loss: 0.0385026, Val Loss: 0.0564438
883
+ 2024-11-02 21:54:53,127 Epoch 438/500
884
+ 2024-11-02 21:57:54,417 Train Loss: 0.0386925, Val Loss: 0.0559600
885
+ 2024-11-02 21:57:54,417 Epoch 439/500
886
+ 2024-11-02 22:01:20,923 Train Loss: 0.0391002, Val Loss: 0.0560886
887
+ 2024-11-02 22:01:20,923 Epoch 440/500
888
+ 2024-11-02 22:04:46,216 Train Loss: 0.0395528, Val Loss: 0.0559410
889
+ 2024-11-02 22:04:46,216 Epoch 441/500
890
+ 2024-11-02 22:07:46,139 Train Loss: 0.0399341, Val Loss: 0.0560736
891
+ 2024-11-02 22:07:46,139 Epoch 442/500
892
+ 2024-11-02 22:10:44,509 Train Loss: 0.0398281, Val Loss: 0.0564665
893
+ 2024-11-02 22:10:44,510 Epoch 443/500
894
+ 2024-11-02 22:14:10,688 Train Loss: 0.0400747, Val Loss: 0.0560445
895
+ 2024-11-02 22:14:10,688 Epoch 444/500
896
+ 2024-11-02 22:17:34,967 Train Loss: 0.0409284, Val Loss: 0.0565227
897
+ 2024-11-02 22:17:34,968 Epoch 445/500
898
+ 2024-11-02 22:20:33,352 Train Loss: 0.0396965, Val Loss: 0.0570916
899
+ 2024-11-02 22:20:33,352 Epoch 446/500
900
+ 2024-11-02 22:24:20,103 Train Loss: 0.0395606, Val Loss: 0.0573105
901
+ 2024-11-02 22:24:20,104 Epoch 447/500
902
+ 2024-11-02 22:27:20,865 Train Loss: 0.0394130, Val Loss: 0.0568101
903
+ 2024-11-02 22:27:20,866 Epoch 448/500
904
+ 2024-11-02 22:30:16,627 Train Loss: 0.0387025, Val Loss: 0.0570552
905
+ 2024-11-02 22:30:16,627 Epoch 449/500
906
+ 2024-11-02 22:34:04,620 Train Loss: 0.0392206, Val Loss: 0.0567237
907
+ 2024-11-02 22:34:04,620 Epoch 450/500
908
+ 2024-11-02 22:37:06,377 Train Loss: 0.0384510, Val Loss: 0.0560127
909
+ 2024-11-02 22:37:06,377 Epoch 451/500
910
+ 2024-11-02 22:40:12,127 Train Loss: 0.0385708, Val Loss: 0.0567452
911
+ 2024-11-02 22:40:12,132 Epoch 452/500
912
+ 2024-11-02 22:43:56,311 Train Loss: 0.0382739, Val Loss: 0.0563417
913
+ 2024-11-02 22:43:56,312 Epoch 453/500
914
+ 2024-11-02 22:47:08,413 Train Loss: 0.0376996, Val Loss: 0.0558982
915
+ 2024-11-02 22:47:08,414 Epoch 454/500
916
+ 2024-11-02 22:50:49,669 Train Loss: 0.0374447, Val Loss: 0.0556690
917
+ 2024-11-02 22:50:49,670 Epoch 455/500
918
+ 2024-11-02 22:53:49,007 Train Loss: 0.0376442, Val Loss: 0.0558452
919
+ 2024-11-02 22:53:49,008 Epoch 456/500
920
+ 2024-11-02 22:56:47,089 Train Loss: 0.0376348, Val Loss: 0.0559104
921
+ 2024-11-02 22:56:47,090 Epoch 457/500
922
+ 2024-11-02 23:00:23,064 Train Loss: 0.0373049, Val Loss: 0.0559752
923
+ 2024-11-02 23:00:23,064 Epoch 458/500
924
+ 2024-11-02 23:03:36,628 Train Loss: 0.0373410, Val Loss: 0.0557501
925
+ 2024-11-02 23:03:36,628 Epoch 459/500
926
+ 2024-11-02 23:06:56,943 Train Loss: 0.0376213, Val Loss: 0.0554219
927
+ 2024-11-02 23:06:56,943 Epoch 460/500
928
+ 2024-11-02 23:10:25,010 Train Loss: 0.0374262, Val Loss: 0.0553996
929
+ 2024-11-02 23:10:25,010 Epoch 461/500
930
+ 2024-11-02 23:13:21,931 Train Loss: 0.0377059, Val Loss: 0.0553632
931
+ 2024-11-02 23:13:21,931 Epoch 462/500
932
+ 2024-11-02 23:16:19,013 Train Loss: 0.0369894, Val Loss: 0.0554736
933
+ 2024-11-02 23:16:19,013 Epoch 463/500
934
+ 2024-11-02 23:19:53,004 Train Loss: 0.0374426, Val Loss: 0.0555118
935
+ 2024-11-02 23:19:53,004 Epoch 464/500
936
+ 2024-11-02 23:23:10,115 Train Loss: 0.0374760, Val Loss: 0.0559440
937
+ 2024-11-02 23:23:10,115 Epoch 465/500
938
+ 2024-11-02 23:26:29,706 Train Loss: 0.0377081, Val Loss: 0.0563126
939
+ 2024-11-02 23:26:29,707 Epoch 466/500
940
+ 2024-11-02 23:29:59,147 Train Loss: 0.0377832, Val Loss: 0.0564361
941
+ 2024-11-02 23:29:59,147 Epoch 467/500
942
+ 2024-11-02 23:33:00,675 Train Loss: 0.0378480, Val Loss: 0.0565159
943
+ 2024-11-02 23:33:00,676 Epoch 468/500
944
+ 2024-11-02 23:36:47,620 Train Loss: 0.0381216, Val Loss: 0.0563773
945
+ 2024-11-02 23:36:47,620 Epoch 469/500
946
+ 2024-11-02 23:39:46,182 Train Loss: 0.0386798, Val Loss: 0.0571887
947
+ 2024-11-02 23:39:46,183 Epoch 470/500
948
+ 2024-11-02 23:42:44,607 Train Loss: 0.0386984, Val Loss: 0.0576652
949
+ 2024-11-02 23:42:44,607 Epoch 471/500
950
+ 2024-11-02 23:45:43,140 Train Loss: 0.0386614, Val Loss: 0.0570068
951
+ 2024-11-02 23:45:43,140 Epoch 472/500
952
+ 2024-11-02 23:48:59,929 Train Loss: 0.0386925, Val Loss: 0.0559145
953
+ 2024-11-02 23:48:59,929 Epoch 473/500
954
+ 2024-11-02 23:52:37,953 Train Loss: 0.0388576, Val Loss: 0.0563857
955
+ 2024-11-02 23:52:37,953 Epoch 474/500
956
+ 2024-11-02 23:55:50,616 Train Loss: 0.0383907, Val Loss: 0.0573166
957
+ 2024-11-02 23:55:50,617 Epoch 475/500
958
+ 2024-11-02 23:59:35,482 Train Loss: 0.0382544, Val Loss: 0.0566372
959
+ 2024-11-02 23:59:35,482 Epoch 476/500
960
+ 2024-11-03 00:03:13,219 Train Loss: 0.0385290, Val Loss: 0.0559754
961
+ 2024-11-03 00:03:13,219 Epoch 477/500
962
+ 2024-11-03 00:06:28,398 Train Loss: 0.0379065, Val Loss: 0.0557118
963
+ 2024-11-03 00:06:28,399 Epoch 478/500
964
+ 2024-11-03 00:09:26,315 Train Loss: 0.0383753, Val Loss: 0.0557908
965
+ 2024-11-03 00:09:26,316 Epoch 479/500
966
+ 2024-11-03 00:13:15,129 Train Loss: 0.0377758, Val Loss: 0.0557593
967
+ 2024-11-03 00:13:15,130 Epoch 480/500
968
+ 2024-11-03 00:16:12,726 Train Loss: 0.0373506, Val Loss: 0.0559643
969
+ 2024-11-03 00:16:12,727 Epoch 481/500
970
+ 2024-11-03 00:19:10,168 Train Loss: 0.0372199, Val Loss: 0.0566857
971
+ 2024-11-03 00:19:10,168 Epoch 482/500
972
+ 2024-11-03 00:22:07,301 Train Loss: 0.0371610, Val Loss: 0.0558072
973
+ 2024-11-03 00:22:07,301 Epoch 483/500
974
+ 2024-11-03 00:25:16,442 Train Loss: 0.0369303, Val Loss: 0.0557542
975
+ 2024-11-03 00:25:16,443 Epoch 484/500
976
+ 2024-11-03 00:28:55,691 Train Loss: 0.0367464, Val Loss: 0.0557234
977
+ 2024-11-03 00:28:55,691 Epoch 485/500
978
+ 2024-11-03 00:31:55,121 Train Loss: 0.0369893, Val Loss: 0.0562180
979
+ 2024-11-03 00:31:55,121 Epoch 486/500
980
+ 2024-11-03 00:34:56,180 Train Loss: 0.0372507, Val Loss: 0.0560992
981
+ 2024-11-03 00:34:56,180 Epoch 487/500
982
+ 2024-11-03 00:38:46,146 Train Loss: 0.0373390, Val Loss: 0.0555817
983
+ 2024-11-03 00:38:46,146 Epoch 488/500
984
+ 2024-11-03 00:41:47,966 Train Loss: 0.0371835, Val Loss: 0.0561714
985
+ 2024-11-03 00:41:47,967 Epoch 489/500
986
+ 2024-11-03 00:44:44,799 Train Loss: 0.0372496, Val Loss: 0.0555808
987
+ 2024-11-03 00:44:44,800 Epoch 490/500
988
+ 2024-11-03 00:48:23,255 Train Loss: 0.0373195, Val Loss: 0.0555320
989
+ 2024-11-03 00:48:23,255 Epoch 491/500
990
+ 2024-11-03 00:51:35,216 Train Loss: 0.0376244, Val Loss: 0.0558077
991
+ 2024-11-03 00:51:35,217 Epoch 492/500
992
+ 2024-11-03 00:54:46,920 Train Loss: 0.0376095, Val Loss: 0.0558452
993
+ 2024-11-03 00:54:46,921 Epoch 493/500
994
+ 2024-11-03 00:58:30,336 Train Loss: 0.0372585, Val Loss: 0.0557160
995
+ 2024-11-03 00:58:30,336 Epoch 494/500
996
+ 2024-11-03 01:01:33,647 Train Loss: 0.0376758, Val Loss: 0.0563320
997
+ 2024-11-03 01:01:33,648 Epoch 495/500
998
+ 2024-11-03 01:05:07,852 Train Loss: 0.0371837, Val Loss: 0.0561041
999
+ 2024-11-03 01:05:07,853 Epoch 496/500
1000
+ 2024-11-03 01:08:25,195 Train Loss: 0.0376199, Val Loss: 0.0559861
1001
+ 2024-11-03 01:08:25,195 Epoch 497/500
1002
+ 2024-11-03 01:11:37,813 Train Loss: 0.0373268, Val Loss: 0.0553711
1003
+ 2024-11-03 01:11:37,814 Epoch 498/500
1004
+ 2024-11-03 01:15:16,007 Train Loss: 0.0373039, Val Loss: 0.0554337
1005
+ 2024-11-03 01:15:16,007 Epoch 499/500
1006
+ 2024-11-03 01:18:15,856 Train Loss: 0.0373263, Val Loss: 0.0555723
1007
+ 2024-11-03 01:18:15,856 Epoch 500/500
1008
+ 2024-11-03 01:21:55,890 Train Loss: 0.0373820, Val Loss: 0.0555461
1009
+ 2024-11-03 01:22:22,918 Testing completed and best model saved.
Exp1_Global_weather_forecasting/logs/triton_weather_20250326_v1.log ADDED
The diff for this file is too large to render. See raw diff
 
Exp1_Global_weather_forecasting/model/Triton_model.py ADDED
@@ -0,0 +1,516 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from torch import nn
3
+ import math
4
+ from timm.layers import DropPath, trunc_normal_
5
+
6
+ def stride_generator(N, reverse=False):
7
+ strides = [1, 2] * 10
8
+ if reverse:
9
+ return list(reversed(strides[:N]))
10
+ else:
11
+ return strides[:N]
12
+
13
+ class MLP(nn.Module):
14
+ def __init__(self, in_features, hidden_features=None, out_features=None, act_layer=nn.GELU, drop=0.):
15
+ super(MLP, self).__init__()
16
+ out_features = out_features or in_features
17
+ hidden_features = hidden_features or in_features
18
+ self.fc1 = nn.Linear(in_features, hidden_features)
19
+ self.act = act_layer()
20
+ self.fc2 = nn.Linear(hidden_features, out_features)
21
+ self.drop = nn.Dropout(drop)
22
+
23
+ def forward(self, x):
24
+ x = self.fc1(x)
25
+ x = self.act(x)
26
+ x = self.drop(x)
27
+ x = self.fc2(x)
28
+ x = self.drop(x)
29
+ return x
30
+
31
+ class ConvMLP(nn.Module):
32
+ def __init__(self, in_features, hidden_features=None, out_features=None, act_layer=nn.GELU, drop=0.):
33
+ super(ConvMLP, self).__init__()
34
+ out_features = out_features or in_features
35
+ hidden_features = hidden_features or in_features
36
+ self.fc1 = nn.Conv2d(in_features, hidden_features, 1)
37
+ self.act = act_layer()
38
+ self.fc2 = nn.Conv2d(hidden_features, out_features, 1)
39
+ self.drop = nn.Dropout(drop)
40
+
41
+ def forward(self, x):
42
+ x = self.fc1(x)
43
+ x = self.act(x)
44
+ x = self.drop(x)
45
+ x = self.fc2(x)
46
+ x = self.drop(x)
47
+ return x
48
+
49
+ class Attention(nn.Module):
50
+ def __init__(self, dim, num_heads=8, qkv_bias=False, qk_scale=None, attn_drop=0., proj_drop=0.):
51
+ super(Attention, self).__init__()
52
+ self.num_heads = num_heads
53
+ head_dim = dim // num_heads
54
+ self.scale = qk_scale or head_dim ** -0.5
55
+
56
+ self.qkv = nn.Linear(dim, dim * 3, bias=qkv_bias)
57
+ self.attn_drop = nn.Dropout(attn_drop)
58
+ self.proj = nn.Linear(dim, dim)
59
+ self.proj_drop = nn.Dropout(proj_drop)
60
+
61
+ def forward(self, x):
62
+ B, N, C = x.shape
63
+ qkv = (
64
+ self.qkv(x)
65
+ .reshape(B, N, 3, self.num_heads, C // self.num_heads)
66
+ .permute(2, 0, 3, 1, 4)
67
+ )
68
+ q, k, v = qkv[0], qkv[1], qkv[2]
69
+
70
+ attn = (q @ k.transpose(-2, -1)) * self.scale
71
+ attn = attn.softmax(dim=-1)
72
+ attn = self.attn_drop(attn)
73
+
74
+ x = (attn @ v).transpose(1, 2).reshape(B, N, C)
75
+ x = self.proj(x)
76
+ x = self.proj_drop(x)
77
+ return x
78
+
79
+ class ConvBlock(nn.Module):
80
+ def __init__(
81
+ self,
82
+ dim,
83
+ num_heads=4,
84
+ mlp_ratio=4.,
85
+ qkv_bias=False,
86
+ qk_scale=None,
87
+ drop=0.,
88
+ attn_drop=0.,
89
+ drop_path=0.,
90
+ act_layer=nn.GELU,
91
+ norm_layer=nn.LayerNorm
92
+ ):
93
+ super(ConvBlock, self).__init__()
94
+ self.pos_embed = nn.Conv2d(dim, dim, 3, padding=1, groups=dim)
95
+ self.norm1 = nn.BatchNorm2d(dim)
96
+ self.conv1 = nn.Conv2d(dim, dim, 1)
97
+ self.conv2 = nn.Conv2d(dim, dim, 1)
98
+ self.attn = nn.Conv2d(dim, dim, 5, padding=2, groups=dim)
99
+ self.drop_path = DropPath(drop_path) if drop_path > 0. else nn.Identity()
100
+ self.norm2 = nn.BatchNorm2d(dim)
101
+ mlp_hidden_dim = int(dim * mlp_ratio)
102
+ self.mlp = ConvMLP(
103
+ in_features=dim,
104
+ hidden_features=mlp_hidden_dim,
105
+ act_layer=act_layer,
106
+ drop=drop
107
+ )
108
+
109
+ self.apply(self._init_weights)
110
+
111
+ def _init_weights(self, m):
112
+ if isinstance(m, (nn.LayerNorm, nn.GroupNorm, nn.BatchNorm2d)):
113
+ nn.init.constant_(m.bias, 0)
114
+ nn.init.constant_(m.weight, 1.0)
115
+ elif isinstance(m, nn.Conv2d):
116
+ fan_out = (
117
+ m.kernel_size[0] * m.kernel_size[1] * m.out_channels
118
+ )
119
+ fan_out //= m.groups
120
+ m.weight.data.normal_(0, math.sqrt(2.0 / fan_out))
121
+ if m.bias is not None:
122
+ m.bias.data.zero_()
123
+
124
+ @torch.jit.ignore
125
+ def no_weight_decay(self):
126
+ return {}
127
+
128
+ def forward(self, x):
129
+ x = x + self.pos_embed(x)
130
+ x = x + self.drop_path(
131
+ self.conv2(self.attn(self.conv1(self.norm1(x))))
132
+ )
133
+ x = x + self.drop_path(self.mlp(self.norm2(x)))
134
+ return x
135
+
136
+ class SelfAttentionBlock(nn.Module):
137
+ def __init__(
138
+ self,
139
+ dim,
140
+ num_heads,
141
+ mlp_ratio=4.,
142
+ qkv_bias=False,
143
+ qk_scale=None,
144
+ drop=0.,
145
+ attn_drop=0.,
146
+ drop_path=0.,
147
+ init_value=1e-6,
148
+ act_layer=nn.GELU,
149
+ norm_layer=nn.LayerNorm
150
+ ):
151
+ super(SelfAttentionBlock, self).__init__()
152
+ self.pos_embed = nn.Conv2d(dim, dim, 3, padding=1, groups=dim)
153
+ self.norm1 = norm_layer(dim)
154
+ self.attn = Attention(
155
+ dim,
156
+ num_heads=num_heads,
157
+ qkv_bias=qkv_bias,
158
+ qk_scale=qk_scale,
159
+ attn_drop=attn_drop,
160
+ proj_drop=drop
161
+ )
162
+ self.drop_path = DropPath(drop_path) if drop_path > 0. else nn.Identity()
163
+ self.norm2 = norm_layer(dim)
164
+ mlp_hidden_dim = int(dim * mlp_ratio)
165
+ self.mlp = MLP(
166
+ in_features=dim,
167
+ hidden_features=mlp_hidden_dim,
168
+ act_layer=act_layer,
169
+ drop=drop
170
+ )
171
+ self.gamma_1 = nn.Parameter(init_value * torch.ones((dim)), requires_grad=True)
172
+ self.gamma_2 = nn.Parameter(init_value * torch.ones((dim)), requires_grad=True)
173
+
174
+ self.apply(self._init_weights)
175
+
176
+ def _init_weights(self, m):
177
+ if isinstance(m, nn.Linear):
178
+ trunc_normal_(m.weight, std=.02)
179
+ if isinstance(m, nn.Linear) and m.bias is not None:
180
+ nn.init.constant_(m.bias, 0)
181
+ elif isinstance(m, (nn.LayerNorm, nn.GroupNorm, nn.BatchNorm2d)):
182
+ nn.init.constant_(m.bias, 0)
183
+ nn.init.constant_(m.weight, 1.0)
184
+
185
+ @torch.jit.ignore
186
+ def no_weight_decay(self):
187
+ return {'gamma_1', 'gamma_2'}
188
+
189
+ def forward(self, x):
190
+ x = x + self.pos_embed(x)
191
+ B, N, H, W = x.shape
192
+ x = x.flatten(2).transpose(1, 2)
193
+ x = x + self.drop_path(self.gamma_1 * self.attn(self.norm1(x)))
194
+ x = x + self.drop_path(self.gamma_2 * self.mlp(self.norm2(x)))
195
+ x = x.transpose(1, 2).reshape(B, N, H, W)
196
+ return x
197
+
198
+ def UniformerSubBlock(
199
+ embed_dims,
200
+ mlp_ratio=4.,
201
+ drop=0.,
202
+ drop_path=0.,
203
+ init_value=1e-6,
204
+ block_type='Conv'
205
+ ):
206
+ assert block_type in ['Conv', 'MHSA']
207
+ if block_type == 'Conv':
208
+ # return ConvBlock(dim=embed_dims, mlp_ratio=mlp_ratio, drop=drop, drop_path=drop_path)
209
+ return SelfAttentionBlock(
210
+ dim=embed_dims,
211
+ num_heads=8,
212
+ mlp_ratio=mlp_ratio,
213
+ qkv_bias=True,
214
+ drop=drop,
215
+ drop_path=drop_path,
216
+ init_value=init_value
217
+ )
218
+ else:
219
+ return SelfAttentionBlock(
220
+ dim=embed_dims,
221
+ num_heads=8,
222
+ mlp_ratio=mlp_ratio,
223
+ qkv_bias=True,
224
+ drop=drop,
225
+ drop_path=drop_path,
226
+ init_value=init_value
227
+ )
228
+
229
+ class SpatioTemporalEvolutionBlock(nn.Module):
230
+ def __init__(
231
+ self,
232
+ in_channels,
233
+ out_channels,
234
+ input_resolution=None,
235
+ mlp_ratio=8.,
236
+ drop=0.0,
237
+ drop_path=0.0,
238
+ layer_i=0
239
+ ):
240
+ super(SpatioTemporalEvolutionBlock, self).__init__()
241
+ self.in_channels = in_channels
242
+ self.out_channels = out_channels
243
+ block_type = 'MHSA' if in_channels == out_channels and layer_i > 0 else 'Conv'
244
+ self.block = UniformerSubBlock(
245
+ in_channels,
246
+ mlp_ratio=mlp_ratio,
247
+ drop=drop,
248
+ drop_path=drop_path,
249
+ block_type=block_type
250
+ )
251
+
252
+ if in_channels != out_channels:
253
+ self.reduction = nn.Conv2d(
254
+ in_channels,
255
+ out_channels,
256
+ kernel_size=1,
257
+ stride=1,
258
+ padding=0
259
+ )
260
+
261
+ def forward(self, x):
262
+ z = self.block(x)
263
+ if self.in_channels != self.out_channels:
264
+ z = self.reduction(z)
265
+ return z
266
+
267
+ class SpatioTemporalEvolution(nn.Module):
268
+ def __init__(
269
+ self,
270
+ channel_in,
271
+ channel_hid,
272
+ N2,
273
+ input_resolution=None,
274
+ mlp_ratio=4.,
275
+ drop=0.0,
276
+ drop_path=0.1
277
+ ):
278
+ super(SpatioTemporalEvolution, self).__init__()
279
+ assert N2 >= 2 and mlp_ratio > 1
280
+ self.N2 = N2
281
+ dpr = [x.item() for x in torch.linspace(1e-2, drop_path, self.N2)]
282
+
283
+ evolution_layers = [SpatioTemporalEvolutionBlock(
284
+ channel_in,
285
+ channel_hid,
286
+ input_resolution,
287
+ mlp_ratio=mlp_ratio,
288
+ drop=drop,
289
+ drop_path=dpr[0],
290
+ layer_i=0
291
+ )]
292
+
293
+ for i in range(1, N2 - 1):
294
+ evolution_layers.append(SpatioTemporalEvolutionBlock(
295
+ channel_hid,
296
+ channel_hid,
297
+ input_resolution,
298
+ mlp_ratio=mlp_ratio,
299
+ drop=drop,
300
+ drop_path=dpr[i],
301
+ layer_i=i
302
+ ))
303
+
304
+ evolution_layers.append(SpatioTemporalEvolutionBlock(
305
+ channel_hid,
306
+ channel_in,
307
+ input_resolution,
308
+ mlp_ratio=mlp_ratio,
309
+ drop=drop,
310
+ drop_path=drop_path,
311
+ layer_i=N2 - 1
312
+ ))
313
+ self.enc = nn.Sequential(*evolution_layers)
314
+
315
+ def forward(self, x):
316
+ B, T, C, H, W = x.shape
317
+ x = x.reshape(B, T * C, H, W)
318
+ z = x
319
+ for i in range(self.N2):
320
+ z = self.enc[i](z)
321
+ y = z.reshape(B, T, C, H, W)
322
+ return y
323
+
324
+ class BasicConv2d(nn.Module):
325
+ def __init__(
326
+ self,
327
+ in_channels,
328
+ out_channels,
329
+ kernel_size,
330
+ stride,
331
+ padding,
332
+ transpose=False,
333
+ act_norm=False
334
+ ):
335
+ super(BasicConv2d, self).__init__()
336
+ self.act_norm = act_norm
337
+ if not transpose:
338
+ self.conv = nn.Conv2d(
339
+ in_channels,
340
+ out_channels,
341
+ kernel_size=kernel_size,
342
+ stride=stride,
343
+ padding=padding
344
+ )
345
+ else:
346
+ self.conv = nn.ConvTranspose2d(
347
+ in_channels,
348
+ out_channels,
349
+ kernel_size=kernel_size,
350
+ stride=stride,
351
+ padding=padding,
352
+ output_padding=stride // 2
353
+ )
354
+ self.norm = nn.GroupNorm(2, out_channels)
355
+ self.act = nn.LeakyReLU(0.2, inplace=True)
356
+
357
+ def forward(self, x):
358
+ y = self.conv(x)
359
+ if self.act_norm:
360
+ y = self.act(self.norm(y))
361
+ return y
362
+
363
+ class ConvDynamicsLayer(nn.Module):
364
+ def __init__(self, C_in, C_out, stride, transpose=False, act_norm=True):
365
+ super(ConvDynamicsLayer, self).__init__()
366
+ if stride == 1:
367
+ transpose = False
368
+ self.conv = BasicConv2d(
369
+ C_in,
370
+ C_out,
371
+ kernel_size=3,
372
+ stride=stride,
373
+ padding=1,
374
+ transpose=transpose,
375
+ act_norm=act_norm
376
+ )
377
+
378
+ def forward(self, x):
379
+ y = self.conv(x)
380
+ return y
381
+
382
+ class MultiGroupConv2d(nn.Module):
383
+ def __init__(
384
+ self,
385
+ in_channels,
386
+ out_channels,
387
+ kernel_size,
388
+ stride,
389
+ padding,
390
+ groups,
391
+ act_norm=False
392
+ ):
393
+ super(MultiGroupConv2d, self).__init__()
394
+ self.act_norm = act_norm
395
+ if in_channels % groups != 0:
396
+ groups = 1
397
+ self.conv = nn.Conv2d(
398
+ in_channels,
399
+ out_channels,
400
+ kernel_size=kernel_size,
401
+ stride=stride,
402
+ padding=padding,
403
+ groups=groups
404
+ )
405
+ self.norm = nn.GroupNorm(groups, out_channels)
406
+ self.activate = nn.LeakyReLU(0.2, inplace=True)
407
+
408
+ def forward(self, x):
409
+ y = self.conv(x)
410
+ if self.act_norm:
411
+ y = self.activate(self.norm(y))
412
+ return y
413
+
414
+
415
+ class AtmosphericEncoder(nn.Module):
416
+ def __init__(self, C_in, spatial_hidden_dim, num_spatial_layers):
417
+ super(AtmosphericEncoder, self).__init__()
418
+ strides = stride_generator(num_spatial_layers)
419
+ self.enc = nn.Sequential(
420
+ ConvDynamicsLayer(C_in, spatial_hidden_dim, stride=strides[0]),
421
+ *[ConvDynamicsLayer(spatial_hidden_dim, spatial_hidden_dim, stride=s) for s in strides[1:]]
422
+ )
423
+
424
+ def forward(self, x):
425
+ enc1 = self.enc[0](x)
426
+ latent = enc1
427
+ for i in range(1, len(self.enc)):
428
+ latent = self.enc[i](latent)
429
+ return latent, enc1
430
+
431
+ class AtmosphericDecoder(nn.Module):
432
+ def __init__(self, spatial_hidden_dim, C_out, num_spatial_layers):
433
+ super(AtmosphericDecoder, self).__init__()
434
+ strides = stride_generator(num_spatial_layers, reverse=True)
435
+ self.dec = nn.Sequential(
436
+ *[ConvDynamicsLayer(spatial_hidden_dim, spatial_hidden_dim, stride=s, transpose=True) for s in strides[:-1]],
437
+ ConvDynamicsLayer(2 * spatial_hidden_dim, spatial_hidden_dim, stride=strides[-1], transpose=True)
438
+ )
439
+ self.readout = nn.Conv2d(spatial_hidden_dim, C_out, 1)
440
+
441
+ def forward(self, hid, enc1=None):
442
+ for i in range(0, len(self.dec) - 1):
443
+ hid = self.dec[i](hid)
444
+ Y = self.dec[-1](torch.cat([hid, enc1], dim=1))
445
+ Y = self.readout(Y)
446
+ return Y
447
+
448
+ class Triton(nn.Module):
449
+ def __init__(
450
+ self,
451
+ shape_in,
452
+ spatial_hidden_dim=64,
453
+ output_channels=4,
454
+ temporal_hidden_dim=128,
455
+ num_spatial_layers=4,
456
+ num_temporal_layers=8,
457
+ in_time_seq_length=10,
458
+ out_time_seq_length=10
459
+ ):
460
+ super(Triton, self).__init__()
461
+ T, C, H, W = shape_in
462
+ self.H1 = int(H / 2 ** (num_spatial_layers / 2)) + 1 if H % 3 == 0 else int(H / 2 ** (num_spatial_layers / 2))
463
+ self.W1 = int(W / 2 ** (num_spatial_layers / 2))
464
+ self.output_dim = output_channels
465
+ self.input_time_seq_length = in_time_seq_length
466
+ self.output_time_seq_length = out_time_seq_length
467
+
468
+ self.atmospheric_encoder = AtmosphericEncoder(C, spatial_hidden_dim, num_spatial_layers)
469
+ self.temporal_evolution = SpatioTemporalEvolution(
470
+ T * spatial_hidden_dim,
471
+ temporal_hidden_dim,
472
+ num_temporal_layers,
473
+ input_resolution=[self.H1, self.W1],
474
+ mlp_ratio=4.0,
475
+ drop_path=0.1
476
+ )
477
+ self.atmospheric_decoder = AtmosphericDecoder(spatial_hidden_dim, self.output_dim, num_spatial_layers)
478
+
479
+ def forward(self, input_state):
480
+ """
481
+ 1. Reshape the input state to match the encoder's input requirements.
482
+ 2. Extract features using the Atmospheric Encoder and obtain skip connections.
483
+ 3. Perform spatio-temporal evolution on the encoded features.
484
+ 4. Decode the evolved features to generate the final output.
485
+ """
486
+ batch_size, temporal_length, channels, height, width = input_state.shape
487
+ reshaped_input = input_state.view(batch_size * temporal_length, channels, height, width)
488
+
489
+ encoded_features, skip_connection = self.atmospheric_encoder(reshaped_input)
490
+ _, encoded_channels, encoded_height, encoded_width = encoded_features.shape
491
+ encoded_features = encoded_features.view(batch_size, temporal_length, encoded_channels, encoded_height, encoded_width)
492
+
493
+ temporal_bias = encoded_features
494
+ temporal_hidden = self.temporal_evolution(temporal_bias)
495
+ reshaped_hidden = temporal_hidden.view(batch_size * temporal_length, encoded_channels, encoded_height, encoded_width)
496
+
497
+ decoded_output = self.atmospheric_decoder(reshaped_hidden, skip_connection)
498
+ final_output = decoded_output.view(batch_size, temporal_length, -1, height, width)
499
+
500
+ return final_output
501
+
502
+
503
+ def count_parameters(model):
504
+ return sum(p.numel() for p in model.parameters() if p.requires_grad)
505
+
506
+ if __name__ == '__main__':
507
+ inputs = torch.randn(1, 1, 69, 180, 360)
508
+ model = Triton(
509
+ shape_in=(1, 69, 180, 360),
510
+ spatial_hidden_dim=64,
511
+ output_channels=69,
512
+ temporal_hidden_dim=128,
513
+ num_spatial_layers=4,
514
+ num_temporal_layers=8)
515
+ output = model(inputs)
516
+ print(output.shape)
Exp1_Global_weather_forecasting/model_baselines/fuxi_model.py ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from torch import nn
3
+ from torch.nn import functional as F
4
+ from timm.layers.helpers import to_2tuple
5
+ from timm.models.swin_transformer_v2 import SwinTransformerV2Stage
6
+
7
+ from typing import Sequence
8
+
9
+
10
+
11
+ def get_pad3d(input_resolution, window_size):
12
+ """
13
+ Args:
14
+ input_resolution (tuple[int]): (Pl, Lat, Lon)
15
+ window_size (tuple[int]): (Pl, Lat, Lon)
16
+
17
+ Returns:
18
+ padding (tuple[int]): (padding_left, padding_right, padding_top, padding_bottom, padding_front, padding_back)
19
+ """
20
+ Pl, Lat, Lon = input_resolution
21
+ win_pl, win_lat, win_lon = window_size
22
+
23
+ padding_left = padding_right = padding_top = padding_bottom = padding_front = padding_back = 0
24
+ pl_remainder = Pl % win_pl
25
+ lat_remainder = Lat % win_lat
26
+ lon_remainder = Lon % win_lon
27
+
28
+ if pl_remainder:
29
+ pl_pad = win_pl - pl_remainder
30
+ padding_front = pl_pad // 2
31
+ padding_back = pl_pad - padding_front
32
+ if lat_remainder:
33
+ lat_pad = win_lat - lat_remainder
34
+ padding_top = lat_pad // 2
35
+ padding_bottom = lat_pad - padding_top
36
+ if lon_remainder:
37
+ lon_pad = win_lon - lon_remainder
38
+ padding_left = lon_pad // 2
39
+ padding_right = lon_pad - padding_left
40
+
41
+ return padding_left, padding_right, padding_top, padding_bottom, padding_front, padding_back
42
+
43
+ def get_pad2d(input_resolution, window_size):
44
+ """
45
+ Args:
46
+ input_resolution (tuple[int]): Lat, Lon
47
+ window_size (tuple[int]): Lat, Lon
48
+
49
+ Returns:
50
+ padding (tuple[int]): (padding_left, padding_right, padding_top, padding_bottom)
51
+ """
52
+ input_resolution = [2] + list(input_resolution)
53
+ window_size = [2] + list(window_size)
54
+ padding = get_pad3d(input_resolution, window_size)
55
+ return padding[: 4]
56
+
57
+
58
+ class CubeEmbedding(nn.Module):
59
+ """
60
+ Args:
61
+ img_size: T, Lat, Lon
62
+ patch_size: T, Lat, Lon
63
+ """
64
+ def __init__(self, img_size, patch_size, in_chans, embed_dim, norm_layer=nn.LayerNorm):
65
+ super().__init__()
66
+ patches_resolution = [img_size[0] // patch_size[0], img_size[1] // patch_size[1], img_size[2] // patch_size[2]]
67
+
68
+ self.img_size = img_size
69
+ self.patches_resolution = patches_resolution
70
+ self.embed_dim = embed_dim
71
+ self.proj = nn.Conv3d(in_chans, embed_dim, kernel_size=patch_size, stride=patch_size)
72
+ if norm_layer is not None:
73
+ self.norm = norm_layer(embed_dim)
74
+ else:
75
+ self.norm = None
76
+
77
+ def forward(self, x: torch.Tensor):
78
+ B, C, T, Lat, Lon = x.shape
79
+ assert T == self.img_size[0] and Lat == self.img_size[1] and Lon == self.img_size[2], \
80
+ f"Input image size ({T}*{Lat}*{Lon}) doesn't match model ({self.img_size[0]}*{self.img_size[1]}*{self.img_size[2]})."
81
+ x = self.proj(x).reshape(B, self.embed_dim, -1).transpose(1, 2) # B T*Lat*Lon C
82
+ if self.norm is not None:
83
+ x = self.norm(x)
84
+ x = x.transpose(1, 2).reshape(B, self.embed_dim, *self.patches_resolution)
85
+ return x
86
+
87
+
88
+ class DownBlock(nn.Module):
89
+ def __init__(self, in_chans: int, out_chans: int, num_groups: int, num_residuals: int = 2):
90
+ super().__init__()
91
+ self.conv = nn.Conv2d(in_chans, out_chans, kernel_size=(3, 3), stride=2, padding=1)
92
+
93
+ blk = []
94
+ for i in range(num_residuals):
95
+ blk.append(nn.Conv2d(out_chans, out_chans, kernel_size=3, stride=1, padding=1))
96
+ blk.append(nn.GroupNorm(num_groups, out_chans))
97
+ blk.append(nn.SiLU())
98
+
99
+ self.b = nn.Sequential(*blk)
100
+
101
+ def forward(self, x):
102
+ _, _, h, w = x.shape
103
+ x = self.conv(x)
104
+
105
+ shortcut = x
106
+
107
+ x = self.b(x)
108
+
109
+ res = x + shortcut
110
+ if h % 2 != 0:
111
+ res = res[:, :, :-1, :]
112
+ if w % 2 != 0:
113
+ res = res[:, :, :, :-1]
114
+ return res
115
+
116
+
117
+ class UpBlock(nn.Module):
118
+ def __init__(self, in_chans, out_chans, num_groups, num_residuals=2):
119
+ super().__init__()
120
+ self.conv = nn.ConvTranspose2d(in_chans, out_chans, kernel_size=2, stride=2)
121
+
122
+ blk = []
123
+ for i in range(num_residuals):
124
+ blk.append(nn.Conv2d(out_chans, out_chans, kernel_size=3, stride=1, padding=1))
125
+ blk.append(nn.GroupNorm(num_groups, out_chans))
126
+ blk.append(nn.SiLU())
127
+
128
+ self.b = nn.Sequential(*blk)
129
+
130
+ def forward(self, x):
131
+ x = self.conv(x)
132
+
133
+ shortcut = x
134
+
135
+ x = self.b(x)
136
+
137
+ return x + shortcut
138
+
139
+
140
+ class UTransformer(nn.Module):
141
+ """U-Transformer
142
+ Args:
143
+ embed_dim (int): Patch embedding dimension.
144
+ num_groups (int | tuple[int]): number of groups to separate the channels into.
145
+ input_resolution (tuple[int]): Lat, Lon.
146
+ num_heads (int): Number of attention heads in different layers.
147
+ window_size (int | tuple[int]): Window size.
148
+ depth (int): Number of blocks.
149
+ """
150
+ def __init__(self, embed_dim, num_groups, input_resolution, num_heads, window_size, depth):
151
+ super().__init__()
152
+ num_groups = to_2tuple(num_groups)
153
+ window_size = to_2tuple(window_size)
154
+ padding = get_pad2d(input_resolution, window_size)
155
+ padding_left, padding_right, padding_top, padding_bottom = padding
156
+ self.padding = padding
157
+ self.pad = nn.ZeroPad2d(padding)
158
+ input_resolution = list(input_resolution)
159
+ input_resolution[0] = input_resolution[0] + padding_top + padding_bottom
160
+ input_resolution[1] = input_resolution[1] + padding_left + padding_right
161
+ self.down = DownBlock(embed_dim, embed_dim, num_groups[0])
162
+ self.layer = SwinTransformerV2Stage(embed_dim, embed_dim, input_resolution, depth, num_heads, window_size)
163
+ self.up = UpBlock(embed_dim * 2, embed_dim, num_groups[1])
164
+
165
+ def forward(self, x):
166
+ B, C, Lat, Lon = x.shape
167
+ padding_left, padding_right, padding_top, padding_bottom = self.padding
168
+ x = self.down(x)
169
+
170
+ shortcut = x
171
+
172
+ # pad
173
+ x = self.pad(x)
174
+ _, _, pad_lat, pad_lon = x.shape
175
+
176
+ x = x.permute(0, 2, 3, 1) # B Lat Lon C
177
+ x = self.layer(x)
178
+ x = x.permute(0, 3, 1, 2)
179
+
180
+ # crop
181
+ x = x[:, :, padding_top: pad_lat - padding_bottom, padding_left: pad_lon - padding_right]
182
+
183
+ # concat
184
+ x = torch.cat([shortcut, x], dim=1) # B 2*C Lat Lon
185
+
186
+ x = self.up(x)
187
+ return x
188
+
189
+
190
+ class Fuxi(nn.Module):
191
+ """
192
+ Args:
193
+ img_size (Sequence[int], optional): T, Lat, Lon.
194
+ patch_size (Sequence[int], optional): T, Lat, Lon.
195
+ in_chans (int, optional): number of input channels.
196
+ out_chans (int, optional): number of output channels.
197
+ embed_dim (int, optional): number of embed channels.
198
+ num_groups (Sequence[int] | int, optional): number of groups to separate the channels into.
199
+ num_heads (int, optional): Number of attention heads.
200
+ window_size (int | tuple[int], optional): Local window size.
201
+ """
202
+ def __init__(self, in_shape=(1, 69, 180, 360), patch_size=(1, 4, 4), in_chans=69, out_chans=69,
203
+ embed_dim=1024, num_groups=32, num_heads=8, window_size=7,**kwargs):
204
+ super().__init__()
205
+
206
+ img_size=in_shape[0],in_shape[2],in_shape[3]
207
+ input_resolution = int(img_size[1] / patch_size[1] / 2), int(img_size[2] / patch_size[2] / 2)
208
+ self.cube_embedding = CubeEmbedding(img_size, patch_size, in_chans, embed_dim)
209
+ self.u_transformer = UTransformer(embed_dim, num_groups, input_resolution, num_heads, window_size, depth=48)
210
+ self.fc = nn.Linear(embed_dim, out_chans * patch_size[1] * patch_size[2])
211
+
212
+ self.patch_size = patch_size
213
+ self.input_resolution = input_resolution
214
+ self.out_chans = out_chans
215
+ self.img_size = img_size
216
+
217
+ def forward(self, x: torch.Tensor):
218
+ x = x.permute(0, 2, 1, 3, 4)
219
+ B, _, _, _, _ = x.shape
220
+ _, patch_lat, patch_lon = self.patch_size
221
+ Lat, Lon = self.input_resolution
222
+ Lat, Lon = Lat * 2, Lon * 2
223
+ x = self.cube_embedding(x).squeeze(2) # B C Lat Lon
224
+ x = self.u_transformer(x)
225
+ x = self.fc(x.permute(0, 2, 3, 1)) # B Lat Lon C
226
+ x = x.reshape(B, Lat, Lon, patch_lat, patch_lon, self.out_chans).permute(0, 1, 3, 2, 4, 5)
227
+ # B, lat, patch_lat, lon, patch_lon, C
228
+
229
+ x = x.reshape(B, Lat * patch_lat, Lon * patch_lon, self.out_chans)
230
+ x = x.permute(0, 3, 1, 2) # B C Lat Lon
231
+
232
+ # bilinear
233
+ x = F.interpolate(x, size=self.img_size[1:], mode="bilinear", align_corners=True).unsqueeze(1)
234
+
235
+ return x
236
+
237
+ if __name__ == '__main__':
238
+ inputs = torch.randn(1, 1, 69, 180, 360)
239
+ model = Fuxi(in_shape=(1, 69, 180, 360)) #in_shape=(1, 69, 180, 360)
240
+ output = model(inputs)
241
+ print(inputs.shape)
242
+ print(output.shape)
Exp1_Global_weather_forecasting/model_baselines/pangu_model.py ADDED
@@ -0,0 +1,1218 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from torch import nn
3
+ import numpy as np
4
+ import math
5
+ from collections.abc import Sequence
6
+ import warnings
7
+
8
+
9
+
10
+ ##### weight init ######
11
+ def _trunc_normal_(tensor, mean, std, a, b):
12
+ # Cut & paste from PyTorch official master until it's in a few official releases - RW
13
+ # Method based on https://people.sc.fsu.edu/~jburkardt/presentations/truncated_normal.pdf
14
+ def norm_cdf(x):
15
+ # Computes standard normal cumulative distribution function
16
+ return (1.0 + math.erf(x / math.sqrt(2.0))) / 2.0
17
+
18
+ if (mean < a - 2 * std) or (mean > b + 2 * std):
19
+ warnings.warn(
20
+ "mean is more than 2 std from [a, b] in nn.init.trunc_normal_. "
21
+ "The distribution of values may be incorrect.",
22
+ stacklevel=2,
23
+ )
24
+
25
+ # Values are generated by using a truncated uniform distribution and
26
+ # then using the inverse CDF for the normal distribution.
27
+ # Get upper and lower cdf values
28
+ u1 = norm_cdf((a - mean) / std)
29
+ u2 = norm_cdf((b - mean) / std)
30
+
31
+ # Uniformly fill tensor with values from [u1, u2], then translate to
32
+ # [2u1-1, 2u2-1].
33
+ tensor.uniform_(2 * u1 - 1, 2 * u2 - 1)
34
+
35
+ # Use inverse cdf transform for normal distribution to get truncated
36
+ # standard normal
37
+ tensor.erfinv_()
38
+
39
+ # Transform to proper mean, std
40
+ tensor.mul_(std * math.sqrt(2.0))
41
+ tensor.add_(mean)
42
+
43
+ # Clamp to ensure it's in the proper range
44
+ tensor.clamp_(min=a, max=b)
45
+ return tensor
46
+
47
+
48
+ def trunc_normal_(tensor, mean=0.0, std=1.0, a=-2.0, b=2.0):
49
+ # type: (Tensor, float, float, float, float) -> Tensor
50
+ r"""Cut & paste from timm master
51
+ Fills the input Tensor with values drawn from a truncated
52
+ normal distribution. The values are effectively drawn from the
53
+ normal distribution :math:`\mathcal{N}(\text{mean}, \text{std}^2)`
54
+ with values outside :math:`[a, b]` redrawn until they are within
55
+ the bounds. The method used for generating the random values works
56
+ best when :math:`a \leq \text{mean} \leq b`.
57
+
58
+ NOTE: this impl is similar to the PyTorch trunc_normal_, the bounds [a, b] are
59
+ applied while sampling the normal with mean/std applied, therefore a, b args
60
+ should be adjusted to match the range of mean, std args.
61
+ """
62
+ with torch.no_grad():
63
+ return _trunc_normal_(tensor, mean, std, a, b)
64
+
65
+
66
+ class Mlp(nn.Module):
67
+ def __init__(
68
+ self,
69
+ in_features,
70
+ hidden_features=None,
71
+ out_features=None,
72
+ act_layer=nn.GELU,
73
+ drop=0.0,
74
+ ):
75
+ super().__init__()
76
+ out_features = out_features or in_features
77
+ hidden_features = hidden_features or in_features
78
+ self.fc1 = nn.Linear(in_features, hidden_features)
79
+ self.act = act_layer()
80
+ self.fc2 = nn.Linear(hidden_features, out_features)
81
+ self.drop = nn.Dropout(drop)
82
+
83
+ def forward(self, x: torch.Tensor):
84
+ x = self.fc1(x)
85
+ x = self.act(x)
86
+ x = self.drop(x)
87
+ x = self.fc2(x)
88
+ x = self.drop(x)
89
+ return x
90
+
91
+
92
+
93
+ def drop_path(
94
+ x, drop_prob: float = 0.0, training: bool = False, scale_by_keep: bool = True
95
+ ):
96
+ """Cut & paste from timm master
97
+ Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks).
98
+
99
+ This is the same as the DropConnect impl I created for EfficientNet, etc networks, however,
100
+ the original name is misleading as 'Drop Connect' is a different form of dropout in a separate paper...
101
+ See discussion: https://github.com/tensorflow/tpu/issues/494#issuecomment-532968956 ... I've opted for
102
+ changing the layer and argument names to 'drop path' rather than mix DropConnect as a layer name and use
103
+ 'survival rate' as the argument.
104
+
105
+ """
106
+ if drop_prob == 0.0 or not training:
107
+ return x
108
+ keep_prob = 1 - drop_prob
109
+ shape = (x.shape[0],) + (1,) * (
110
+ x.ndim - 1
111
+ ) # work with diff dim tensors, not just 2D ConvNets
112
+ random_tensor = x.new_empty(shape).bernoulli_(keep_prob)
113
+ if keep_prob > 0.0 and scale_by_keep:
114
+ random_tensor.div_(keep_prob)
115
+ return x * random_tensor
116
+
117
+
118
+ class DropPath(nn.Module):
119
+ """Cut & paste from timm master
120
+ Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks).
121
+ """
122
+
123
+ def __init__(self, drop_prob: float = 0.0, scale_by_keep: bool = True):
124
+ super(DropPath, self).__init__()
125
+ self.drop_prob = drop_prob
126
+ self.scale_by_keep = scale_by_keep
127
+
128
+ def forward(self, x):
129
+ return drop_path(x, self.drop_prob, self.training, self.scale_by_keep)
130
+
131
+ def extra_repr(self):
132
+ return f"drop_prob={round(self.drop_prob,3):0.3f}"
133
+
134
+
135
+
136
+ class PatchEmbed2D(nn.Module):
137
+ """
138
+ Revise from WeatherLearn https://github.com/lizhuoq/WeatherLearn
139
+ 2D Image to Patch Embedding.
140
+
141
+ Args:
142
+ img_size (tuple[int]): Image size.
143
+ patch_size (tuple[int]): Patch token size.
144
+ in_chans (int): Number of input image channels.
145
+ embed_dim(int): Number of projection output channels.
146
+ norm_layer (nn.Module, optional): Normalization layer. Default: None
147
+ """
148
+
149
+ def __init__(self, img_size, patch_size, in_chans, embed_dim, norm_layer=None):
150
+ super().__init__()
151
+ self.img_size = img_size
152
+ height, width = img_size
153
+ h_patch_size, w_path_size = patch_size
154
+ padding_left = padding_right = padding_top = padding_bottom = 0
155
+
156
+ h_remainder = height % h_patch_size
157
+ w_remainder = width % w_path_size
158
+
159
+ if h_remainder:
160
+ h_pad = h_patch_size - h_remainder
161
+ padding_top = h_pad // 2
162
+ padding_bottom = int(h_pad - padding_top)
163
+
164
+ if w_remainder:
165
+ w_pad = w_path_size - w_remainder
166
+ padding_left = w_pad // 2
167
+ padding_right = int(w_pad - padding_left)
168
+
169
+ self.pad = nn.ZeroPad2d(
170
+ (padding_left, padding_right, padding_top, padding_bottom)
171
+ )
172
+ self.proj = nn.Conv2d(
173
+ in_chans, embed_dim, kernel_size=patch_size, stride=patch_size
174
+ )
175
+ if norm_layer is not None:
176
+ self.norm = norm_layer(embed_dim)
177
+ else:
178
+ self.norm = None
179
+
180
+ def forward(self, x: torch.Tensor):
181
+ B, C, H, W = x.shape
182
+ x = self.pad(x)
183
+ x = self.proj(x)
184
+ if self.norm is not None:
185
+ x = self.norm(x.permute(0, 2, 3, 1)).permute(0, 3, 1, 2)
186
+ return x
187
+
188
+
189
+ class PatchEmbed3D(nn.Module):
190
+ """
191
+ Revise from WeatherLearn https://github.com/lizhuoq/WeatherLearn
192
+ 3D Image to Patch Embedding.
193
+
194
+ Args:
195
+ img_size (tuple[int]): Image size.
196
+ patch_size (tuple[int]): Patch token size.
197
+ in_chans (int): Number of input image channels.
198
+ embed_dim(int): Number of projection output channels.
199
+ norm_layer (nn.Module, optional): Normalization layer. Default: None
200
+ """
201
+
202
+ def __init__(self, img_size, patch_size, in_chans, embed_dim, norm_layer=None):
203
+ super().__init__()
204
+ self.img_size = img_size
205
+ level, height, width = img_size
206
+ l_patch_size, h_patch_size, w_patch_size = patch_size
207
+ padding_left = (
208
+ padding_right
209
+ ) = padding_top = padding_bottom = padding_front = padding_back = 0
210
+
211
+ l_remainder = level % l_patch_size
212
+ h_remainder = height % l_patch_size
213
+ w_remainder = width % w_patch_size
214
+
215
+ if l_remainder:
216
+ l_pad = l_patch_size - l_remainder
217
+ padding_front = l_pad // 2
218
+ padding_back = l_pad - padding_front
219
+ if h_remainder:
220
+ h_pad = h_patch_size - h_remainder
221
+ padding_top = h_pad // 2
222
+ padding_bottom = h_pad - padding_top
223
+ if w_remainder:
224
+ w_pad = w_patch_size - w_remainder
225
+ padding_left = w_pad // 2
226
+ padding_right = w_pad - padding_left
227
+
228
+ self.pad = nn.ConstantPad3d(
229
+ (
230
+ padding_left,
231
+ padding_right,
232
+ padding_top,
233
+ padding_bottom,
234
+ padding_front,
235
+ padding_back,
236
+ ),
237
+ value=0
238
+ )
239
+ self.proj = nn.Conv3d(
240
+ in_chans, embed_dim, kernel_size=patch_size, stride=patch_size
241
+ )
242
+ if norm_layer is not None:
243
+ self.norm = norm_layer(embed_dim)
244
+ else:
245
+ self.norm = None
246
+
247
+ def forward(self, x: torch.Tensor):
248
+ B, C, L, H, W = x.shape
249
+ x = self.pad(x)
250
+ x = self.proj(x)
251
+ if self.norm:
252
+ x = self.norm(x.permute(0, 2, 3, 4, 1)).permute(0, 4, 1, 2, 3)
253
+ return x
254
+
255
+
256
+ class PatchRecovery2D(nn.Module):
257
+ """
258
+ Revise from WeatherLearn https://github.com/lizhuoq/WeatherLearn
259
+ Patch Embedding Recovery to 2D Image.
260
+
261
+ Args:
262
+ img_size (tuple[int]): Lat, Lon
263
+ patch_size (tuple[int]): Lat, Lon
264
+ in_chans (int): Number of input channels.
265
+ out_chans (int): Number of output channels.
266
+ """
267
+
268
+ def __init__(self, img_size, patch_size, in_chans, out_chans):
269
+ super().__init__()
270
+ self.img_size = img_size
271
+ self.conv = nn.ConvTranspose2d(in_chans, out_chans, patch_size, patch_size)
272
+
273
+ def forward(self, x):
274
+ output = self.conv(x)
275
+ _, _, H, W = output.shape
276
+ h_pad = H - self.img_size[0]
277
+ w_pad = W - self.img_size[1]
278
+
279
+ padding_top = h_pad // 2
280
+ padding_bottom = int(h_pad - padding_top)
281
+
282
+ padding_left = w_pad // 2
283
+ padding_right = int(w_pad - padding_left)
284
+
285
+ return output[
286
+ :, :, padding_top : H - padding_bottom, padding_left : W - padding_right
287
+ ]
288
+
289
+
290
+ class PatchRecovery3D(nn.Module):
291
+ """
292
+ Revise from WeatherLearn https://github.com/lizhuoq/WeatherLearn
293
+ Patch Embedding Recovery to 3D Image.
294
+
295
+ Args:
296
+ img_size (tuple[int]): Pl, Lat, Lon
297
+ patch_size (tuple[int]): Pl, Lat, Lon
298
+ in_chans (int): Number of input channels.
299
+ out_chans (int): Number of output channels.
300
+ """
301
+
302
+ def __init__(self, img_size, patch_size, in_chans, out_chans):
303
+ super().__init__()
304
+ self.img_size = img_size
305
+ self.conv = nn.ConvTranspose3d(in_chans, out_chans, patch_size, patch_size)
306
+
307
+ def forward(self, x: torch.Tensor):
308
+ output = self.conv(x)
309
+ _, _, Pl, Lat, Lon = output.shape
310
+
311
+ pl_pad = Pl - self.img_size[0]
312
+ lat_pad = Lat - self.img_size[1]
313
+ lon_pad = Lon - self.img_size[2]
314
+
315
+ padding_front = pl_pad // 2
316
+ padding_back = pl_pad - padding_front
317
+
318
+ padding_top = lat_pad // 2
319
+ padding_bottom = lat_pad - padding_top
320
+
321
+ padding_left = lon_pad // 2
322
+ padding_right = lon_pad - padding_left
323
+
324
+ return output[
325
+ :,
326
+ :,
327
+ padding_front : Pl - padding_back,
328
+ padding_top : Lat - padding_bottom,
329
+ padding_left : Lon - padding_right,
330
+ ]
331
+
332
+ class UpSample3D(nn.Module):
333
+ """
334
+ Revise from WeatherLearn https://github.com/lizhuoq/WeatherLearn
335
+ 3D Up-sampling operation.
336
+ Implementation from: https://github.com/198808xc/Pangu-Weather/blob/main/pseudocode.py
337
+
338
+ Args:
339
+ in_dim (int): Number of input channels.
340
+ out_dim (int): Number of output channels.
341
+ input_resolution (tuple[int]): [pressure levels, latitude, longitude]
342
+ output_resolution (tuple[int]): [pressure levels, latitude, longitude]
343
+ """
344
+
345
+ def __init__(self, in_dim, out_dim, input_resolution, output_resolution):
346
+ super().__init__()
347
+ self.linear1 = nn.Linear(in_dim, out_dim * 4, bias=False)
348
+ self.linear2 = nn.Linear(out_dim, out_dim, bias=False)
349
+ self.norm = nn.LayerNorm(out_dim)
350
+ self.input_resolution = input_resolution
351
+ self.output_resolution = output_resolution
352
+
353
+ def forward(self, x: torch.Tensor):
354
+ """
355
+ Args:
356
+ x (torch.Tensor): (B, N, C)
357
+ """
358
+ B, N, C = x.shape
359
+ in_pl, in_lat, in_lon = self.input_resolution
360
+ out_pl, out_lat, out_lon = self.output_resolution
361
+
362
+ x = self.linear1(x)
363
+ x = x.reshape(B, in_pl, in_lat, in_lon, 2, 2, C // 2).permute(
364
+ 0, 1, 2, 4, 3, 5, 6
365
+ )
366
+ x = x.reshape(B, in_pl, in_lat * 2, in_lon * 2, -1)
367
+
368
+ pad_h = in_lat * 2 - out_lat
369
+ pad_w = in_lon * 2 - out_lon
370
+
371
+ pad_top = pad_h // 2
372
+ pad_bottom = pad_h - pad_top
373
+
374
+ pad_left = pad_w // 2
375
+ pad_right = pad_w - pad_left
376
+
377
+ x = x[
378
+ :,
379
+ :out_pl,
380
+ pad_top : 2 * in_lat - pad_bottom,
381
+ pad_left : 2 * in_lon - pad_right,
382
+ :,
383
+ ]
384
+ x = x.reshape(x.shape[0], x.shape[1] * x.shape[2] * x.shape[3], x.shape[4])
385
+ x = self.norm(x)
386
+ x = self.linear2(x)
387
+ return x
388
+
389
+ class DownSample3D(nn.Module):
390
+ """
391
+ Revise from WeatherLearn https://github.com/lizhuoq/WeatherLearn
392
+ 3D Down-sampling operation
393
+ Implementation from: https://github.com/198808xc/Pangu-Weather/blob/main/pseudocode.py
394
+
395
+ Args:
396
+ in_dim (int): Number of input channels.
397
+ input_resolution (tuple[int]): [pressure levels, latitude, longitude]
398
+ output_resolution (tuple[int]): [pressure levels, latitude, longitude]
399
+ """
400
+
401
+ def __init__(self, in_dim, input_resolution, output_resolution):
402
+ super().__init__()
403
+ self.linear = nn.Linear(in_dim * 4, in_dim * 2, bias=False)
404
+ self.norm = nn.LayerNorm(4 * in_dim)
405
+ self.input_resolution = input_resolution
406
+ self.output_resolution = output_resolution
407
+
408
+ in_pl, in_lat, in_lon = self.input_resolution
409
+ out_pl, out_lat, out_lon = self.output_resolution
410
+
411
+ h_pad = out_lat * 2 - in_lat
412
+ w_pad = out_lon * 2 - in_lon
413
+
414
+ pad_top = h_pad // 2
415
+ pad_bottom = h_pad - pad_top
416
+
417
+ pad_left = w_pad // 2
418
+ pad_right = w_pad - pad_left
419
+
420
+ pad_front = pad_back = 0
421
+
422
+ self.pad = nn.ConstantPad3d(
423
+ (pad_left, pad_right, pad_top, pad_bottom, pad_front, pad_back), value=0
424
+ )
425
+
426
+ def forward(self, x):
427
+ B, N, C = x.shape
428
+ in_pl, in_lat, in_lon = self.input_resolution
429
+ out_pl, out_lat, out_lon = self.output_resolution
430
+ x = x.reshape(B, in_pl, in_lat, in_lon, C)
431
+
432
+ # Padding the input to facilitate downsampling
433
+ x = self.pad(x.permute(0, -1, 1, 2, 3)).permute(0, 2, 3, 4, 1)
434
+ x = x.reshape(B, in_pl, out_lat, 2, out_lon, 2, C).permute(0, 1, 2, 4, 3, 5, 6)
435
+ x = x.reshape(B, out_pl * out_lat * out_lon, 4 * C)
436
+
437
+ x = self.norm(x)
438
+ x = self.linear(x)
439
+ return x
440
+
441
+
442
+
443
+ def get_earth_position_index(window_size, ndim=3):
444
+ """
445
+ Revise from WeatherLearn https://github.com/lizhuoq/WeatherLearn
446
+ This function construct the position index to reuse symmetrical parameters of the position bias.
447
+ implementation from: https://github.com/198808xc/Pangu-Weather/blob/main/pseudocode.py
448
+
449
+ Args:
450
+ window_size (tuple[int]): [pressure levels, latitude, longitude] or [latitude, longitude]
451
+ ndim (int): dimension of tensor, 3 or 2
452
+
453
+ Returns:
454
+ position_index (torch.Tensor): [win_pl * win_lat * win_lon, win_pl * win_lat * win_lon] or [win_lat * win_lon, win_lat * win_lon]
455
+ """
456
+ if ndim == 3:
457
+ win_pl, win_lat, win_lon = window_size
458
+ elif ndim == 2:
459
+ win_lat, win_lon = window_size
460
+
461
+ if ndim == 3:
462
+ # Index in the pressure level of query matrix
463
+ coords_zi = torch.arange(win_pl)
464
+ # Index in the pressure level of key matrix
465
+ coords_zj = -torch.arange(win_pl) * win_pl
466
+
467
+ # Index in the latitude of query matrix
468
+ coords_hi = torch.arange(win_lat)
469
+ # Index in the latitude of key matrix
470
+ coords_hj = -torch.arange(win_lat) * win_lat
471
+
472
+ # Index in the longitude of the key-value pair
473
+ coords_w = torch.arange(win_lon)
474
+
475
+ # Change the order of the index to calculate the index in total
476
+ if ndim == 3:
477
+ coords_1 = torch.stack(torch.meshgrid([coords_zi, coords_hi, coords_w]))
478
+ coords_2 = torch.stack(torch.meshgrid([coords_zj, coords_hj, coords_w]))
479
+ elif ndim == 2:
480
+ coords_1 = torch.stack(torch.meshgrid([coords_hi, coords_w]))
481
+ coords_2 = torch.stack(torch.meshgrid([coords_hj, coords_w]))
482
+ coords_flatten_1 = torch.flatten(coords_1, 1)
483
+ coords_flatten_2 = torch.flatten(coords_2, 1)
484
+ coords = coords_flatten_1[:, :, None] - coords_flatten_2[:, None, :]
485
+ coords = coords.permute(1, 2, 0).contiguous()
486
+
487
+ # Shift the index for each dimension to start from 0
488
+ if ndim == 3:
489
+ coords[:, :, 2] += win_lon - 1
490
+ coords[:, :, 1] *= 2 * win_lon - 1
491
+ coords[:, :, 0] *= (2 * win_lon - 1) * win_lat * win_lat
492
+ elif ndim == 2:
493
+ coords[:, :, 1] += win_lon - 1
494
+ coords[:, :, 0] *= 2 * win_lon - 1
495
+
496
+ # Sum up the indexes in two/three dimensions
497
+ position_index = coords.sum(-1)
498
+
499
+ return position_index
500
+
501
+
502
+ def get_pad3d(input_resolution, window_size):
503
+ """
504
+ Args:
505
+ input_resolution (tuple[int]): (Pl, Lat, Lon)
506
+ window_size (tuple[int]): (Pl, Lat, Lon)
507
+
508
+ Returns:
509
+ padding (tuple[int]): (padding_left, padding_right, padding_top, padding_bottom, padding_front, padding_back)
510
+ """
511
+ Pl, Lat, Lon = input_resolution
512
+ win_pl, win_lat, win_lon = window_size
513
+
514
+ padding_left = (
515
+ padding_right
516
+ ) = padding_top = padding_bottom = padding_front = padding_back = 0
517
+ pl_remainder = Pl % win_pl
518
+ lat_remainder = Lat % win_lat
519
+ lon_remainder = Lon % win_lon
520
+
521
+ if pl_remainder:
522
+ pl_pad = win_pl - pl_remainder
523
+ padding_front = pl_pad // 2
524
+ padding_back = pl_pad - padding_front
525
+ if lat_remainder:
526
+ lat_pad = win_lat - lat_remainder
527
+ padding_top = lat_pad // 2
528
+ padding_bottom = lat_pad - padding_top
529
+ if lon_remainder:
530
+ lon_pad = win_lon - lon_remainder
531
+ padding_left = lon_pad // 2
532
+ padding_right = lon_pad - padding_left
533
+
534
+ return (
535
+ padding_left,
536
+ padding_right,
537
+ padding_top,
538
+ padding_bottom,
539
+ padding_front,
540
+ padding_back,
541
+ )
542
+
543
+
544
+
545
+ def crop3d(x: torch.Tensor, resolution):
546
+ """
547
+ Args:
548
+ x (torch.Tensor): B, C, Pl, Lat, Lon
549
+ resolution (tuple[int]): Pl, Lat, Lon
550
+ """
551
+ _, _, Pl, Lat, Lon = x.shape
552
+ pl_pad = Pl - resolution[0]
553
+ lat_pad = Lat - resolution[1]
554
+ lon_pad = Lon - resolution[2]
555
+
556
+ padding_front = pl_pad // 2
557
+ padding_back = pl_pad - padding_front
558
+
559
+ padding_top = lat_pad // 2
560
+ padding_bottom = lat_pad - padding_top
561
+
562
+ padding_left = lon_pad // 2
563
+ padding_right = lon_pad - padding_left
564
+ return x[
565
+ :,
566
+ :,
567
+ padding_front : Pl - padding_back,
568
+ padding_top : Lat - padding_bottom,
569
+ padding_left : Lon - padding_right,
570
+ ]
571
+
572
+
573
+ class EarthAttention3D(nn.Module):
574
+ """
575
+ Revise from WeatherLearn https://github.com/lizhuoq/WeatherLearn
576
+ 3D window attention with earth position bias.
577
+ It supports both of shifted and non-shifted window.
578
+
579
+ Args:
580
+ dim (int): Number of input channels.
581
+ input_resolution (tuple[int]): [pressure levels, latitude, longitude]
582
+ window_size (tuple[int]): [pressure levels, latitude, longitude]
583
+ num_heads (int): Number of attention heads.
584
+ qkv_bias (bool, optional): If True, add a learnable bias to query, key, value. Default: True
585
+ qk_scale (float | None, optional): Override default qk scale of head_dim ** -0.5 if set
586
+ attn_drop (float, optional): Dropout ratio of attention weight. Default: 0.0
587
+ proj_drop (float, optional): Dropout ratio of output. Default: 0.0
588
+ """
589
+
590
+ def __init__(
591
+ self,
592
+ dim,
593
+ input_resolution,
594
+ window_size,
595
+ num_heads,
596
+ qkv_bias=True,
597
+ qk_scale=None,
598
+ attn_drop=0.0,
599
+ proj_drop=0.0,
600
+ ):
601
+ super().__init__()
602
+ self.dim = dim
603
+ self.window_size = window_size # Wpl, Wlat, Wlon
604
+ self.num_heads = num_heads
605
+ head_dim = dim // num_heads
606
+ self.scale = qk_scale or head_dim**-0.5
607
+
608
+ self.type_of_windows = (input_resolution[0] // window_size[0]) * (
609
+ input_resolution[1] // window_size[1]
610
+ )
611
+
612
+ self.earth_position_bias_table = nn.Parameter(
613
+ torch.zeros(
614
+ (window_size[0] ** 2)
615
+ * (window_size[1] ** 2)
616
+ * (window_size[2] * 2 - 1),
617
+ self.type_of_windows,
618
+ num_heads,
619
+ )
620
+ ) # Wpl**2 * Wlat**2 * Wlon*2-1, Npl//Wpl * Nlat//Wlat, nH
621
+
622
+ earth_position_index = get_earth_position_index(
623
+ window_size
624
+ ) # Wpl*Wlat*Wlon, Wpl*Wlat*Wlon
625
+ self.register_buffer("earth_position_index", earth_position_index)
626
+
627
+ self.qkv = nn.Linear(dim, dim * 3, bias=qkv_bias)
628
+ self.attn_drop = nn.Dropout(attn_drop)
629
+ self.proj = nn.Linear(dim, dim)
630
+ self.proj_drop = nn.Dropout(proj_drop)
631
+
632
+ self.earth_position_bias_table = trunc_normal_(
633
+ self.earth_position_bias_table, std=0.02
634
+ )
635
+ self.softmax = nn.Softmax(dim=-1)
636
+
637
+ def forward(self, x: torch.Tensor, mask=None):
638
+ """
639
+ Args:
640
+ x: input features with shape of (B * num_lon, num_pl*num_lat, N, C)
641
+ mask: (0/-inf) mask with shape of (num_lon, num_pl*num_lat, Wpl*Wlat*Wlon, Wpl*Wlat*Wlon)
642
+ """
643
+ B_, nW_, N, C = x.shape
644
+ qkv = (
645
+ self.qkv(x)
646
+ .reshape(B_, nW_, N, 3, self.num_heads, C // self.num_heads)
647
+ .permute(3, 0, 4, 1, 2, 5)
648
+ )
649
+ q, k, v = qkv[0], qkv[1], qkv[2]
650
+
651
+ q = q * self.scale
652
+ attn = q @ k.transpose(-2, -1)
653
+
654
+ earth_position_bias = self.earth_position_bias_table[
655
+ self.earth_position_index.view(-1)
656
+ ].view(
657
+ self.window_size[0] * self.window_size[1] * self.window_size[2],
658
+ self.window_size[0] * self.window_size[1] * self.window_size[2],
659
+ self.type_of_windows,
660
+ -1,
661
+ ) # Wpl*Wlat*Wlon, Wpl*Wlat*Wlon, num_pl*num_lat, nH
662
+ earth_position_bias = earth_position_bias.permute(
663
+ 3, 2, 0, 1
664
+ ).contiguous() # nH, num_pl*num_lat, Wpl*Wlat*Wlon, Wpl*Wlat*Wlon
665
+ attn = attn + earth_position_bias.unsqueeze(0)
666
+
667
+ if mask is not None:
668
+ nLon = mask.shape[0]
669
+ attn = attn.view(
670
+ B_ // nLon, nLon, self.num_heads, nW_, N, N
671
+ ) + mask.unsqueeze(1).unsqueeze(0)
672
+ attn = attn.view(-1, self.num_heads, nW_, N, N)
673
+ attn = self.softmax(attn)
674
+ else:
675
+ attn = self.softmax(attn)
676
+
677
+ attn = self.attn_drop(attn)
678
+
679
+ x = (attn @ v).permute(0, 2, 3, 1, 4).reshape(B_, nW_, N, C)
680
+ x = self.proj(x)
681
+ x = self.proj_drop(x)
682
+ return x
683
+
684
+
685
+
686
+ class Transformer3DBlock(nn.Module):
687
+ """
688
+ Revise from WeatherLearn https://github.com/lizhuoq/WeatherLearn
689
+ 3D Transformer Block
690
+ Args:
691
+ dim (int): Number of input channels.
692
+ input_resolution (tuple[int]): Input resulotion.
693
+ num_heads (int): Number of attention heads.
694
+ window_size (tuple[int]): Window size [pressure levels, latitude, longitude].
695
+ shift_size (tuple[int]): Shift size for SW-MSA [pressure levels, latitude, longitude].
696
+ mlp_ratio (float): Ratio of mlp hidden dim to embedding dim.
697
+ qkv_bias (bool, optional): If True, add a learnable bias to query, key, value. Default: True
698
+ qk_scale (float | None, optional): Override default qk scale of head_dim ** -0.5 if set.
699
+ drop (float, optional): Dropout rate. Default: 0.0
700
+ attn_drop (float, optional): Attention dropout rate. Default: 0.0
701
+ drop_path (float, optional): Stochastic depth rate. Default: 0.0
702
+ act_layer (nn.Module, optional): Activation layer. Default: nn.GELU
703
+ norm_layer (nn.Module, optional): Normalization layer. Default: nn.LayerNorm
704
+ """
705
+
706
+ def __init__(
707
+ self,
708
+ dim,
709
+ input_resolution,
710
+ num_heads,
711
+ window_size=None,
712
+ shift_size=None,
713
+ mlp_ratio=4.0,
714
+ qkv_bias=True,
715
+ qk_scale=None,
716
+ drop=0.0,
717
+ attn_drop=0.0,
718
+ drop_path=0.0,
719
+ act_layer=nn.GELU,
720
+ norm_layer=nn.LayerNorm,
721
+ ):
722
+ super().__init__()
723
+ window_size = (2, 6, 12) if window_size is None else window_size
724
+ shift_size = (1, 3, 6) if shift_size is None else shift_size
725
+ self.dim = dim
726
+ self.input_resolution = input_resolution
727
+ self.num_heads = num_heads
728
+ self.window_size = window_size
729
+ self.shift_size = shift_size
730
+ self.mlp_ratio = mlp_ratio
731
+
732
+ self.norm1 = norm_layer(dim)
733
+ padding = get_pad3d(input_resolution, window_size)
734
+ self.pad = nn.ConstantPad3d(padding, value=0)
735
+
736
+ pad_resolution = list(input_resolution)
737
+ pad_resolution[0] += padding[-1] + padding[-2]
738
+ pad_resolution[1] += padding[2] + padding[3]
739
+ pad_resolution[2] += padding[0] + padding[1]
740
+
741
+ self.attn = EarthAttention3D(
742
+ dim=dim,
743
+ input_resolution=pad_resolution,
744
+ window_size=window_size,
745
+ num_heads=num_heads,
746
+ qkv_bias=qkv_bias,
747
+ qk_scale=qk_scale,
748
+ attn_drop=attn_drop,
749
+ proj_drop=drop,
750
+ )
751
+
752
+ self.drop_path = DropPath(drop_path) if drop_path > 0.0 else nn.Identity()
753
+ self.norm2 = norm_layer(dim)
754
+ mlp_hidden_dim = int(dim * mlp_ratio)
755
+ self.mlp = Mlp(
756
+ in_features=dim,
757
+ hidden_features=mlp_hidden_dim,
758
+ act_layer=act_layer,
759
+ drop=drop,
760
+ )
761
+
762
+ shift_pl, shift_lat, shift_lon = self.shift_size
763
+ self.roll = shift_pl and shift_lon and shift_lat
764
+
765
+ if self.roll:
766
+ attn_mask = get_shift_window_mask(pad_resolution, window_size, shift_size)
767
+ else:
768
+ attn_mask = None
769
+
770
+ self.register_buffer("attn_mask", attn_mask)
771
+
772
+ def forward(self, x: torch.Tensor):
773
+ Pl, Lat, Lon = self.input_resolution
774
+ B, L, C = x.shape
775
+
776
+ shortcut = x
777
+ x = self.norm1(x)
778
+ x = x.view(B, Pl, Lat, Lon, C)
779
+
780
+ # start pad
781
+ x = self.pad(x.permute(0, 4, 1, 2, 3)).permute(0, 2, 3, 4, 1)
782
+
783
+ _, Pl_pad, Lat_pad, Lon_pad, _ = x.shape
784
+
785
+ shift_pl, shift_lat, shift_lon = self.shift_size
786
+ if self.roll:
787
+ shifted_x = torch.roll(
788
+ x, shifts=(-shift_pl, -shift_lat, -shift_lat), dims=(1, 2, 3)
789
+ )
790
+ x_windows = window_partition(shifted_x, self.window_size)
791
+ # B*num_lon, num_pl*num_lat, win_pl, win_lat, win_lon, C
792
+ else:
793
+ shifted_x = x
794
+ x_windows = window_partition(shifted_x, self.window_size)
795
+ # B*num_lon, num_pl*num_lat, win_pl, win_lat, win_lon, C
796
+
797
+ win_pl, win_lat, win_lon = self.window_size
798
+ x_windows = x_windows.view(
799
+ x_windows.shape[0], x_windows.shape[1], win_pl * win_lat * win_lon, C
800
+ )
801
+ # B*num_lon, num_pl*num_lat, win_pl*win_lat*win_lon, C
802
+
803
+ attn_windows = self.attn(
804
+ x_windows, mask=self.attn_mask
805
+ ) # B*num_lon, num_pl*num_lat, win_pl*win_lat*win_lon, C
806
+
807
+ attn_windows = attn_windows.view(
808
+ attn_windows.shape[0], attn_windows.shape[1], win_pl, win_lat, win_lon, C
809
+ )
810
+
811
+ if self.roll:
812
+ shifted_x = window_reverse(
813
+ attn_windows, self.window_size, Pl=Pl_pad, Lat=Lat_pad, Lon=Lon_pad
814
+ )
815
+ # B * Pl * Lat * Lon * C
816
+ x = torch.roll(
817
+ shifted_x, shifts=(shift_pl, shift_lat, shift_lon), dims=(1, 2, 3)
818
+ )
819
+ else:
820
+ shifted_x = window_reverse(
821
+ attn_windows, self.window_size, Pl=Pl_pad, Lat=Lat_pad, Lon=Lon_pad
822
+ )
823
+ x = shifted_x
824
+
825
+ # crop, end pad
826
+ x = crop3d(x.permute(0, 4, 1, 2, 3), self.input_resolution).permute(
827
+ 0, 2, 3, 4, 1
828
+ )
829
+
830
+ x = x.reshape(B, Pl * Lat * Lon, C)
831
+ x = shortcut + self.drop_path(x)
832
+
833
+ x = x + self.drop_path(self.mlp(self.norm2(x)))
834
+
835
+ return x
836
+
837
+
838
+
839
+
840
+
841
+ ##### shift window mask ############
842
+
843
+ def window_partition(x: torch.Tensor, window_size, ndim=3):
844
+ """
845
+ Args:
846
+ x: (B, Pl, Lat, Lon, C) or (B, Lat, Lon, C)
847
+ window_size (tuple[int]): [win_pl, win_lat, win_lon] or [win_lat, win_lon]
848
+ ndim (int): dimension of window (3 or 2)
849
+
850
+ Returns:
851
+ windows: (B*num_lon, num_pl*num_lat, win_pl, win_lat, win_lon, C) or (B*num_lon, num_lat, win_lat, win_lon, C)
852
+ """
853
+ if ndim == 3:
854
+ B, Pl, Lat, Lon, C = x.shape
855
+ win_pl, win_lat, win_lon = window_size
856
+ x = x.view(
857
+ B, Pl // win_pl, win_pl, Lat // win_lat, win_lat, Lon // win_lon, win_lon, C
858
+ )
859
+ windows = (
860
+ x.permute(0, 5, 1, 3, 2, 4, 6, 7)
861
+ .contiguous()
862
+ .view(-1, (Pl // win_pl) * (Lat // win_lat), win_pl, win_lat, win_lon, C)
863
+ )
864
+ return windows
865
+ elif ndim == 2:
866
+ B, Lat, Lon, C = x.shape
867
+ win_lat, win_lon = window_size
868
+ x = x.view(B, Lat // win_lat, win_lat, Lon // win_lon, win_lon, C)
869
+ windows = (
870
+ x.permute(0, 3, 1, 2, 4, 5)
871
+ .contiguous()
872
+ .view(-1, (Lat // win_lat), win_lat, win_lon, C)
873
+ )
874
+ return windows
875
+
876
+
877
+ def window_reverse(windows, window_size, Pl=1, Lat=1, Lon=1, ndim=3):
878
+ """
879
+ Args:
880
+ windows: (B*num_lon, num_pl*num_lat, win_pl, win_lat, win_lon, C) or (B*num_lon, num_lat, win_lat, win_lon, C)
881
+ window_size (tuple[int]): [win_pl, win_lat, win_lon] or [win_lat, win_lon]
882
+ Pl (int): pressure levels
883
+ Lat (int): latitude
884
+ Lon (int): longitude
885
+ ndim (int): dimension of window (3 or 2)
886
+
887
+ Returns:
888
+ x: (B, Pl, Lat, Lon, C) or (B, Lat, Lon, C)
889
+ """
890
+ if ndim == 3:
891
+ win_pl, win_lat, win_lon = window_size
892
+ B = int(windows.shape[0] / (Lon / win_lon))
893
+ x = windows.view(
894
+ B,
895
+ Lon // win_lon,
896
+ Pl // win_pl,
897
+ Lat // win_lat,
898
+ win_pl,
899
+ win_lat,
900
+ win_lon,
901
+ -1,
902
+ )
903
+ x = x.permute(0, 2, 4, 3, 5, 1, 6, 7).contiguous().view(B, Pl, Lat, Lon, -1)
904
+ return x
905
+ elif ndim == 2:
906
+ win_lat, win_lon = window_size
907
+ B = int(windows.shape[0] / (Lon / win_lon))
908
+ x = windows.view(B, Lon // win_lon, Lat // win_lat, win_lat, win_lon, -1)
909
+ x = x.permute(0, 2, 3, 1, 4, 5).contiguous().view(B, Lat, Lon, -1)
910
+ return x
911
+
912
+
913
+ def get_shift_window_mask(input_resolution, window_size, shift_size, ndim=3):
914
+ """
915
+ Along the longitude dimension, the leftmost and rightmost indices are actually close to each other.
916
+ If half windows apper at both leftmost and rightmost positions, they are dircetly merged into one window.
917
+ Args:
918
+ input_resolution (tuple[int]): [pressure levels, latitude, longitude] or [latitude, longitude]
919
+ window_size (tuple[int]): Window size [pressure levels, latitude, longitude] or [latitude, longitude]
920
+ shift_size (tuple[int]): Shift size for SW-MSA [pressure levels, latitude, longitude] or [latitude, longitude]
921
+ ndim (int): dimension of window (3 or 2)
922
+
923
+ Returns:
924
+ attn_mask: (n_lon, n_pl*n_lat, win_pl*win_lat*win_lon, win_pl*win_lat*win_lon) or (n_lon, n_lat, win_lat*win_lon, win_lat*win_lon)
925
+ """
926
+ if ndim == 3:
927
+ Pl, Lat, Lon = input_resolution
928
+ win_pl, win_lat, win_lon = window_size
929
+ shift_pl, shift_lat, shift_lon = shift_size
930
+
931
+ img_mask = torch.zeros((1, Pl, Lat, Lon + shift_lon, 1))
932
+ elif ndim == 2:
933
+ Lat, Lon = input_resolution
934
+ win_lat, win_lon = window_size
935
+ shift_lat, shift_lon = shift_size
936
+
937
+ img_mask = torch.zeros((1, Lat, Lon + shift_lon, 1))
938
+
939
+ if ndim == 3:
940
+ pl_slices = (
941
+ slice(0, -win_pl),
942
+ slice(-win_pl, -shift_pl),
943
+ slice(-shift_pl, None),
944
+ )
945
+ lat_slices = (
946
+ slice(0, -win_lat),
947
+ slice(-win_lat, -shift_lat),
948
+ slice(-shift_lat, None),
949
+ )
950
+ lon_slices = (
951
+ slice(0, -win_lon),
952
+ slice(-win_lon, -shift_lon),
953
+ slice(-shift_lon, None),
954
+ )
955
+
956
+ cnt = 0
957
+ if ndim == 3:
958
+ for pl in pl_slices:
959
+ for lat in lat_slices:
960
+ for lon in lon_slices:
961
+ img_mask[:, pl, lat, lon, :] = cnt
962
+ cnt += 1
963
+ img_mask = img_mask[:, :, :, :Lon, :]
964
+ elif ndim == 2:
965
+ for lat in lat_slices:
966
+ for lon in lon_slices:
967
+ img_mask[:, lat, lon, :] = cnt
968
+ cnt += 1
969
+ img_mask = img_mask[:, :, :Lon, :]
970
+
971
+ mask_windows = window_partition(
972
+ img_mask, window_size, ndim=ndim
973
+ ) # n_lon, n_pl*n_lat, win_pl, win_lat, win_lon, 1 or n_lon, n_lat, win_lat, win_lon, 1
974
+ if ndim == 3:
975
+ win_total = win_pl * win_lat * win_lon
976
+ elif ndim == 2:
977
+ win_total = win_lat * win_lon
978
+ mask_windows = mask_windows.view(
979
+ mask_windows.shape[0], mask_windows.shape[1], win_total
980
+ )
981
+ attn_mask = mask_windows.unsqueeze(2) - mask_windows.unsqueeze(3)
982
+ attn_mask = attn_mask.masked_fill(attn_mask != 0, float(-100.0)).masked_fill(
983
+ attn_mask == 0, float(0.0)
984
+ )
985
+ return attn_mask
986
+
987
+
988
+
989
+ ####### FuserLayer ###########
990
+
991
+
992
+ class FuserLayer(nn.Module):
993
+ """Revise from WeatherLearn https://github.com/lizhuoq/WeatherLearn
994
+ A basic 3D Transformer layer for one stage
995
+
996
+ Args:
997
+ dim (int): Number of input channels.
998
+ input_resolution (tuple[int]): Input resolution.
999
+ depth (int): Number of blocks.
1000
+ num_heads (int): Number of attention heads.
1001
+ window_size (tuple[int]): Local window size.
1002
+ mlp_ratio (float): Ratio of mlp hidden dim to embedding dim.
1003
+ qkv_bias (bool, optional): If True, add a learnable bias to query, key, value. Default: True
1004
+ qk_scale (float | None, optional): Override default qk scale of head_dim ** -0.5 if set.
1005
+ drop (float, optional): Dropout rate. Default: 0.0
1006
+ attn_drop (float, optional): Attention dropout rate. Default: 0.0
1007
+ drop_path (float | tuple[float], optional): Stochastic depth rate. Default: 0.0
1008
+ norm_layer (nn.Module, optional): Normalization layer. Default: nn.LayerNorm
1009
+ """
1010
+
1011
+ def __init__(
1012
+ self,
1013
+ dim,
1014
+ input_resolution,
1015
+ depth,
1016
+ num_heads,
1017
+ window_size,
1018
+ mlp_ratio=4.0,
1019
+ qkv_bias=True,
1020
+ qk_scale=None,
1021
+ drop=0.0,
1022
+ attn_drop=0.0,
1023
+ drop_path=0.0,
1024
+ norm_layer=nn.LayerNorm,
1025
+ ):
1026
+ super().__init__()
1027
+ self.dim = dim
1028
+ self.input_resolution = input_resolution
1029
+ self.depth = depth
1030
+
1031
+ self.blocks = nn.ModuleList(
1032
+ [
1033
+ Transformer3DBlock(
1034
+ dim=dim,
1035
+ input_resolution=input_resolution,
1036
+ num_heads=num_heads,
1037
+ window_size=window_size,
1038
+ shift_size=(0, 0, 0) if i % 2 == 0 else None,
1039
+ mlp_ratio=mlp_ratio,
1040
+ qkv_bias=qkv_bias,
1041
+ qk_scale=qk_scale,
1042
+ drop=drop,
1043
+ attn_drop=attn_drop,
1044
+ drop_path=drop_path[i]
1045
+ if isinstance(drop_path, Sequence)
1046
+ else drop_path,
1047
+ norm_layer=norm_layer,
1048
+ )
1049
+ for i in range(depth)
1050
+ ]
1051
+ )
1052
+
1053
+ def forward(self, x):
1054
+ for blk in self.blocks:
1055
+ x = blk(x)
1056
+ return x
1057
+
1058
+
1059
+
1060
+ class Pangu(nn.Module):
1061
+ """
1062
+ Pangu A PyTorch impl of: `Pangu-Weather: A 3D High-Resolution Model for Fast and Accurate Global Weather Forecast`
1063
+ - https://arxiv.org/abs/2211.02556
1064
+
1065
+ Args:
1066
+ img_size (tuple[int]): Image size [Lat, Lon].
1067
+ patch_size (tuple[int]): Patch token size [Lat, Lon].
1068
+ embed_dim (int): Patch embedding dimension. Default: 192
1069
+ num_heads (tuple[int]): Number of attention heads in different layers.
1070
+ window_size (tuple[int]): Window size.
1071
+ """
1072
+
1073
+ def __init__(
1074
+ self,
1075
+ in_shape=(1, 69, 180, 360),
1076
+ patch_size=(2, 4, 4),
1077
+ embed_dim=384,
1078
+ num_heads=(6, 12, 12, 6),
1079
+ window_size=(2, 6, 12),
1080
+ **kwargs):
1081
+ super().__init__()
1082
+
1083
+
1084
+ drop_path = np.linspace(0, 0.2, 8).tolist()
1085
+ T, C, H, W = in_shape
1086
+ img_size = (H,W)
1087
+
1088
+ # In addition, three constant masks(the topography mask, land-sea mask and soil type mask)
1089
+ self.patchembed2d = PatchEmbed2D(
1090
+ img_size=img_size,
1091
+ patch_size=patch_size[1:],
1092
+ in_chans=4, # add
1093
+ embed_dim=embed_dim,
1094
+ )
1095
+ self.patchembed3d = PatchEmbed3D(
1096
+ img_size=(13, img_size[0], img_size[1]),
1097
+ patch_size=patch_size,
1098
+ in_chans=5,
1099
+ embed_dim=embed_dim,
1100
+ )
1101
+ patched_inp_shape = (
1102
+ 8,
1103
+ math.ceil(img_size[0] / patch_size[1]),
1104
+ math.ceil(img_size[1] / patch_size[2]),
1105
+ )
1106
+
1107
+ self.layer1 = FuserLayer(
1108
+ dim=embed_dim,
1109
+ input_resolution=patched_inp_shape,
1110
+ depth=2,
1111
+ num_heads=num_heads[0],
1112
+ window_size=window_size,
1113
+ drop_path=drop_path[:2],
1114
+ )
1115
+
1116
+ patched_inp_shape_downsample = (
1117
+ 8,
1118
+ math.ceil(patched_inp_shape[1] / 2),
1119
+ math.ceil(patched_inp_shape[2] / 2),
1120
+ )
1121
+ self.downsample = DownSample3D(
1122
+ in_dim=embed_dim,
1123
+ input_resolution=patched_inp_shape,
1124
+ output_resolution=patched_inp_shape_downsample,
1125
+ )
1126
+ self.layer2 = FuserLayer(
1127
+ dim=embed_dim * 2,
1128
+ input_resolution=patched_inp_shape_downsample,
1129
+ depth=6,
1130
+ num_heads=num_heads[1],
1131
+ window_size=window_size,
1132
+ drop_path=drop_path[2:],
1133
+ )
1134
+ self.layer3 = FuserLayer(
1135
+ dim=embed_dim * 2,
1136
+ input_resolution=patched_inp_shape_downsample,
1137
+ depth=6,
1138
+ num_heads=num_heads[2],
1139
+ window_size=window_size,
1140
+ drop_path=drop_path[2:],
1141
+ )
1142
+ self.upsample = UpSample3D(
1143
+ embed_dim * 2, embed_dim, patched_inp_shape_downsample, patched_inp_shape
1144
+ )
1145
+ self.layer4 = FuserLayer(
1146
+ dim=embed_dim,
1147
+ input_resolution=patched_inp_shape,
1148
+ depth=2,
1149
+ num_heads=num_heads[3],
1150
+ window_size=window_size,
1151
+ drop_path=drop_path[:2],
1152
+ )
1153
+ # The outputs of the 2nd encoder layer and the 7th decoder layer are catenated along the channel dimension.
1154
+ self.patchrecovery2d = PatchRecovery2D(
1155
+ img_size, patch_size[1:], 2 * embed_dim, 4
1156
+ )
1157
+ self.patchrecovery3d = PatchRecovery3D(
1158
+ (13, img_size[0], img_size[1]), patch_size, 2 * embed_dim, 5
1159
+ )
1160
+
1161
+ def prepare_input(self, surface, surface_mask, upper_air):
1162
+ """Prepares the input to the model in the required shape.
1163
+ Args:
1164
+ surface (torch.Tensor): 2D n_lat=721, n_lon=1440, chans=4.
1165
+ surface_mask (torch.Tensor): 2D n_lat=721, n_lon=1440, chans=3.
1166
+ upper_air (torch.Tensor): 3D n_pl=13, n_lat=721, n_lon=1440, chans=5.
1167
+ """
1168
+ upper_air = upper_air.reshape(
1169
+ upper_air.shape[0], -1, upper_air.shape[3], upper_air.shape[4]
1170
+ )
1171
+ surface_mask = surface_mask.unsqueeze(0).repeat(surface.shape[0], 1, 1, 1)
1172
+ return torch.cat([surface, surface_mask, upper_air], dim=1)
1173
+
1174
+ def forward(self, x):
1175
+ """
1176
+ Args:
1177
+ x (torch.Tensor): [batch,T,4+5*13, lat, lon]
1178
+ """
1179
+ x = x.squeeze(1)
1180
+
1181
+ surface = x[:, :4, :, :]
1182
+ upper_air = x[:, 4:, :, :].reshape(x.shape[0], 5, 13, x.shape[2], x.shape[3])
1183
+ surface = self.patchembed2d(surface)
1184
+ upper_air = self.patchembed3d(upper_air)
1185
+
1186
+ x = torch.cat([surface.unsqueeze(2), upper_air], dim=2)
1187
+ B, C, Pl, Lat, Lon = x.shape
1188
+
1189
+ x = x.reshape(B, C, -1).transpose(1, 2)
1190
+
1191
+ x = self.layer1(x)
1192
+
1193
+ skip = x
1194
+
1195
+ x = self.downsample(x)
1196
+ x = self.layer2(x)
1197
+ x = self.layer3(x)
1198
+ x = self.upsample(x)
1199
+ x = self.layer4(x)
1200
+
1201
+ output = torch.cat([x, skip], dim=-1)
1202
+ output = output.transpose(1, 2).reshape(B, -1, Pl, Lat, Lon)
1203
+ output_surface = output[:, :, 0, :, :]
1204
+ output_upper_air = output[:, :, 1:, :, :]
1205
+
1206
+ output_surface = self.patchrecovery2d(output_surface)
1207
+ output_upper_air = self.patchrecovery3d(output_upper_air)
1208
+
1209
+ B,_,__,Lat,Lon=output_upper_air.shape
1210
+ final_output = torch.cat([output_surface,output_upper_air.reshape(B,5*13,Lat,Lon)],dim=1).unsqueeze(1)
1211
+ return final_output
1212
+
1213
+ if __name__ == '__main__':
1214
+ inputs = torch.randn(1, 1, 69, 180, 360)
1215
+ model = Pangu(in_shape=(1, 69, 180, 360))
1216
+ output = model(inputs)
1217
+ print(inputs.shape)
1218
+ print(output.shape)
Exp1_Global_weather_forecasting/plt_triton/.DS_Store ADDED
Binary file (6.15 kB). View file
 
Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/.DS_Store ADDED
Binary file (10.2 kB). View file
 
Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2018/.DS_Store ADDED
Binary file (6.15 kB). View file
 
Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2018/Fuxi_210.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1e5acd314deaabad580ec55c01b76a74013bb05c4d8a54a6c22cb0310c60d252
3
+ size 17884928
Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2018/Pangu_210.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dfd14601a410d87b38e9d0bb64f59d7cd349c23b91d9f46be480ca7a3f57b115
3
+ size 17884928
Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2018/SFNO_210.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:af3d4c417521c4ddb4d0091fb99ca8904c913fde0c18985577d07abafd630777
3
+ size 17884928
Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2018/Triton_210_day.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a6e10e76d95de03068ea788557848d4771974009c7d8f18de4f952a8bda84bac
3
+ size 17884928
Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2018/groundtruth_210.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8f8c3bf1f921af120ad63ccb4db0c2419e76b6e5e90f3cfbf9968b8e716b502d
3
+ size 17884928
Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2018/initial_input.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1e15ee08e3843e75a12fb6238b87e08eddb1e4b6b371197fcf2278ff4c59944a
3
+ size 17884928
Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2018/vis.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/.DS_Store ADDED
Binary file (6.15 kB). View file
 
Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_initial_input.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1e15ee08e3843e75a12fb6238b87e08eddb1e4b6b371197fcf2278ff4c59944a
3
+ size 17884928
Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_prediction_step_0.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5891e14364685fbc8da90689f9eb4b70abf83bb06fdb4ef54751374c7296e094
3
+ size 17884928
Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_prediction_step_13.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2ff9b99d9545e9f226225524ef015282e6a7101423f442233339813ab5404253
3
+ size 17884928
Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_prediction_step_179.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7fee6f5eac7cd10f65bdd6cb4caa9dd03cd9295c8a5f69339f1da2086f5a8b2a
3
+ size 17884928
Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_prediction_step_2.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b0f7f3a83d1f5d1529e2a6cba57242540ccf124b8203bec0f31873852a86be7d
3
+ size 17884928
Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_prediction_step_29.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:52081d5f9a049eb280a5866cd51e917f757938bf09277e2d6acf10fabd8b5c13
3
+ size 17884928
Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_prediction_step_4.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eddd04fe8f3e47240f2e837538d997ceca0a6e6880e7e0845a633b61c9c0a85c
3
+ size 17884928
Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_prediction_step_6.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:afb04a18c9dc483b35be03e18102f3369e7704502a47c2303294b2296a53a3fa
3
+ size 17884928
Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_prediction_step_9.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f5c08349d81b1337dee41d1ca7391128b4a75d3a858fbbf43efc17d652ed8b97
3
+ size 17884928
Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_true_label_step_0.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b9f297703389c2d684f268a07f1dc48fbdba0534ce4c37a706f76cd182fa5759
3
+ size 17884928
Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_true_label_step_13.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0495dbfc103c9d2b69f75710bf64948523c59b6b4b34e133e0316fbd339b4270
3
+ size 17884928
Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_true_label_step_179.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:67cc499e88c0bc24290f1550aeaec58df936a3de221473ae5854cfea8f099582
3
+ size 17884928
Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_true_label_step_2.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e7bc93d6593855fccdcd5b35df196dfa5758e33b27b5a1a95e2bbb3ae5663744
3
+ size 17884928
Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_true_label_step_29.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1175796a11b9d12b4f04ad3c959b3b62b46f4b92723c3542c6b3d88dfb54e040
3
+ size 17884928
Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_true_label_step_4.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:de92a245cd366e8b42db8f3554b7eafc1ff2bbeba62ddce752f04bc0ae833c5b
3
+ size 17884928
Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_true_label_step_6.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4f8f379e99bc8337b1aa070f36aa58ea4716de1393cd59af08d84ffdfd19d103
3
+ size 17884928
Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/2020_triton_results/baselines_triton_20250326_exp1_true_label_step_9.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:57561ae16acafa5b03eeef0ede659513bfeb1fd718de9f9db0dd80fe9a6641c1
3
+ size 17884928
Exp1_Global_weather_forecasting/plt_triton/S1_weather_forecasting/vis_triton_weather.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
Exp1_Global_weather_forecasting/results_2018/vis_2018.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
Exp1_Global_weather_forecasting/train.py ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import random
3
+ import torch
4
+ import numpy as np
5
+ import torch.nn as nn
6
+ import torch.optim as optim
7
+ from torch.utils.data import DataLoader
8
+ import torch.utils.data as data
9
+ import torch.distributed as dist
10
+ import torch.multiprocessing as mp
11
+ import netCDF4 as nc
12
+ import torchvision.transforms as transforms
13
+ from dataloader_api.dataloader import *
14
+ from tqdm import tqdm
15
+ import logging
16
+ import numpy as np
17
+ import torch
18
+ from torch.utils.data import Dataset, DataLoader
19
+ import torch
20
+ from torch.utils.data import DataLoader, ConcatDataset
21
+ from torch.utils.data.distributed import DistributedSampler
22
+ from model.Triton_model import *
23
+ from model_baselines.pangu_model import *
24
+
25
+ # Setup logging
26
+ backbone = 'triton_weather_20250326_v1'
27
+ logging.basicConfig(filename=f'/jizhicfs/easyluwu/ocean_project/NPJ_baselines/Exp_0_Weather/logs/{backbone}_training_log.log',
28
+ level=logging.INFO,
29
+ format='%(asctime)s %(message)s')
30
+
31
+ # Set a specific seed
32
+ seed = 42
33
+ def set_seed(seed):
34
+ random.seed(seed)
35
+ np.random.seed(seed)
36
+ torch.manual_seed(seed)
37
+ torch.cuda.manual_seed(seed)
38
+ torch.cuda.manual_seed_all(seed)
39
+ torch.backends.cudnn.deterministic = True
40
+ torch.backends.cudnn.benchmark = False
41
+
42
+ set_seed(seed)
43
+
44
+ # =========================================================================== dist train ========================================================================================================================
45
+ dist.init_process_group(backend='nccl')
46
+ local_rank = int(os.environ['LOCAL_RANK'])
47
+ torch.cuda.set_device(local_rank)
48
+ device = torch.device("cuda", local_rank)
49
+ num_gpus = torch.cuda.device_count()
50
+
51
+ def reduce_mean(tensor, nprocs):
52
+ rt = tensor.clone()
53
+ dist.all_reduce(rt, op=dist.ReduceOp.SUM)
54
+ rt /= nprocs
55
+ return rt
56
+
57
+ # ============================================================= data load ===================================================
58
+ args = {
59
+ 'data_path': '/jizhicfs/easyluwu/scaling_law/ft_local/low_res',
60
+ 'ocean_lead_time': 1,
61
+ 'atmosphere_lead_time': 1,
62
+ 'shuffle': True,
63
+ 'variables_input': list(range(69)),
64
+ 'variables_output': list(range(69)),
65
+ 'lon_start': 0,
66
+ 'lat_start': 0,
67
+ 'lon_end': 1440,
68
+ 'lat_end': 720,
69
+ 'ds_factor': 1,
70
+ }
71
+
72
+ train_dataset = train_Dataset(args)
73
+ test_dataset = test_Dataset(args)
74
+
75
+ train_sampler = data.distributed.DistributedSampler(train_dataset)
76
+ train_loader = data.DataLoader(train_dataset,
77
+ num_workers=0,
78
+ batch_size=1,
79
+ sampler=train_sampler)
80
+
81
+ test_sampler = data.distributed.DistributedSampler(test_dataset)
82
+ test_loader = data.DataLoader(test_dataset,
83
+ num_workers=0,
84
+ batch_size=1,
85
+ sampler=test_sampler)
86
+
87
+ for inputs, targets in iter(train_loader):
88
+ print(inputs.shape, targets.shape)
89
+ break
90
+
91
+ # ================================================ model load ===========================================================
92
+ model = Triton(
93
+ shape_in=(1, 69, 180, 360),
94
+ spatial_hidden_dim=256,
95
+ output_channels=69,
96
+ temporal_hidden_dim=512,
97
+ num_spatial_layers=4,
98
+ num_temporal_layers=8)
99
+
100
+ model = model.to(device)
101
+ model = torch.nn.parallel.DistributedDataParallel(model, device_ids=[local_rank], find_unused_parameters=True)
102
+
103
+ # ============================== criterion and optimizer ======================================================
104
+ criterion = nn.MSELoss()
105
+ optimizer = optim.Adam(model.parameters(), lr=1e-3)
106
+ scheduler = torch.optim.lr_scheduler.StepLR(optimizer, step_size=50, gamma=0.2)
107
+
108
+ # ===========================train val and test ======================================
109
+ def train(model, train_loader, criterion, optimizer, device):
110
+ model.train()
111
+ train_loss = 0.0
112
+ for inputs, targets in tqdm(train_loader, desc="Training", disable=local_rank != 0):
113
+ inputs, targets = inputs.to(device, non_blocking=True), targets.to(device, non_blocking=True)
114
+ optimizer.zero_grad()
115
+ outputs = model(inputs)
116
+ loss = criterion(outputs, targets)
117
+ loss.backward()
118
+ optimizer.step()
119
+ train_loss += loss.item() * inputs.size(0)
120
+ return train_loss / len(train_loader.dataset)
121
+
122
+ def validate(model, val_loader, criterion, device):
123
+ model.eval()
124
+ val_loss = 0.0
125
+ with torch.no_grad():
126
+ for inputs, targets in tqdm(val_loader, desc="Validation", disable=local_rank != 0):
127
+ inputs, targets = inputs.to(device, non_blocking=True), targets.to(device, non_blocking=True)
128
+ outputs = model(inputs)
129
+ loss = criterion(outputs, targets)
130
+ val_loss += loss.item() * inputs.size(0)
131
+ return val_loss / len(val_loader.dataset)
132
+
133
+ def test(model, test_loader, criterion, device):
134
+ path = '/jizhicfs/easyluwu/ocean_project/NPJ_baselines/Exp_0_Weather/results'
135
+ model.eval()
136
+ test_loss = 0.0
137
+
138
+ all_inputs = []
139
+ all_targets = []
140
+ all_outputs = []
141
+ i = 0
142
+ with torch.no_grad():
143
+ for inputs, targets in tqdm(test_loader, desc="Testing", disable=local_rank != 0):
144
+ i += 1
145
+ print(f"{i} : {inputs.shape}")
146
+ inputs, targets = inputs.to(device, non_blocking=True), targets.to(device, non_blocking=True)
147
+ outputs = model(inputs)
148
+
149
+ # Convert tensors to numpy arrays and append to lists
150
+ all_inputs.append(inputs.cpu().numpy())
151
+ all_targets.append(targets.cpu().numpy())
152
+ all_outputs.append(outputs.cpu().numpy())
153
+
154
+ loss = criterion(outputs, targets)
155
+ test_loss += loss.item() * inputs.size(0)
156
+
157
+ all_inputs = np.concatenate(all_inputs, axis=0)
158
+ all_targets = np.concatenate(all_targets, axis=0)
159
+ all_outputs = np.concatenate(all_outputs, axis=0)
160
+
161
+ if local_rank == 0:
162
+ np.save(f'{path}/{backbone}_inputs.npy', all_inputs)
163
+ np.save(f'{path}/{backbone}_targets.npy', all_targets)
164
+ np.save(f'{path}/{backbone}_outputs.npy', all_outputs)
165
+ print(test_loss)
166
+ print(len(test_loader.dataset))
167
+ print(i)
168
+ return test_loss / len(test_loader.dataset)
169
+
170
+ num_epochs = 1000
171
+ best_val_loss = float('inf')
172
+ best_model_path = f'/jizhicfs/easyluwu/ocean_project/NPJ_baselines/Exp_0_Weather/checkpoints/{backbone}_best_model.pth'
173
+
174
+ if local_rank == 0 and os.path.exists(best_model_path):
175
+ try:
176
+ logging.info('Loading best model from checkpoint.')
177
+ checkpoint = torch.load(best_model_path, map_location=device)
178
+ model.load_state_dict(checkpoint)
179
+ except Exception as e:
180
+ logging.error(f'Error loading model checkpoint: {e}')
181
+
182
+ for epoch in range(num_epochs):
183
+ if local_rank == 0:
184
+ logging.info(f'Epoch {epoch + 1}/{num_epochs}')
185
+ train_loss = train(model, train_loader, criterion, optimizer, device)
186
+ val_loss = validate(model, test_loader, criterion, device)
187
+
188
+ if local_rank == 0:
189
+ if val_loss < best_val_loss:
190
+ best_val_loss = val_loss
191
+ torch.save(model.state_dict(), best_model_path)
192
+
193
+ logging.info(f'Train Loss: {train_loss * num_gpus:.7f}, Val Loss: {val_loss * num_gpus:.7f}')
194
+
195
+ if local_rank == 0:
196
+ try:
197
+ model.load_state_dict(torch.load(best_model_path))
198
+ test_loss = test(model, test_loader, criterion, device)
199
+ logging.info(f"Testing completed and best model saved. | test_loss:{test_loss * num_gpus:.7f}")
200
+ except Exception as e:
201
+ logging.error(f'Error loading model checkpoint during testing: {e}')
202
+
203
+ dist.destroy_process_group()