griffingoodwin04 commited on
Commit
d01e1f1
·
1 Parent(s): a24ac36

update model configuration: adjust batch size, patch size, dropout rate, and checkpoint paths

Browse files
.idea/workspace.xml CHANGED
@@ -4,8 +4,14 @@
4
  <option name="autoReloadType" value="SELECTIVE" />
5
  </component>
6
  <component name="ChangeListManager">
7
- <list default="true" id="e883d810-3b4e-470d-b72e-9ed3eee941a0" name="Changes" comment="fixed some comments">
 
 
 
 
8
  <change beforePath="$PROJECT_DIR$/flaring/forecasting/models/vit_patch_model.py" beforeDir="false" afterPath="$PROJECT_DIR$/flaring/forecasting/models/vit_patch_model.py" afterDir="false" />
 
 
9
  </list>
10
  <option name="SHOW_DIALOG" value="false" />
11
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -143,7 +149,9 @@
143
  <workItem from="1755801805292" duration="58749000" />
144
  <workItem from="1756171392559" duration="40222000" />
145
  <workItem from="1756308588067" duration="10459000" />
146
- <workItem from="1756386184391" duration="57683000" />
 
 
147
  </task>
148
  <task id="LOCAL-00004" summary="update train code to save model as .pth, creating plotting jupyter notebook, updated inference code to accept checkpoints">
149
  <option name="closed" value="true" />
@@ -489,7 +497,15 @@
489
  <option name="project" value="LOCAL" />
490
  <updated>1756678669786</updated>
491
  </task>
492
- <option name="localTasksCounter" value="47" />
 
 
 
 
 
 
 
 
493
  <servers />
494
  </component>
495
  <component name="TypeScriptGeneratedFilesManager">
@@ -507,7 +523,6 @@
507
  </option>
508
  </component>
509
  <component name="VcsManagerConfiguration">
510
- <MESSAGE value="add visualization notebook and refactor model configuration; update batch size, patch size, and dropout rate; implement dynamic loss for SXR regression" />
511
  <MESSAGE value="update model configuration and training scripts; adjust learning rate, epochs, and data paths; refactor trainer initialization and logging" />
512
  <MESSAGE value="update model configuration and training scripts; change selected model to 'ViT Custom', increase epochs to 250, and adjust output paths; refactor model loading in inference to support hybrid models and attention weight saving" />
513
  <MESSAGE value="added evaluation script" />
@@ -532,7 +547,8 @@
532
  <MESSAGE value="implement wavelength dropout in training, just as a test... it's commented out" />
533
  <MESSAGE value="added support for a patch based model" />
534
  <MESSAGE value="fixed some comments" />
535
- <option name="LAST_COMMIT_MESSAGE" value="fixed some comments" />
 
536
  </component>
537
  <component name="XDebuggerManager">
538
  <breakpoint-manager>
 
4
  <option name="autoReloadType" value="SELECTIVE" />
5
  </component>
6
  <component name="ChangeListManager">
7
+ <list default="true" id="e883d810-3b4e-470d-b72e-9ed3eee941a0" name="Changes" comment="weight decay">
8
+ <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
9
+ <change beforePath="$PROJECT_DIR$/flaring/forecasting/inference/inference_config.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/flaring/forecasting/inference/inference_config.yaml" afterDir="false" />
10
+ <change beforePath="$PROJECT_DIR$/flaring/forecasting/inference/inference_on_patch.py" beforeDir="false" afterPath="$PROJECT_DIR$/flaring/forecasting/inference/inference_on_patch.py" afterDir="false" />
11
+ <change beforePath="$PROJECT_DIR$/flaring/forecasting/inference/inference_on_patch_config.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/flaring/forecasting/inference/inference_on_patch_config.yaml" afterDir="false" />
12
  <change beforePath="$PROJECT_DIR$/flaring/forecasting/models/vit_patch_model.py" beforeDir="false" afterPath="$PROJECT_DIR$/flaring/forecasting/models/vit_patch_model.py" afterDir="false" />
