Esempio n. 1
0
 def evidence(self, model, useMaximumApproximation):
     evidences = sequitur_.EvidenceStore()
     evidences.setSequenceModel(model)
     if useMaximumApproximation:
         accumulator = sequitur_.ViterbiAccumulator()
     else:
         accumulator = sequitur_.Accumulator()
     accumulator.setTarget(evidences)
     logLik = 0.0
     for eg in self.graphs(model):
         logLik += accumulator.accumulate(eg, 1.0)
     misc.reportMemoryUsage()
     return evidences, logLik
Esempio n. 2
0
 def evidence(self, model, useMaximumApproximation):
     evidences = sequitur_.EvidenceStore()
     evidences.setSequenceModel(model)
     if useMaximumApproximation:
         accumulator = sequitur_.ViterbiAccumulator()
     else:
         accumulator = sequitur_.Accumulator()
     accumulator.setTarget(evidences)
     logLik = 0.0
     for eg in self.graphs(model):
         logLik += accumulator.accumulate(eg, 1.0)
     misc.reportMemoryUsage()
     return evidences, logLik
Esempio n. 3
0
 def run(self, context):
     lastCheckpoint = misc.cputime()
     shouldStop = False
     while not shouldStop:
         if context.iteration >= self.maxIterations:
             print >> context.log, 'maximum number of iterations reached.'
             break
         print >> context.log, 'iteration: %s' % context.iteration
         try:
             shouldStop = self.iterate(context)
         except:
             import traceback
             traceback.print_exc()
             print >> context.log, 'iteration failed.'
             break
         if ((self.checkpointInterval) and
             (misc.cputime() > lastCheckpoint + self.checkpointInterval)):
             self.checkpoint(context)
             lastCheckpoint = misc.cputime()
         context.iteration += 1
         misc.reportMemoryUsage()
         print >> context.log
         context.log.flush()
Esempio n. 4
0
 def run(self, context):
     lastCheckpoint = misc.cputime()
     shouldStop = False
     while not shouldStop:
         if context.iteration >= self.maxIterations:
             print >> context.log, 'maximum number of iterations reached.'
             break
         print >> context.log, 'iteration: %s' % context.iteration
         try:
             shouldStop = self.iterate(context)
         except Exception:
             import traceback
             traceback.print_exc()
             print >> context.log, 'iteration failed.'
             break
         if ((self.checkpointInterval) and
             (misc.cputime() > lastCheckpoint + self.checkpointInterval)):
             self.checkpoint(context)
             lastCheckpoint = misc.cputime()
         context.iteration += 1
         misc.reportMemoryUsage()
         print >> context.log
         context.log.flush()