-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigs.py
2418 lines (2114 loc) · 91.8 KB
/
configs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
#!/usr/bin/env python
"""
Filename = Foobar.py
Description = Lorem ipsum dolor sit amet
Created on Sat Nov 27 17:09:58 2021
__author__ = nnarenraju
__copyright__ = Copyright 2021, ProjectName
__credits__ = nnarenraju
__license__ = MIT Licence
__version__ = 0.0.1
__maintainer__ = nnarenraju
__email__ = nnarenraju@gmail.com
__status__ = ['inProgress', 'Archived', 'inUsage', 'Debugging']
Github Repository: NULL
Documentation:
[1] Using OSnet
##Architecture
model = SigmaModel
# Kernel sizes on modified OSnet (type 1)
kernel_sizes = []
kernel_sizes.append([[16, 32, 64, 128, 256], [8, 16, 32, 64, 128]])
kernel_sizes.append([[8, 16, 32, 64, 128], [2, 4, 8, 16, 32]])
kernel_sizes.append([[2, 4, 8, 16, 32], [2, 4, 8, 16, 32]])
model_params = dict(
## OSnet + Resnet50 CBAM
model_name='sigmanet',
norm_layer = 'instancenorm',
## OSnet params
# channels[0] is used when initial_dim_reduction == True
channels=[16, 32, 64, 128],
kernel_sizes=kernel_sizes,
# strides[:2] is used when initial_dim_reduction == True
strides=[2,2,8,4],
stacking=False,
initial_dim_reduction=False,
# reduction value of 16 does not work with KaggleNet type kernels
channel_gate_reduction=8,
# ResNet CBAM params
resnet_size = 50,
# Common
store_device = 'cuda:2',
)
"""
# PACKAGES
import os
import torch
import subprocess
import numpy as np
import torch.optim as optim
from pathlib import Path
from torch.optim.lr_scheduler import CosineAnnealingWarmRestarts
## LOCAL
# Dataset objects
from data.datasets import MinimalOTF
# Architectures
from architectures.models import Rigatoni_MS_ResNetCBAM, Rigatoni_MS_ResNetCBAM_legacy, Rigatoni_MS_ResNetCBAM_legacy_minimal
from architectures.models import KappaModel_ResNet1D, KappaModelPE
from architectures.frontend import MultiScaleBlock
# Transforms, augmentation and generation
from data.transforms import Unify, UnifySignal, UnifyNoise, UnifySignalGen, UnifyNoiseGen
from data.transforms import Whiten, MultirateSampling, Normalise, MonorateSampling
from data.transforms import AugmentOptimalNetworkSNR, AugmentPolSky
from data.transforms import Recolour, HighPass
from data.transforms import Buffer, BufferPerChannel
# Generating signals and noise
from data.transforms import FastGenerateWaveform, SinusoidGenerator
from data.transforms import RandomNoiseSlice, MultipleFileRandomNoiseSlice, ColouredNoiseGenerator, WhiteNoiseGenerator
# Loss functions
from losses.custom_loss_functions import BCEWithPEregLoss, lPOPWithPEregLoss
# RayTune
from ray import tune
from ray.tune import CLIReporter
from ray.tune.schedulers import ASHAScheduler
# TASKS
# Cleanup prior modifications
# Change all mention on ORChiD to Sage
# All tmp files must be placed in a single location (eg. segments.csv)
# code to produce all tmp files must be consolidated (add to utils)
# code to download noise files for full experimentation must be consolidated (add to utils)
# Change all debug folders to exist within export_dir
# Clean unify noise gen
# Move all external data into one directory (psds, O3 noise, etc.)
# Add verbosity to all modules
# Add logging to all modules
# Add documentation to all classes and functions
# Add diagnostic tests with at least 90% coverage
# Add Sage logo to output
""" CUSTOM MODELS FOR EXPERIMENTATION """
class SageNetOTF:
""" Data storage """
name = "SageNet50_CBAM_OTF_Feb03_dummy"
export_dir = Path("/home/nnarenraju/Research/ORChiD/RUNS") / name
debug_dir = "./DEBUG"
git_revparse = subprocess.run(["git", "rev-parse", "--show-toplevel"], capture_output = True, text = True)
repo_abspath = os.path.join(git_revparse.stdout.strip('\n'), 'sage')
""" RayTune (Untested) """
# Placed before initialising any relevant tunable parameter
# WARNING: Required compute is prohibitively large for large models
rtune_optimise = False
rtune_params = dict(
# RayTune Tunable Parameters
config = {
"learning_rate": tune.loguniform(1e-5, 1e-2),
"batch_size": tune.choice([32,])
},
# Scheduler (ASHA has intelligent early stopping)
scheduler = ASHAScheduler,
# NOTE: max_t is maximum number of epochs Tune is allowed to run
scheduler_params = dict(
metric = "loss",
mode = "min",
max_t = 10,
grace_period = 1,
reduction_factor = 2
),
# Reporter
reporter = CLIReporter,
reporter_params = dict(
metric_columns=["loss", "accuracy", "low_far_nsignals", "training_iteration"]
),
# To sample multiple times/run multiple trials
# Samples from config num_samples number of times
num_samples = 100
)
""" Dataset """
dataset = MinimalOTF
dataset_params = dict()
""" Architecture """
model = Rigatoni_MS_ResNetCBAM
# Following options available for pe point estimate
# 'norm_tc', 'norm_dchirp', 'norm_mchirp',
# 'norm_dist', 'norm_q', 'norm_invq', 'norm_snr'
model_params = dict(
scales = [1, 2, 4, 0.5, 0.25],
blocks = [
[MultiScaleBlock, MultiScaleBlock],
[MultiScaleBlock, MultiScaleBlock],
[MultiScaleBlock, MultiScaleBlock]
],
out_channels = [[32, 32], [64, 64], [128, 128]],
base_kernel_sizes = [
[64, 64 // 2 + 1],
[64 // 2 + 1, 64 // 4 + 1],
[64 // 4 + 1, 64 // 4 + 1]
],
compression_factor = [8, 4, 0],
in_channels = 1,
resnet_size = 50,
parameter_estimation = ('norm_tc', 'norm_mchirp', ),
norm_layer = 'instancenorm',
store_device = 'cuda:0',
review = True
)
""" Epochs and Batches """
num_epochs = 500
batch_size = 64
validation_plot_freq = 1 # every n epochs
""" Weight Types """
# Lowest loss, highest accuracy, highest auc, highest low_far_nsignals found
weight_types = ['loss', 'accuracy', 'roc_auc', 'low_far_nsignals']
# Save weights for particular epochs
save_epoch_weight = list(range(500))
# Pick one of the above weights for best epoch save directory
save_best_option = 'loss'
# Checkpoints
save_checkpoint = True
checkpoint_freq = 1 # every n epochs
resume_from_checkpoint = False
checkpoint_path = ""
pretrained = False
freeze_for_transfer = False
weights_path = 'weights_loss.pt'
""" Optimizer """
## Adam
optimizer = optim.Adam
optimizer_params = dict(lr=2e-4, weight_decay=1e-6)
""" Scheduler """
## Cosine Annealing with Warm Restarts
scheduler = CosineAnnealingWarmRestarts
scheduler_params = dict(T_0=5, T_mult=1, eta_min=1e-6)
""" Gradient Clipping """
clip_norm = 10000
""" Automatic Mixed Precision """
# Keep this turned off when using Adam
# It seems to be unstable and produces NaN losses
do_AMP = False
""" Storage Devices """
store_device = 'cuda:0'
train_device = 'cuda:0'
""" Dataloader params """
num_workers = 16
pin_memory = True
prefetch_factor = 4
persistent_workers = True
""" Loss Function """
# All parameter estimation is done only using MSE loss at the moment
loss_function = BCEWithPEregLoss(gw_loss=torch.nn.BCEWithLogitsLoss(), mse_alpha=1.0)
# Calculate the network SNR for pure noise samples as well
# If used with parameter estimation, custom loss function should have network_snr_for_noise option toggled
network_snr_for_noise = False
# Dataset imbalance
ignore_dset_imbalance = False
subset_for_funsies = False # debug_size is used for subset, debug need not be true
""" Generation """
# Augmentation using GWSPY glitches happens only during training (not for validation)
generation = dict(
signal = UnifySignalGen([
FastGenerateWaveform(rwrap = 3.0,
beta_taper = 8,
pad_duration_estimate = 1.1,
min_mass = 5.0,
debug_me = False
),
]),
noise = UnifyNoiseGen({
'training': RandomNoiseSlice(
real_noise_path="/local/scratch/igr/nnarenraju/O3a_real_noise/O3a_real_noise.hdf",
segment_llimit=133, segment_ulimit=-1, debug_me=False
),
'validation': RandomNoiseSlice(
real_noise_path="/local/scratch/igr/nnarenraju/O3a_real_noise/O3a_real_noise.hdf",
segment_llimit=0, segment_ulimit=132, debug_me=False
),
},
# Auxilliary noise data (only used for training, not for validation)
MultipleFileRandomNoiseSlice(noise_dirs=dict(
H1="/local/scratch/igr/nnarenraju/O3b_real_noise/H1",
L1="/local/scratch/igr/nnarenraju/O3b_real_noise/L1",
),
debug_me=False,
debug_dir=""
),
paux = 0.689, # 113/164 days for extra O3b noise
debug_me=False,
debug_dir=os.path.join(debug_dir, 'NoiseGen')
)
)
""" Transforms """
batchshuffle_noise = False
transforms = dict(
signal=UnifySignal([
AugmentOptimalNetworkSNR(rescale=True, use_uniform=True, snr_lower_limit=5.0, snr_upper_limit=15.0),
]),
noise=UnifyNoise([
Recolour(use_precomputed=True,
h1_psds_hdf=os.path.join(repo_abspath, "notebooks/tmp/psds_H1_30days.hdf"),
l1_psds_hdf=os.path.join(repo_abspath, "notebooks/tmp/psds_L1_30days.hdf"),
p_recolour=0.3829,
debug_me=False,
debug_dir=os.path.join(debug_dir, 'Recolour')),
]),
train=Unify({
'stage1':[
Whiten(trunc_method='hann', remove_corrupted=True, estimated=False),
],
'stage2':[
Normalise(ignore_factors=True),
MultirateSampling(),
],
}),
test=Unify({
'stage1':[
Whiten(trunc_method='hann', remove_corrupted=True, estimated=False),
],
'stage2':[
Normalise(ignore_factors=True),
MultirateSampling(),
],
}),
target=None
)
""" Optional things to do during training """
# Testing on a small 64000s dataset at the end of each epoch
epoch_testing = False
epoch_testing_dir = "/local/scratch/igr/nnarenraju/testing_64000_D4_seeded"
epoch_far_scaling_factor = 64000.0
""" Testing Phase """
injection_file = 'injections.hdf'
evaluation_output = 'evaluation.hdf'
test_foreground_dataset = "foreground.hdf"
test_foreground_output = "testing_foutput.hdf"
test_background_dataset = "background.hdf"
test_background_output = "testing_boutput.hdf"
# Run device for testing phase
## Testing config
# Real step will be slightly different due to rounding errors
step_size = 0.1
# Based on prediction probabilities in best epoch
trigger_threshold = 0.0
# Time shift the signal by multiple of step_size and check pred probs
cluster_threshold = 0.0001
# Run device for testing phase
testing_device = 'cuda:1'
testing_dir = "/local/scratch/igr/nnarenraju/testing_month_D4_seeded"
far_scaling_factor = 2592000.0
# Debugging
debug = False
debug_size = 10000
verbose = True
# DONE (BEST 24/06/24)
class SageNetOTF_May24_Russet(SageNetOTF):
### Primary Deviations (Comparison to BOY) ###
# 1. 113 days of O3b data (**VARIATION**)
# 2. SNR halfnorm (**VARIATION**)
""" Data storage """
name = "SageNet50_halfnormSNR_May17_Russet"
export_dir = Path("/home/nnarenraju/Research/ORChiD/RUNS") / name
debug_dir = "./DEBUG"
git_revparse = subprocess.run(["git", "rev-parse", "--show-toplevel"], capture_output = True, text = True)
repo_abspath = os.path.join(git_revparse.stdout.strip('\n'), 'sage')
""" Dataset """
dataset = MinimalOTF
dataset_params = dict()
# weights_path = "/home/nnarenraju/Research/ORChiD/RUNS/SageNet50_halfnormSNR_May17_Russet/checkpoint_epoch_39.pt"
""" Generation """
# Augmentation using GWSPY glitches happens only during training (not for validation)
generation = dict(
signal = UnifySignalGen([
FastGenerateWaveform(rwrap = 3.0,
beta_taper = 8,
pad_duration_estimate = 1.1,
min_mass = 5.0,
debug_me = False
),
]),
noise = UnifyNoiseGen({
'training': RandomNoiseSlice(
real_noise_path="/local/scratch/igr/nnarenraju/O3a_real_noise/O3a_real_noise.hdf",
segment_llimit=133, segment_ulimit=-1, debug_me=False
),
'validation': RandomNoiseSlice(
real_noise_path="/local/scratch/igr/nnarenraju/O3a_real_noise/O3a_real_noise.hdf",
segment_llimit=0, segment_ulimit=132, debug_me=False
),
},
MultipleFileRandomNoiseSlice(noise_dirs=dict(
H1="/local/scratch/igr/nnarenraju/O3b_real_noise/H1",
L1="/local/scratch/igr/nnarenraju/O3b_real_noise/L1",
),
debug_me=False,
debug_dir=""
),
paux = 0.689, # 113/164 days for extra O3b noise
debug_me=False,
debug_dir=os.path.join(debug_dir, 'NoiseGen')
)
)
""" Transforms """
transforms = dict(
signal=UnifySignal([
AugmentOptimalNetworkSNR(rescale=True, use_halfnorm=True, snr_lower_limit=5.0, snr_upper_limit=15.0),
]),
noise=UnifyNoise([
Recolour(use_precomputed=True,
h1_psds_hdf=os.path.join(repo_abspath, "notebooks/tmp/psds_H1_30days.hdf"),
l1_psds_hdf=os.path.join(repo_abspath, "notebooks/tmp/psds_L1_30days.hdf"),
p_recolour=0.3829,
debug_me=False,
debug_dir=os.path.join(debug_dir, 'Recolour')),
]),
train=Unify({
'stage1':[
Whiten(trunc_method='hann', remove_corrupted=True, estimated=False),
],
'stage2':[
Normalise(ignore_factors=True),
MultirateSampling(),
],
}),
test=Unify({
'stage1':[
Whiten(trunc_method='hann', remove_corrupted=True, estimated=False),
],
'stage2':[
Normalise(ignore_factors=True),
MultirateSampling(),
],
}),
target=None
)
""" Architecture """
model = Rigatoni_MS_ResNetCBAM_legacy
model_params = dict(
# Resnet50
filter_size = 32,
kernel_size = 64,
resnet_size = 50,
store_device = 'cuda:0',
)
""" Storage Devices """
store_device = 'cuda:0'
train_device = 'cuda:0'
# Run device for testing phase
testing_device = 'cuda:0'
testing_dir = "/home/nnarenraju/Research/ORChiD/test_data_d4"
test_foreground_output = "testing_foutput_BEST_June.hdf"
test_background_output = "testing_boutput_BEST_June.hdf"
# DONE (Unbiased and bad noise rejection)
class SageNetOTF_metric_density_Desiree(SageNetOTF):
### Primary Deviations (Comparison to BOY latest) ###
# 1. 113 days of O3b data (not variation)
# 2. SNR halfnorm (not variation)
# 3. Template placement density - fixed (**VARIATION**)
""" Data storage """
name = "SageNet50_metric_density_Jun26"
export_dir = Path("/home/nnarenraju/Research/ORChiD/RUNS") / name
debug_dir = "./DEBUG"
git_revparse = subprocess.run(["git", "rev-parse", "--show-toplevel"], capture_output = True, text = True)
repo_abspath = os.path.join(git_revparse.stdout.strip('\n'), 'sage')
""" Dataset """
dataset = MinimalOTF
dataset_params = dict()
""" Dataloader params """
num_workers = 16
pin_memory = True
prefetch_factor = 8
persistent_workers = True
""" Generation """
# Augmentation using GWSPY glitches happens only during training (not for validation)
generation = dict(
signal = UnifySignalGen([
FastGenerateWaveform(rwrap = 3.0,
beta_taper = 8,
pad_duration_estimate = 1.1,
min_mass = 5.0,
debug_me = False
),
]),
noise = UnifyNoiseGen({
'training': RandomNoiseSlice(
real_noise_path="/local/scratch/igr/nnarenraju/O3a_real_noise/O3a_real_noise.hdf",
segment_llimit=133, segment_ulimit=-1, debug_me=False,
),
'validation': RandomNoiseSlice(
real_noise_path="/local/scratch/igr/nnarenraju/O3a_real_noise/O3a_real_noise.hdf",
segment_llimit=0, segment_ulimit=132, debug_me=False,
),
},
MultipleFileRandomNoiseSlice(noise_dirs=dict(
H1="/local/scratch/igr/nnarenraju/O3b_real_noise/H1",
L1="/local/scratch/igr/nnarenraju/O3b_real_noise/L1",
),
debug_me=False,
debug_dir=""
),
paux = 0.689, # 113/164 days for extra O3b noise
debug_me=False,
debug_dir=os.path.join(debug_dir, 'NoiseGen')
)
)
""" Transforms """
transforms = dict(
signal=UnifySignal([
AugmentOptimalNetworkSNR(rescale=True, use_halfnorm=True, snr_lower_limit=5.0, snr_upper_limit=15.0),
]),
noise=UnifyNoise([
Recolour(use_precomputed=True,
h1_psds_hdf=os.path.join(repo_abspath, "notebooks/tmp/psds_H1_30days.hdf"),
l1_psds_hdf=os.path.join(repo_abspath, "notebooks/tmp/psds_L1_30days.hdf"),
p_recolour=0.3829,
debug_me=False,
debug_dir=os.path.join(debug_dir, 'Recolour')),
]),
train=Unify({
'stage1':[
Whiten(trunc_method='hann', remove_corrupted=True, estimated=False),
],
'stage2':[
Normalise(ignore_factors=True),
MultirateSampling(),
],
}),
test=Unify({
'stage1':[
Whiten(trunc_method='hann', remove_corrupted=True, estimated=False),
],
'stage2':[
Normalise(ignore_factors=True),
MultirateSampling(),
],
}),
target=None
)
""" Architecture """
model = Rigatoni_MS_ResNetCBAM
# Following options available for pe point estimate
# 'norm_tc', 'norm_dchirp', 'norm_mchirp',
# 'norm_dist', 'norm_q', 'norm_invq', 'norm_snr'
model_params = dict(
scales = [1, 2, 4, 0.5, 0.25],
blocks = [
[MultiScaleBlock, MultiScaleBlock],
[MultiScaleBlock, MultiScaleBlock],
[MultiScaleBlock, MultiScaleBlock]
],
out_channels = [[32, 32], [64, 64], [128, 128]],
base_kernel_sizes = [
[64, 64 // 2 + 1],
[64 // 2 + 1, 64 // 4 + 1],
[64 // 4 + 1, 64 // 4 + 1]
],
compression_factor = [8, 4, 0],
in_channels = 1,
resnet_size = 50,
parameter_estimation = ('norm_tc', 'norm_mchirp', ),
norm_layer = 'instancenorm',
store_device = 'cuda:0',
review = False
)
""" Storage Devices """
store_device = 'cuda:1'
train_device = 'cuda:1'
# Run device for testing phase
testing_device = 'cuda:1'
testing_dir = "/home/nnarenraju/Research/ORChiD/test_data_d4"
test_foreground_output = "testing_foutput_metric_latest.hdf"
test_background_output = "testing_boutput_metric_latest.hdf"
# Anneal from U(m1, m2) to template placement metric
class Kennebec_Annealed(SageNetOTF):
# Hopefully we can keep both noise rejection capabilities and unbiased representation
""" Data storage """
name = "Kennebec_Annealed_training_Jul25"
export_dir = Path("/home/nnarenraju/Research/ORChiD/RUNS") / name
debug_dir = "./DEBUG"
git_revparse = subprocess.run(["git", "rev-parse", "--show-toplevel"], capture_output = True, text = True)
repo_abspath = os.path.join(git_revparse.stdout.strip('\n'), 'sage')
""" Dataset """
dataset = MinimalOTF
dataset_params = dict()
""" Dataloader params """
num_workers = 16
pin_memory = True
prefetch_factor = 8
persistent_workers = True
# Weights for testing
weights_path = 'CHECKPOINTS/checkpoint_epoch_39.pt'
""" Generation """
# Augmentation using GWSPY glitches happens only during training (not for validation)
generation = dict(
signal = UnifySignalGen([
FastGenerateWaveform(rwrap = 3.0,
beta_taper = 8,
pad_duration_estimate = 1.1,
min_mass = 5.0,
debug_me = False
),
]),
noise = UnifyNoiseGen({
'training': RandomNoiseSlice(
real_noise_path="/local/scratch/igr/nnarenraju/O3a_real_noise/O3a_real_noise.hdf",
segment_llimit=133, segment_ulimit=-1, debug_me=False,
),
'validation': RandomNoiseSlice(
real_noise_path="/local/scratch/igr/nnarenraju/O3a_real_noise/O3a_real_noise.hdf",
segment_llimit=0, segment_ulimit=132, debug_me=False,
),
},
MultipleFileRandomNoiseSlice(noise_dirs=dict(
H1="/local/scratch/igr/nnarenraju/O3b_real_noise/H1",
L1="/local/scratch/igr/nnarenraju/O3b_real_noise/L1",
),
debug_me=False,
debug_dir=""
),
paux = 0.689, # 113/164 days for extra O3b noise
debug_me=False,
debug_dir=os.path.join(debug_dir, 'NoiseGen')
)
)
""" Transforms """
transforms = dict(
signal=UnifySignal([
AugmentOptimalNetworkSNR(rescale=True, use_halfnorm=True, snr_lower_limit=5.0, snr_upper_limit=15.0),
]),
noise=UnifyNoise([
Recolour(use_precomputed=True,
h1_psds_hdf=os.path.join(repo_abspath, "notebooks/tmp/psds_H1_30days.hdf"),
l1_psds_hdf=os.path.join(repo_abspath, "notebooks/tmp/psds_L1_30days.hdf"),
p_recolour=0.3829,
debug_me=False,
debug_dir=os.path.join(debug_dir, 'Recolour')),
]),
train=Unify({
'stage1':[
Whiten(trunc_method='hann', remove_corrupted=True, estimated=False),
],
'stage2':[
Normalise(ignore_factors=True),
MultirateSampling(),
],
}),
test=Unify({
'stage1':[
Whiten(trunc_method='hann', remove_corrupted=True, estimated=False),
],
'stage2':[
Normalise(ignore_factors=True),
MultirateSampling(),
],
}),
target=None
)
""" Architecture """
model = Rigatoni_MS_ResNetCBAM
# Following options available for pe point estimate
# 'norm_tc', 'norm_dchirp', 'norm_mchirp',
# 'norm_dist', 'norm_q', 'norm_invq', 'norm_snr'
model_params = dict(
scales = [1, 2, 4, 0.5, 0.25],
blocks = [
[MultiScaleBlock, MultiScaleBlock],
[MultiScaleBlock, MultiScaleBlock],
[MultiScaleBlock, MultiScaleBlock]
],
out_channels = [[32, 32], [64, 64], [128, 128]],
base_kernel_sizes = [
[64, 64 // 2 + 1],
[64 // 2 + 1, 64 // 4 + 1],
[64 // 4 + 1, 64 // 4 + 1]
],
compression_factor = [8, 4, 0],
in_channels = 1,
resnet_size = 50,
parameter_estimation = ('norm_tc', 'norm_mchirp', ),
norm_layer = 'instancenorm',
store_device = 'cuda:0',
review = False
)
""" Storage Devices """
store_device = 'cuda:0'
train_device = 'cuda:0'
# Run device for testing phase
testing_device = 'cuda:0'
testing_dir = "/home/nnarenraju/Research/ORChiD/test_data_d4"
test_foreground_output = "testing_foutput_annealed_training.hdf"
test_background_output = "testing_boutput_annealed_training.hdf"
class Norland_D3_template_density(SageNetOTF):
# Running D3 on template placement metric
# Due to the abscence of blip glitches sensitivitiy should not suffer
# PSD distribution should match exactly between train and test
""" Data storage """
name = "Norland_D3_template_placement_metric_Jul26"
export_dir = Path("/home/nnarenraju/Research/ORChiD/RUNS") / name
debug_dir = "./DEBUG"
git_revparse = subprocess.run(["git", "rev-parse", "--show-toplevel"], capture_output = True, text = True)
repo_abspath = os.path.join(git_revparse.stdout.strip('\n'), 'sage')
""" Dataset """
dataset = MinimalOTF
dataset_params = dict()
""" Dataloader params """
num_workers = 16
pin_memory = True
prefetch_factor = 8
persistent_workers = True
""" Generation """
# Augmentation using GWSPY glitches happens only during training (not for validation)
generation = dict(
signal = UnifySignalGen([
FastGenerateWaveform(rwrap = 3.0,
beta_taper = 8,
pad_duration_estimate = 1.1,
min_mass = 5.0,
debug_me = False
),
]),
noise = UnifyNoiseGen({
'training': ColouredNoiseGenerator(psds_dir=os.path.join(repo_abspath, "data/psds")),
'validation': ColouredNoiseGenerator(psds_dir=os.path.join(repo_abspath, "data/psds")),
},
)
)
""" Transforms """
transforms = dict(
signal=UnifySignal([
AugmentOptimalNetworkSNR(rescale=True, use_halfnorm=True, snr_lower_limit=5.0, snr_upper_limit=15.0),
]),
noise=None,
train=Unify({
'stage1':[
Whiten(trunc_method='hann', remove_corrupted=True, estimated=False),
],
'stage2':[
Normalise(ignore_factors=True),
MultirateSampling(),
],
}),
test=Unify({
'stage1':[
Whiten(trunc_method='hann', remove_corrupted=True, estimated=False),
],
'stage2':[
Normalise(ignore_factors=True),
MultirateSampling(),
],
}),
target=None
)
""" Architecture """
model = Rigatoni_MS_ResNetCBAM
# Following options available for pe point estimate
# 'norm_tc', 'norm_dchirp', 'norm_mchirp',
# 'norm_dist', 'norm_q', 'norm_invq', 'norm_snr'
model_params = dict(
scales = [1, 2, 4, 0.5, 0.25],
blocks = [
[MultiScaleBlock, MultiScaleBlock],
[MultiScaleBlock, MultiScaleBlock],
[MultiScaleBlock, MultiScaleBlock]
],
out_channels = [[32, 32], [64, 64], [128, 128]],
base_kernel_sizes = [
[64, 64 // 2 + 1],
[64 // 2 + 1, 64 // 4 + 1],
[64 // 4 + 1, 64 // 4 + 1]
],
compression_factor = [8, 4, 0],
in_channels = 1,
resnet_size = 50,
parameter_estimation = ('norm_tc', 'norm_mchirp', ),
norm_layer = 'instancenorm',
store_device = 'cuda:2',
review = False
)
""" Storage Devices """
store_device = 'cuda:2'
train_device = 'cuda:2'
# Run device for testing phase
testing_device = 'cuda:2'
testing_dir = "/home/nnarenraju/Research/ORChiD/test_data_d3"
test_foreground_output = "testing_foutput_D3_SageNet.hdf"
test_background_output = "testing_boutput_D3_SageNet.hdf"
class Russet_TrainingRecolour(SageNetOTF):
### Primary Deviations (Comparison to BOY) ###
# 1. 113 days of O3b data (**VARIATION**)
# 2. SNR halfnorm (**VARIATION**)
# 3. Recoloured using training data (51 days)
""" Data storage """
name = "Russet_TrainingRecolour_Aug09"
export_dir = Path("/home/nnarenraju/Research/ORChiD/RUNS") / name
debug_dir = "./DEBUG"
git_revparse = subprocess.run(["git", "rev-parse", "--show-toplevel"], capture_output = True, text = True)
repo_abspath = os.path.join(git_revparse.stdout.strip('\n'), 'sage')
""" Dataset """
dataset = MinimalOTF
dataset_params = dict()
""" Generation """
# Augmentation using GWSPY glitches happens only during training (not for validation)
generation = dict(
signal = UnifySignalGen([
FastGenerateWaveform(rwrap = 3.0,
beta_taper = 8,
pad_duration_estimate = 1.1,
min_mass = 5.0,
debug_me = False
),
]),
noise = UnifyNoiseGen({
'training': RandomNoiseSlice(
real_noise_path="/local/scratch/igr/nnarenraju/O3a_real_noise/O3a_real_noise.hdf",
segment_llimit=133, segment_ulimit=-1, debug_me=False,
),
'validation': RandomNoiseSlice(
real_noise_path="/local/scratch/igr/nnarenraju/O3a_real_noise/O3a_real_noise.hdf",
segment_llimit=0, segment_ulimit=132, debug_me=False,
),
},
MultipleFileRandomNoiseSlice(noise_dirs=dict(
H1="/local/scratch/igr/nnarenraju/O3b_real_noise/H1",
L1="/local/scratch/igr/nnarenraju/O3b_real_noise/L1",
),
debug_me=False,
debug_dir=""
),
paux = 0.689, # 113/164 days for extra O3b noise
debug_me=False,
debug_dir=os.path.join(debug_dir, 'NoiseGen')
)
)
""" Transforms """
transforms = dict(
signal=UnifySignal([
AugmentOptimalNetworkSNR(rescale=True, use_halfnorm=True, snr_lower_limit=5.0, snr_upper_limit=15.0),
]),
noise=UnifyNoise([
Recolour(use_precomputed=True,
h1_psds_hdf=os.path.join(repo_abspath, "notebooks/tmp/psds_H1_latter51days_20s.hdf"),
l1_psds_hdf=os.path.join(repo_abspath, "notebooks/tmp/psds_L1_latter51days_20s.hdf"),
p_recolour=0.3829,
debug_me=False,
debug_dir=os.path.join(debug_dir, 'Recolour')),
]),
train=Unify({
'stage1':[
Whiten(trunc_method='hann', remove_corrupted=True, estimated=False),
],
'stage2':[
Normalise(ignore_factors=True),
MultirateSampling(),
],
}),
test=Unify({
'stage1':[
Whiten(trunc_method='hann', remove_corrupted=True, estimated=False),
],
'stage2':[
Normalise(ignore_factors=True),
MultirateSampling(),
],
}),
target=None
)
""" Architecture """
model = Rigatoni_MS_ResNetCBAM_legacy
model_params = dict(
# Resnet50
filter_size = 32,
kernel_size = 64,
resnet_size = 50,
store_device = 'cuda:2',
parameter_estimation = ('norm_tc', 'norm_mchirp', )
)
""" Storage Devices """
store_device = 'cuda:2'
train_device = 'cuda:2'
# Run device for testing phase
testing_device = 'cuda:2'
testing_dir = "/home/nnarenraju/Research/ORChiD/test_data_d4"
test_foreground_output = "testing_foutput_training_recolour_Aug09.hdf"
test_background_output = "testing_boutput_training_recolour_Aug09.hdf"
# ABLATION - fixed dataset (RUNNNG)
class Vitelotte_FixedDataset(SageNetOTF):
### Primary Deviations (Comparison to BOY) ###
# 1. 113 days of O3b data (**VARIATION**)
# 2. SNR halfnorm (**VARIATION**)
# 3. Fixed dataset
## What is a fixed dataset?
# 1. Sample seed does not change between epochs (DONE)
# 2. Augmentation for signals is the same between epochs (DONE)
# 3. No augmentation for noise (DONE)
""" Data storage """
name = "Vitelotte_FixedDataset_Aug31_smaller"
export_dir = Path("/home/nnarenraju/Research/ORChiD/RUNS") / name
debug_dir = "./DEBUG"
git_revparse = subprocess.run(["git", "rev-parse", "--show-toplevel"], capture_output = True, text = True)
repo_abspath = os.path.join(git_revparse.stdout.strip('\n'), 'sage')
""" Dataset """
dataset = MinimalOTF
dataset_params = dict()
batchshuffle_noise = True
""" Generation """
# Augmentation using GWSPY glitches happens only during training (not for validation)
generation = dict(
signal = None,
noise = None,
)
""" Transforms """
transforms = dict(
signal=UnifySignal([
AugmentPolSky(),
AugmentOptimalNetworkSNR(rescale=True, use_uniform=True, snr_lower_limit=5.0, snr_upper_limit=15.0),
]),
noise=None,
train=Unify({
'stage1':[
Whiten(trunc_method='hann', remove_corrupted=True, estimated=False),
],
'stage2':[
Normalise(ignore_factors=True),
MultirateSampling(),
],
}),
test=Unify({
'stage1':[
Whiten(trunc_method='hann', remove_corrupted=True, estimated=False),
],