13
+ <change beforePath="$PROJECT_DIR$/flaring/forecasting/training/config.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/flaring/forecasting/training/config.yaml" afterDir="false" />
14
+ <change beforePath="$PROJECT_DIR$/flaring/forecasting/training/train.py" beforeDir="false" afterPath="$PROJECT_DIR$/flaring/forecasting/training/train.py" afterDir="false" />
15
  </list>
16
  <option name="SHOW_DIALOG" value="false" />
17
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
 
149
  <workItem from="1755801805292" duration="58749000" />
150
  <workItem from="1756171392559" duration="40222000" />
151
  <workItem from="1756308588067" duration="10459000" />
152
+ <workItem from="1756386184391" duration="64689000" />
153
+ <workItem from="1756818485332" duration="17000" />
154
+ <workItem from="1756821188374" duration="7721000" />
155
  </task>
156
  <task id="LOCAL-00004" summary="update train code to save model as .pth, creating plotting jupyter notebook, updated inference code to accept checkpoints">
157
  <option name="closed" value="true" />
 
497
  <option name="project" value="LOCAL" />
498
  <updated>1756678669786</updated>
499
  </task>
500
+ <task id="LOCAL-00047" summary="weight decay">
501
+ <option name="closed" value="true" />
502
+ <created>1756678864389</created>
503
+ <option name="number" value="00047" />
504
+ <option name="presentableId" value="LOCAL-00047" />
505
+ <option name="project" value="LOCAL" />
506
+ <updated>1756678864389</updated>
507
+ </task>
508
+ <option name="localTasksCounter" value="48" />
509
  <servers />
510
  </component>
511
  <component name="TypeScriptGeneratedFilesManager">
 
523
  </option>
524
  </component>
525
  <component name="VcsManagerConfiguration">
 
526
  <MESSAGE value="update model configuration and training scripts; adjust learning rate, epochs, and data paths; refactor trainer initialization and logging" />
527
  <MESSAGE value="update model configuration and training scripts; change selected model to 'ViT Custom', increase epochs to 250, and adjust output paths; refactor model loading in inference to support hybrid models and attention weight saving" />
528
  <MESSAGE value="added evaluation script" />
 
547
  <MESSAGE value="implement wavelength dropout in training, just as a test... it's commented out" />
548
  <MESSAGE value="added support for a patch based model" />
549
  <MESSAGE value="fixed some comments" />
550
+ <MESSAGE value="weight decay" />
551
+ <option name="LAST_COMMIT_MESSAGE" value="weight decay" />
552
  </component>
553
  <component name="XDebuggerManager">
554
  <breakpoint-manager>
flaring/forecasting/inference/inference_config.yaml CHANGED
@@ -1,7 +1,7 @@
1
  # Base directories - change these to switch datasets
2
  base_data_dir: "/mnt/data/ML-Ready-mixed/ML-Ready-mixed/" # Change this line for different datasets
3
- output_path: "${base_data_dir}/output//mnt/data/ML-Ready-mixed/ML-Ready-mixed/output/NEURIPS.csv"
4
- weight_path: "${base_data_dir}/NEURIPS_Weight/"
5
  mc:
6
  active: "false"
7
  runs: 5
@@ -18,7 +18,7 @@ SolO_data:
18
  sxr_dir: "${base_data_dir}/SXR"
19
  sxr_norm_path: "${base_data_dir}/SolO/SXR/normalized_sxr.npy"
20
  model: "cnn" # Options: "cnn", "vit", "ViT Custom"
21
- wavelengths: [94,131, 171, 193, 211, 304] # AIA wavelengths in Angstroms
22
  data:
23
  aia_dir:
24
  "${base_data_dir}/AIA"
@@ -27,6 +27,6 @@ data:
27
  sxr_norm_path:
28
  "/mnt/data/ML-Ready-mixed/ML-Ready-mixed/SXR/normalized_sxr.npy"
29
  checkpoint_path:
30
- "/mnt/data/ML-Ready-mixed/ML-Ready-mixed/new-checkpoint/megsai-added-data-final-20250807_065956.pth"
31
 
32
 
 
1
  # Base directories - change these to switch datasets
2
  base_data_dir: "/mnt/data/ML-Ready-mixed/ML-Ready-mixed/" # Change this line for different datasets
