예제 #1
0
 def _evaluateSequence(self, f, seq, verbose=False):
     """Return the ponderated MSE over one sequence."""
     totalError = 0.
     ponderation = 0.
     for input, target in seq:
         res = f(input)
         e = 0.5 * sum((target - res).flatten() ** 2)
         totalError += e
         ponderation += len(target)
         if verbose:
             print     'out:    ', fListToString(list(res))
             print     'correct:', fListToString(target)
             print     'error: % .8f' % e
     return totalError, ponderation
예제 #2
0
 def _evaluateSequence(self, f, seq, verbose=False):
     """ return the importance-ponderated MSE over one sequence. """
     totalError = 0
     ponderation = 0.
     for input, target, importance in seq:
         res = f(input)
         e = 0.5 * dot(importance.flatten(), ((target - res).flatten() ** 2))
         totalError += e
         ponderation += sum(importance)
         if verbose:
             print     'out:       ', fListToString(list(res))
             print     'correct:   ', fListToString(target)
             print     'importance:', fListToString(importance)
             print     'error: % .8f' % e
     return totalError, ponderation