File tree Expand file tree Collapse file tree 1 file changed +5
-0
lines changed
Expand file tree Collapse file tree 1 file changed +5
-0
lines changed Original file line number Diff line number Diff line change 22from DeepFried2 .utils import flatten
33
44import numpy as _np
5+ from warnings import warn as _warn
56
67
78class BatchNormalization (df .Module ):
@@ -84,6 +85,10 @@ def evaluate(self):
8485 self .Winf .set_value (self .W .get_value () / _np .sqrt (self .buf_var .get_value () + self .eps ))
8586 self .binf .set_value (self .b .get_value () - self .Winf .get_value () * self .buf_mean .get_value ())
8687
88+ # This check saved me from WTF'ing countless times!
89+ if self .buf_count .get_value () == 0 :
90+ _warn ("You're switching a BN-net to eval mode without having collected any statistics, that can't go well!" )
91+
8792 def __getstate__ (self ):
8893 regular = df .Module .__getstate__ (self )
8994 return [buf .get_value () for buf in (self .buf_mean , self .buf_var , self .buf_count )] + regular
You can’t perform that action at this time.
0 commit comments