3
+ output_path: "${base_data_dir}/output//mnt/data/ML-Ready-mixed/ML-Ready-mixed/output/patch.csv"
4
+ weight_path: "${base_data_dir}/patch_Weight/"
5
  mc:
6
  active: "false"
7
  runs: 5
 
18
  sxr_dir: "${base_data_dir}/SXR"
19
  sxr_norm_path: "${base_data_dir}/SolO/SXR/normalized_sxr.npy"
20
  model: "cnn" # Options: "cnn", "vit", "ViT Custom"
21
+ wavelengths: [94, 131, 171, 193, 211, 304] # AIA wavelengths in Angstroms
22
  data:
23
  aia_dir:
24
  "${base_data_dir}/AIA"
 
27
  sxr_norm_path:
28
  "/mnt/data/ML-Ready-mixed/ML-Ready-mixed/SXR/normalized_sxr.npy"
29
  checkpoint_path:
30
+ "/mnt/data/ML-Ready-mixed/ML-Ready-mixed/new-checkpoint/vit-16-higher-weight-lower-decay-epoch=119-val_total_loss=0.0419.ckpt"
31
 
32
 
flaring/forecasting/inference/inference_on_patch.py CHANGED
@@ -237,7 +237,7 @@ def main():
237
  parser.add_argument('-config', type=str, default='config.yaml', required=True, help='Path to config YAML.')
238
  parser.add_argument('-input_size', type=int, default=512, help='Input size for the model')
239
  parser.add_argument('-patch_size', type=int, default=16, help='Patch size for the model')
240
- parser.add_argument('--batch_size', type=int, default=32, help='Batch size for inference')
241
  parser.add_argument('--no_weights', action='store_true', help='Skip saving attention weights to speed up')
242
  args = parser.parse_args()
243
 
 
237
  parser.add_argument('-config', type=str, default='config.yaml', required=True, help='Path to config YAML.')
238
  parser.add_argument('-input_size', type=int, default=512, help='Input size for the model')
239
  parser.add_argument('-patch_size', type=int, default=16, help='Patch size for the model')
240
+ parser.add_argument('--batch_size', type=int, default=4, help='Batch size for inference')
241
  parser.add_argument('--no_weights', action='store_true', help='Skip saving attention weights to speed up')
242
  args = parser.parse_args()
243
 
flaring/forecasting/inference/inference_on_patch_config.yaml CHANGED
@@ -27,5 +27,5 @@ data:
27
  sxr_norm_path:
28
  "/mnt/data/ML-Ready-mixed/ML-Ready-mixed/SXR/normalized_sxr.npy"
29
  checkpoint_path:
30
- "/mnt/data/ML-Ready-mixed/ML-Ready-mixed/new-checkpoint/vit-16-patch-final-final-20250831_113151.pth"
31
 
 
27
  sxr_norm_path:
28
  "/mnt/data/ML-Ready-mixed/ML-Ready-mixed/SXR/normalized_sxr.npy"
29
  checkpoint_path:
30
+ "/mnt/data/ML-Ready-mixed/ML-Ready-mixed/new-checkpoint/vit-16-higher-weight-lower-decay-epoch=119-val_total_loss=0.0419.ckpt"
31
 
flaring/forecasting/models/vit_patch_model.py CHANGED
@@ -289,7 +289,7 @@ def img_to_patch(x, patch_size, flatten_channels=True):
289
 
290
 
291
  class SXRRegressionDynamicLoss:
292
- def __init__(self, window_size=1000):
293
  self.c_threshold = 1e-6
294
  self.m_threshold = 1e-5
295
  self.x_threshold = 1e-4
@@ -302,14 +302,14 @@ class SXRRegressionDynamicLoss:
302
 
303
  self.base_weights = {
304
  'quiet': 1.0,
305
- 'c_class': 5.0,
306
  'm_class': 10.0,
307
  'x_class': 20.0
308
  }
309
 
310
  def calculate_loss(self, preds_squeezed, sxr, sxr_un, preds_squeezed_un):
311
  base_loss = F.huber_loss(preds_squeezed, sxr, delta=1.0, reduction='none')
