def Eval(train_dir, eval_dir, model_str, eval_data, decoder_file, num_steps, graph_def_file=None, eval_interval_secs=0, reader=None):
 decode = None
 if decoder_file:
  decode = decoder.Decoder(decoder_file)
 rates = ec.ErrorRates(label_error=None, word_recall_error=None, word_precision_error=None, sequence_error=None)
 with tf.Graph().as_default():
  model = InitNetwork(eval_data, model_str, 'eval', reader=reader)
  sw = tf.train.SummaryWriter(eval_dir)
  while True:
   sess = tf.Session('')
   if (graph_def_file is not None):
    if (not tf.gfile.Exists(graph_def_file)):
     with tf.gfile.FastGFile(graph_def_file, 'w') as f:
      f.write(sess.graph.as_graph_def(add_shapes=True).SerializeToString())
   ckpt = tf.train.get_checkpoint_state(train_dir)
   if (ckpt and ckpt.model_checkpoint_path):
    step = model.Restore(ckpt.model_checkpoint_path, sess)
    if decode:
     rates = decode.SoftmaxEval(sess, model, num_steps)
     _AddRateToSummary('Label error rate', rates.label_error, step, sw)
     _AddRateToSummary('Word recall error rate', rates.word_recall_error, step, sw)
     _AddRateToSummary('Word precision error rate', rates.word_precision_error, step, sw)
     _AddRateToSummary('Sequence error rate', rates.sequence_error, step, sw)
     sw.flush()
     print 'Error rates=', rates
    else:
     raise ValueError('Non-softmax decoder evaluation not implemented!')
   if eval_interval_secs:
    time.sleep(eval_interval_secs)
   else:
    break
 return rates

def Eval ( train_dir , eval_dir , model_str , eval_data , decoder_file , num_steps , graph_def_file = None , eval_interval_secs = 0 , reader = None ) : decode = None if decoder_file : decode = decoder . Decoder ( decoder_file ) rates = ec . ErrorRates ( label_error = None , word_recall_error = None , word_precision_error = None , sequence_error = None ) with tf . Graph ( ) . as_default ( ) : model = InitNetwork ( eval_data , model_str , 'eval' , reader = reader ) sw = tf . train . SummaryWriter ( eval_dir ) while True : sess = tf . Session ( '' ) if ( graph_def_file is not None ) : if ( not tf . gfile . Exists ( graph_def_file ) ) : with tf . gfile . FastGFile ( graph_def_file , 'w' ) as f : f . write ( sess . graph . as_graph_def ( add_shapes = True ) . SerializeToString ( ) ) ckpt = tf . train . get_checkpoint_state ( train_dir ) if ( ckpt and ckpt . model_checkpoint_path ) : step = model . Restore ( ckpt . model_checkpoint_path , sess ) if decode : rates = decode . SoftmaxEval ( sess , model , num_steps ) _AddRateToSummary ( 'Label error rate' , rates . label_error , step , sw ) _AddRateToSummary ( 'Word recall error rate' , rates . word_recall_error , step , sw ) _AddRateToSummary ( 'Word precision error rate' , rates . word_precision_error , step , sw ) _AddRateToSummary ( 'Sequence error rate' , rates . sequence_error , step , sw ) sw . flush ( ) print 'Error rates=' , rates else : raise ValueError ( 'Non-softmax decoder evaluation not implemented!' ) if eval_interval_secs : time . sleep ( eval_interval_secs ) else : break return rates
evaluates a network and checkpoints it to disk .