brainstorm/training/trainer.py
def _add_log(self, name, val, verbose=None, logs=None, indent=0):
        """Accumulate the logs (possibly a nested dictionary) recursively."""
        if val is None:
            return

        verbose = self.verbose if verbose is None else verbose
        logs = self.logs if logs is None else logs

        if isinstance(val, dict):
            if verbose:
                print(" " * indent + name)
            logs[name] = dict() if name not in logs else logs[name]

            for k, v in val.items():
                self._add_log(k, v, verbose, logs[name], indent + 2)
        else:
            if verbose:
                print(" " * indent + ("{0:%d}: {1}" % (40 - indent))
                      .format(name, val))
            logs[name] = [] if name not in logs else logs[name]
            logs[name].append(val)
Accumulate the logs (possibly a nested dictionary) recursively.
Accumulate the logs (possibly a nested dictionary) recursively.
Accumulate the logs ( possibly a nested dictionary ) recursively .
def _add_log(self, name, val, verbose=None, logs=None, indent=0):
        if val is None:
            return
        verbose = self.verbose if verbose is None else verbose
        logs = self.logs if logs is None else logs
        if isinstance(val, dict):
            if verbose:
                print(" " * indent + name)
            logs[name] = dict() if name not in logs else logs[name]
            for k, v in val.items():
                self._add_log(k, v, verbose, logs[name], indent + 2)
        else:
            if verbose:
                print(" " * indent + ("{0:%d}: {1}" % (40 - indent))
                      .format(name, val))
            logs[name] = [] if name not in logs else logs[name]
            logs[name].append(val)
def _add_log ( self , name , val , verbose = None , logs = None , indent = 0 ) : if val is None : return verbose = self . verbose if verbose is None else verbose logs = self . logs if logs is None else logs if isinstance ( val , dict ) : if verbose : print ( " " * indent + name ) logs [ name ] = dict ( ) if name not in logs else logs [ name ] for k , v in val . items ( ) : self . _add_log ( k , v , verbose , logs [ name ] , indent + 2 ) else : if verbose : print ( " " * indent + ( "{0:%d}: {1}" % ( 40 - indent ) ) . format ( name , val ) ) logs [ name ] = [ ] if name not in logs else logs [ name ] logs [ name ] . append ( val )
Accumulate the logs (possibly a nested dictionary) recursively.
Accumulate the logs ( possibly a nested dictionary ) recursively .
"""Accumulate the logs (possibly a nested dictionary) recursively."""
self
name
val
verbose
logs
indent