@@ -29,7 +29,7 @@ def __init__(self) -> None:
29
29
self .history = []
30
30
self .reset ()
31
31
32
- def reset (self ):
32
+ def reset (self ) -> None :
33
33
"""
34
34
Reset the running average meter.
35
35
"""
@@ -38,7 +38,7 @@ def reset(self):
38
38
self .sum = 0
39
39
self .count = 0
40
40
41
- def update (self , val : float , n : int = 1 , epoch : int = 0 ):
41
+ def update (self , val : float , n : int = 1 , epoch : int = 0 ) -> None :
42
42
"""
43
43
Updates the average meter with a value `val`.
44
44
@@ -123,7 +123,7 @@ def __init__(
123
123
self .plot_file = plot_file
124
124
self .hard_reset (epoch = epoch )
125
125
126
- def reset (self ):
126
+ def reset (self ) -> None :
127
127
"""
128
128
Called before an epoch to clear current epoch buffers.
129
129
"""
@@ -138,7 +138,7 @@ def reset(self):
138
138
# Set a new timestamp.
139
139
self ._epoch_start = time .time ()
140
140
141
- def hard_reset (self , epoch : int = - 1 ):
141
+ def hard_reset (self , epoch : int = - 1 ) -> None :
142
142
"""
143
143
Erases all logged data.
144
144
"""
@@ -149,7 +149,7 @@ def hard_reset(self, epoch: int = -1):
149
149
self .stats = {}
150
150
self .reset ()
151
151
152
- def new_epoch (self ):
152
+ def new_epoch (self ) -> None :
153
153
"""
154
154
Initializes a new epoch.
155
155
"""
@@ -166,7 +166,7 @@ def _gather_value(self, val):
166
166
val = float (val .sum ())
167
167
return val
168
168
169
- def update (self , preds : dict , stat_set : str = "train" ):
169
+ def update (self , preds : dict , stat_set : str = "train" ) -> None :
170
170
"""
171
171
Update the internal logs with metrics of a training step.
172
172
@@ -211,7 +211,7 @@ def update(self, preds: dict, stat_set: str = "train"):
211
211
if val is not None :
212
212
self .stats [stat_set ][stat ].update (val , epoch = epoch , n = 1 )
213
213
214
- def print (self , max_it : Optional [int ] = None , stat_set : str = "train" ):
214
+ def print (self , max_it : Optional [int ] = None , stat_set : str = "train" ) -> None :
215
215
"""
216
216
Print the current values of all stored stats.
217
217
@@ -247,7 +247,7 @@ def plot_stats(
247
247
viz : Visdom = None ,
248
248
visdom_env : Optional [str ] = None ,
249
249
plot_file : Optional [str ] = None ,
250
- ):
250
+ ) -> None :
251
251
"""
252
252
Plot the line charts of the history of the stats.
253
253
0 commit comments