312
- weights = self._get_adaptive_weights(sxr_un, preds_squeezed_un, base_loss)
313
  self._update_tracking(sxr_un, preds_squeezed_un, base_loss)
314
  weighted_loss = base_loss * weights
315
  loss = weighted_loss.mean()
 
289
 
290
 
291
  class SXRRegressionDynamicLoss:
292
+ def __init__(self, window_size=1500):
293
  self.c_threshold = 1e-6
294
  self.m_threshold = 1e-5
295
  self.x_threshold = 1e-4
 
302
 
303
  self.base_weights = {
304
  'quiet': 1.0,
305
+ 'c_class': 8.0,
306
  'm_class': 10.0,
307
  'x_class': 20.0
308
  }
309
 
310
  def calculate_loss(self, preds_squeezed, sxr, sxr_un, preds_squeezed_un):
311
  base_loss = F.huber_loss(preds_squeezed, sxr, delta=1.0, reduction='none')
312
+ weights = self._get_adaptive_weights(sxr_un)
313
  self._update_tracking(sxr_un, preds_squeezed_un, base_loss)
314
  weighted_loss = base_loss * weights
315
  loss = weighted_loss.mean()
flaring/forecasting/training/config.yaml CHANGED
@@ -5,9 +5,9 @@ base_checkpoint_dir: "/mnt/data/ML-Ready-mixed/ML-Ready-mixed" # Change this
5
  wavelengths: [94, 131, 171, 193, 211, 304] # AIA wavelengths in Angstroms
6
  # Model configuration
7
  selected_model: "ViT Patch" # Options: "cnn", "vit",
8
- batch_size: 80
9
  epochs: 500
10
- oversample: true
11
  balance_strategy: "upsample_minority"
12
 
13
  megsai:
@@ -21,12 +21,12 @@ vit_custom:
21
  embed_dim: 512
22
  num_channels: 6
23
  num_classes: 1
24
- patch_size: 16
25
- num_patches: 1024
26
  hidden_dim: 512
27
  num_heads: 8
28
  num_layers: 6
29
- dropout: 0.2
30
  lr: 0.0001
31
 
32
  # Data paths (automatically constructed from base directories)
@@ -48,5 +48,5 @@ wandb:
48
  - aia
49
  - sxr
50
  - regression
51
- wb_name: vit-16-patch-final-oversample-higher-weights
52
  notes: Regression from AIA images (6 channels) to GOES SXR flux
 
5
  wavelengths: [94, 131, 171, 193, 211, 304] # AIA wavelengths in Angstroms
6
  # Model configuration
7
  selected_model: "ViT Patch" # Options: "cnn", "vit",
8
+ batch_size: 4
9
  epochs: 500
10
+ oversample: false
11
  balance_strategy: "upsample_minority"
12
 
13
  megsai:
 
21
  embed_dim: 512
22
  num_channels: 6
23
  num_classes: 1
24
+ patch_size: 8
25
+ num_patches: 4096
26
  hidden_dim: 512
27
  num_heads: 8
28
  num_layers: 6
29
+ dropout: 0.1
30
  lr: 0.0001
31
 
32
  # Data paths (automatically constructed from base directories)
 
48
  - aia
49
  - sxr
50
  - regression
51
+ wb_name: vit-8-patch
52
  notes: Regression from AIA images (6 channels) to GOES SXR flux
flaring/forecasting/training/train.py CHANGED
@@ -166,7 +166,7 @@ checkpoint_callback = ModelCheckpoint(
166
  dirpath=config_data['data']['checkpoints_dir'],
167
  monitor='val_total_loss',
168
  mode='min',
169
- save_top_k=4,
170
  filename=f"{config_data['wandb']['wb_name']}-{{epoch:02d}}-{{val_total_loss:.4f}}"
171
  )
172
 
 
166
  dirpath=config_data['data']['checkpoints_dir'],
167
  monitor='val_total_loss',
168
  mode='min',
169
+ save_top_k=10,
170
  filename=f"{config_data['wandb']['wb_name']}-{{epoch:02d}}-{{val_total_loss:.4f}}"
171
  )
172