(evaluator, pianorolls)
return rval
Evaluate a sequence of pianorolls.

  The returned dictionary contains two kinds of evaluation results: the "unit"
  losses and the "example" losses. The unit loss measures the negative
  log-likelihood of each unit (e.g. note or frame). The example loss is the
  average of the unit loss across the example. Additionally, the dictionary
  contains various aggregates such as the mean and standard error of the mean
  of both losses, as well as min/max and quartile bounds.

  Args:
    evaluator: an instance of BaseEvaluator
    pianorolls: sequence of pianorolls to evaluate

  Returns:
    A dictionary with evaluation results.
Evaluate a sequence of pianorolls.
Evaluate a sequence of pianorolls .
def evaluate(evaluator, pianorolls):
  """Evaluate a sequence of pianorolls.

  The returned dictionary contains two kinds of evaluation results: the "unit"
  losses and the "example" losses. The unit loss measures the negative
  log-likelihood of each unit (e.g. note or frame). The example loss is the
  average of the unit loss across the example. Additionally, the dictionary
  contains various aggregates such as the mean and standard error of the mean
  of both losses, as well as min/max and quartile bounds.

  Args:
    evaluator: an instance of BaseEvaluator
    pianorolls: sequence of pianorolls to evaluate

  Returns:
    A dictionary with evaluation results.
  """
  example_losses = []
  unit_losses = []

  for pi, pianoroll in enumerate(pianorolls):
    tf.logging.info("evaluating piece %d", pi)
    start_time = time.time()

    unit_loss = -evaluator(pianoroll)
    example_loss = np.mean(unit_loss)

    example_losses.append(example_loss)
    unit_losses.append(unit_loss)

    duration = (time.time() - start_time) / 60.
    _report(unit_loss, prefix="%i %5.2fmin " % (pi, duration))

    if np.isinf(example_loss):
      break

  _report(example_losses, prefix="FINAL example-level ")
  _report(unit_losses, prefix="FINAL unit-level ")

  rval = dict(example_losses=example_losses, unit_losses=unit_losses)
  rval.update(("example_%s" % k, v) for k, v in _stats(example_losses).items())
  rval.update(
      ("unit_%s" % k, v) for k, v in _stats(_flatcat(unit_losses)).items())
  return rval
def evaluate ( evaluator , pianorolls ) : example_losses = [ ] unit_losses = [ ] for pi , pianoroll in enumerate ( pianorolls ) : tf . logging . info ( "evaluating piece %d" , pi ) start_time = time . time ( ) unit_loss = - evaluator ( pianoroll ) example_loss = np . mean ( unit_loss ) example_losses . append ( example_loss ) unit_losses . append ( unit_loss ) duration = ( time . time ( ) - start_time ) / 60. _report ( unit_loss , prefix = "%i %5.2fmin " % ( pi , duration ) ) if np . isinf ( example_loss ) : break _report ( example_losses , prefix = "FINAL example-level " ) _report ( unit_losses , prefix = "FINAL unit-level " ) rval = dict ( example_losses = example_losses , unit_losses = unit_losses ) rval . update ( ( "example_%s" % k , v ) for k , v in _stats ( example_losses ) . items ( ) ) rval . update ( ( "unit_%s" % k , v ) for k , v in _stats ( _flatcat ( unit_losses ) ) . items ( ) ) return rval