-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtrain_stats.py
More file actions
29 lines (21 loc) · 754 Bytes
/
Copy pathtrain_stats.py
File metadata and controls
29 lines (21 loc) · 754 Bytes
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
from genericpath import exists
import pickle
from constants import LAFAN1_DIRECTORY, OUTPUT_DIRECTORY
from util.extract import get_train_stats
def save_stats():
x_mean, x_std, _, _ = get_train_stats(LAFAN1_DIRECTORY, ['subject1', 'subject2', 'subject3', 'subject4'])
with open(f'{OUTPUT_DIRECTORY}/stats.pkl', 'wb') as f:
pickle.dump(
{'x_mean': x_mean, 'x_std': x_std},
f,
protocol=pickle.HIGHEST_PROTOCOL
)
def load_stats():
p = f'{OUTPUT_DIRECTORY}/stats.pkl'
if not exists(p):
save_stats()
with open(f'{OUTPUT_DIRECTORY}/stats.pkl', 'rb') as f:
stats = pickle.load(f)
return stats['x_mean'], stats['x_std']
if __name__ == '__main__':
save_stats()