forked from ZongXR/Baidu_KDD_CUP_2022
-
Notifications
You must be signed in to change notification settings - Fork 0
/
callbacks.py
36 lines (29 loc) · 1.32 KB
/
callbacks.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
# -*-Encoding: utf-8 -*-
from tensorflow.keras.callbacks import Callback
class OneTurbCallback(Callback):
"""
完成或开始一个风机的回调\n
"""
def __init__(self, turb_id: int, train_begin: bool = False, train_end: bool = False, predict_begin: bool = False, predict_end: bool = False):
super().__init__()
self.turb_id = turb_id
self.train_begin = train_begin
self.train_end = train_end
self.predict_begin = predict_begin
self.predict_end = predict_end
def on_train_begin(self, logs=None):
if self.train_begin:
print(">>>>>>>>>>>>> turb %d training begin >>>>>>>>>>>>>>>>>" % self.turb_id)
return super().on_train_begin(logs)
def on_train_end(self, logs=None):
if self.train_end:
print(">>>>>>>>>>>>> turb %d training end >>>>>>>>>>>>>>>>>" % self.turb_id)
return super().on_train_end(logs)
def on_predict_begin(self, logs=None):
if self.predict_begin:
print(">>>>>>>>>>>>> turb %d predicting begin >>>>>>>>>>>>>>>>>" % self.turb_id)
return super().on_predict_begin(logs)
def on_predict_end(self, logs=None):
if self.predict_end:
print(">>>>>>>>>>>>> turb %d predicting end >>>>>>>>>>>>>>>>>" % self.turb_id)
return super().on_predict_end(logs)