-
Notifications
You must be signed in to change notification settings - Fork 11
/
Logger.py
44 lines (36 loc) · 1.57 KB
/
Logger.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
import datetime
import os
import configure
class Logger:
def __init__(self, log_path):
self.__log_filename = log_path
def metatrain_log(self):
self.log('==== Meta-training ====')
self.log('hyperparameters:', configure.maml)
self.log('do_bandpass:', configure.do_bandpass)
self.log('pretrain_dataset:', configure.pretrain_dataset)
def pretrain_log(self):
self.log('==== Pre-training ====')
self.log('hyperparameters:', configure.pretrain)
self.log('do_bandpass:', configure.do_bandpass)
self.log('pretrain_dataset:', configure.pretrain_dataset)
def finetune_log(self):
self.log('==== Fine-tuning ====')
self.log('hyperparameters:', configure.finetune)
self.log('do_bandpass:', configure.do_bandpass)
self.log('finetune_dataset:', configure.finetune_dataset)
self.log('pretrain_path:', configure.pretrain_path)
def test_finetune_log(self):
self.log('==== Test from Fine-tuning ====')
self.log('hyperparameters:', configure.finetune)
self.log('do_bandpass:', configure.do_bandpass)
self.log('finetune_dataset:', configure.finetune_dataset)
self.log('test from weight:', configure.test_from_path)
def log(self, *msg):
f = open(self.__log_filename, "a")
m = ' '.join(map(str,msg))
f.write(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') + ' :: ' + m + '\n')
f.close()
print(m)
def get_path(self):
return self.__log_filename