MCPcopy Create free account
hub / github.com/Audio-AGI/AudioSep / StatisticsContainer

Class StatisticsContainer

utils.py:203–225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

201
202
203class StatisticsContainer(object):
204 def __init__(self, statistics_path):
205 self.statistics_path = statistics_path
206
207 self.backup_statistics_path = "{}_{}.pkl".format(
208 os.path.splitext(self.statistics_path)[0],
209 datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S"),
210 )
211
212 self.statistics_dict = {"balanced_train": [], "test": []}
213
214 def append(self, steps, statistics, split, flush=True):
215 statistics["steps"] = steps
216 self.statistics_dict[split].append(statistics)
217
218 if flush:
219 self.flush()
220
221 def flush(self):
222 pickle.dump(self.statistics_dict, open(self.statistics_path, "wb"))
223 pickle.dump(self.statistics_dict, open(self.backup_statistics_path, "wb"))
224 logging.info(" Dump statistics to {}".format(self.statistics_path))
225 logging.info(" Dump statistics to {}".format(self.backup_statistics_path))
226
227
228def get_mean_sdr_from_dict(sdris_dict):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected