-
Notifications
You must be signed in to change notification settings - Fork 30
/
engine.py
57 lines (38 loc) · 1.52 KB
/
engine.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
from abc import ABC
from abc import abstractmethod
class BaseEngine(ABC):
r"""Base class for all engines.
It defines the training and evaluation process.
"""
def __init__(self, config, **kwargs):
self.config = config
for key, value in kwargs.items():
self.__setattr__(key, value)
@abstractmethod
def train(self, n=None, **kwargs):
r"""Training process for one iteration.
.. note::
It is recommended to use :class:`Logger` to store loggings.
.. note::
All parameterized modules should be called `.train()` to specify training mode.
Args:
n (int, optional): n-th iteration for training.
**kwargs: keyword aguments used for logging.
Returns:
dict: a dictionary of training output
"""
pass
@abstractmethod
def eval(self, n=None, **kwargs):
r"""Evaluation process for one iteration.
.. note::
It is recommended to use :class:`Logger` to store loggings.
.. note::
All parameterized modules should be called `.eval()` to specify evaluation mode.
Args:
n (int, optional): n-th iteration for evaluation.
**kwargs: keyword aguments used for logging.
Returns:
dict: a dictionary of evluation output
"""
pass