Skip to content

Commit faf0fe6

Browse files
authored
Add files via upload
1 parent 5fa96cf commit faf0fe6

19 files changed

+1091
-0
lines changed

model/EarlyStopping_made.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class EarlyStopping_made():
2+
def __init__(self, patience=0, verbose=0):
3+
self._step = 0
4+
self._loss = float('inf')
5+
self.patience = patience
6+
self.verbose = verbose
7+
8+
def validate(self, loss):
9+
if self._loss < loss:
10+
self._step += 1
11+
if self._step > self.patience:
12+
return True
13+
else:
14+
self._step = 0
15+
self._loss = loss
16+
17+
return False
759 Bytes
Binary file not shown.
758 Bytes
Binary file not shown.
1.05 KB
Binary file not shown.
1.03 KB
Binary file not shown.
9.67 KB
Binary file not shown.
9.38 KB
Binary file not shown.
6.22 KB
Binary file not shown.
594 Bytes
Binary file not shown.
584 Bytes
Binary file not shown.
2.43 KB
Binary file not shown.
1.98 KB
Binary file not shown.

model/infolog.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import atexit
2+
from datetime import datetime
3+
from urllib.request import Request, urlopen
4+
5+
_format = '%Y-%m-%d %H:%M:%S.%f'
6+
_file = None
7+
8+
9+
def init(filename):
10+
global _file
11+
_close_logfile()
12+
_file = open(filename, 'a')
13+
_file.write('\n-----------------------------------------------------------------\n')
14+
_file.write('Starting..........\n')
15+
_file.write('-----------------------------------------------------------------\n')
16+
17+
18+
def log(msg, slack=False):
19+
print("[%s] %s" % (datetime.now().strftime(_format)[:-3], msg))
20+
if _file is not None:
21+
_file.write('[%s] %s\n' % (datetime.now().strftime(_format)[:-3], msg))
22+
23+
def _close_logfile():
24+
global _file
25+
if _file is not None:
26+
_file.close()
27+
_file = None
28+
29+
atexit.register(_close_logfile)
30+

0 commit comments

Comments
 (0)