-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMAINCONFIG.py
executable file
·72 lines (52 loc) · 2.13 KB
/
MAINCONFIG.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
"""
This file contains all the hyperparameters
and more global constants for convenient execution of experiments.
It makes up the main configuration of the whole system.
"""
import time
import numpy as np
#Hyperparameters
GL_HOP = 192 #hop size (window size = 6*hop)
GL_SR = 22050 #sampling rate
GL_MIN_LEVEL_DB = -100 #reference values to normalize data
GL_REF_LEVEL_DB = 20
GL_SHAPE = 192 #length of time axis of split specrograms to feed to generator
GL_VECLEN = 128 #length of vector generated by siamese vector
#GL_BS = 16 #batch size
GL_BS = 13 #batch siz
# alpha -> id factor: g_trgt - trgt
GL_ALPHA = 1.
# beta -> travel factor: cos_sim and l2_squared of
GL_BETA = 5.
# epsilon -> frequency priorisation
GL_EPSILON = 8.
# zeta -> parallel loss
GL_ZETA = 0.
# gamma -> margin loss factor
GL_GAMMA = 5.
# delta -> distance of vectors in margin (siamese) loss
GL_DELTA = 0.7 #constant for siamese loss
GL_EPOCHS = 200
GL_EXP_NR = 11
GL_VERSION = '3.2'
GL_SAVE = f'../Ergebnisse/Versuch{GL_EXP_NR:02d}_LossPaper_{GL_VERSION}_{GL_ALPHA}_{GL_BETA}_{GL_GAMMA}_{GL_DELTA}_{GL_EPSILON}_{GL_ZETA}'
GL_LOAD = '../Ergebnisse/Versuch01_1_0_ohneValidierung/2023-07-27-10-31_294_0.4249099_0.6567595'
""" get a string with all important constants """
def getconstants():
msgstr = f"hop size: {GL_HOP} \n"
msgstr += f"shape: {GL_SHAPE} \n"
msgstr += f"Siamese out len: {GL_VECLEN} \n"
msgstr += f"batch size: {GL_BS} \n"
msgstr += f"Sample rate: {GL_SR} \n"
msgstr += f"net params: alpha: {GL_ALPHA}, beta: {GL_BETA}, gamma: {GL_GAMMA}, delta: {GL_DELTA} \n"
msgstr += f"Save to: {GL_SAVE} \n"
return msgstr
""" log to stdout unless function gets locally overwritten/not imported """
def log(msg: str, end='\n'):
print(msg, end=end)
""" functions to convert seconds to nr of values (bins) in spectrogram (spectrogram time unit) """
def bins_to_secs(bins, sr=22050, hop=192):
return bins * hop // sr
def secs_to_bins(secs, sr=22050, hop=192):
# secs + 1 bc offset of -1 coming from somewhere
return int(np.ceil((secs + 1) * sr / hop))