def computeAccuracyEnding(predictions, truths, iterations,
                    resets=None, randoms=None, num=None,
                    sequenceCounter=None):
  """
  Compute accuracy on the sequence ending
  """
  accuracy = []
  numIteration = []
  numSequences = []

  for i in xrange(len(predictions) - 1):
    if num is not None and i > num:
      continue

    if truths[i] is None:
      continue

    # identify the end of sequence
    if resets is not None or randoms is not None:
      if not (resets[i+1] or randoms[i+1]):
        continue

    correct = truths[i] is None or truths[i] in predictions[i]
    accuracy.append(correct)
    numSequences.append(sequenceCounter[i])
    numIteration.append(iterations[i])

  return (accuracy, numIteration, numSequences)
def computeAccuracyEnding ( predictions , truths , iterations , resets = None , randoms = None , num = None , sequenceCounter = None ) : accuracy = [ ] numIteration = [ ] numSequences = [ ] for i in xrange ( len ( predictions ) - 1 ) : if num is not None and i > num : continue if truths [ i ] is None : continue if resets is not None or randoms is not None : if not ( resets [ i + 1 ] or randoms [ i + 1 ] ) : continue correct = truths [ i ] is None or truths [ i ] in predictions [ i ] accuracy . append ( correct ) numSequences . append ( sequenceCounter [ i ] ) numIteration . append ( iterations [ i ] ) return ( accuracy , numIteration , numSequences )
Compute accuracy on the sequence ending