forked from dipamgoswami/FeCAM
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpca.py
More file actions
33 lines (27 loc) · 1.26 KB
/
pca.py
File metadata and controls
33 lines (27 loc) · 1.26 KB
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
import subprocess
import json
# FeCAM settings: full cov matrix with shrink per class
# pca_vecnorm - embedding normalisation before PCA
# pca_components - num of components for PCA
# pca_dist - metric for classification
runs = [
{ 'pca_dist': 'maha', 'pca_vecnorm': True, 'pca_components': 30 },
{ 'pca_dist': 'maha', 'pca_vecnorm': False, 'pca_components': 30 },
{ 'pca_dist': 'norm1', 'pca_vecnorm': True, 'pca_components': 30 },
{ 'pca_dist': 'norm1', 'pca_vecnorm': False, 'pca_components': 30 },
{ 'pca_dist': 'norm2', 'pca_vecnorm': True, 'pca_components': 30 },
{ 'pca_dist': 'norm2', 'pca_vecnorm': False, 'pca_components': 30 },
{ 'pca_dist': 'ocsvm', 'pca_vecnorm': True, 'pca_components': 30 },
{ 'pca_dist': 'ocsvm', 'pca_vecnorm': False, 'pca_components': 30 }
]
config_path = './exps/FeCAM_cifar100.json'
for run_params in runs:
with open(config_path, 'r') as file:
data = json.load(file)
for param_name, param_value in run_params.items():
data[param_name] = param_value
with open(config_path, 'w') as file:
json.dump(data, file, indent=4)
print(f'Running FeCAM with params {run_params}')
process = subprocess.Popen(['python', 'main.py', '--config', config_path])
process.wait()