-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathunmixing.py
52 lines (38 loc) · 1.05 KB
/
unmixing.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
"""
Toolbox main file managed by mlxpy to handle experiments configurations
"""
import logging
import logging.config
import mlxp
def set_seeds(seed):
import torch
import numpy as np
torch.manual_seed(seed)
np.random.seed(seed)
@mlxp.launch(
config_path="./config",
seeding_function=set_seeds,
)
def unmixing(ctx: mlxp.Context) -> None:
cfg = ctx.config
mode = cfg.mode
logging.config.dictConfig(cfg)
log = logging.getLogger(__name__)
log.debug(f"Config:\n{cfg}")
log.info(f"Unmixing mode: {mode.upper()}")
if mode == "blind":
from src.blind import main as _main
elif mode == "supervised":
from src.supervised import main as _main
elif mode == "semi":
from src.semisupervised import main as _main
elif mode == "pruning":
from src.pruning import main as _main
else:
raise ValueError(f"Mode {mode} is invalid")
try:
_main(ctx)
except Exception:
log.error("Exception occured", exc_info=True)
if __name__ == "__main__":
unmixing()