tensor2tensor icon indicating copy to clipboard operation
tensor2tensor copied to clipboard

when run rawSession of EVAL,sess.run([loss,predictions,metric],feed) only metric not work

Open 2877992943 opened this issue 9 years ago • 2 comments

Following the train_util_test.py and try to run a rawsession of EVAL and get eval_metric_ops['metrics-med_abstract_problem/neg_log_perplexity'] after pass the input and target, but only the predictions and loss can be successfully run and the eval_metric_ops cannot with the following error reported

 FailedPreconditionError (see above for traceback): Attempting to use uninitialized value mean_3/count
 	 [[Node: mean_3/count/read = Identity[T=DT_FLOAT, _class=["loc:@mean_3/count"], _device="/job:localhost/replica:0/task:0/cpu:0"](mean_3/count)]]

when building the graph, mean_3/value and mean_3/update_ops is found but not mean_3/count and mean_3/total, just want to get perplexity ,can the perplexity be calculated in rawSession EVAL or it can only happened when training ?

below is the related code

mode = tf.estimator.ModeKeys.EVAL
self.estimator_spec = model_builder.model_fn(
self._model_name, features, mode, self._hparams, problem_names=[self._problem])
self.predictions_dict=self.estimator_spec.predictions
self.eval_metric_ops=self.estimator_spec.eval_metric_ops
self.loss=self.estimator_spec.loss

2877992943 avatar Nov 03 '17 09:11 2877992943

My guess is that you need to run:

sess.run(tf.global_variables_initializer())
sess.run(tf.local_variables_initializer())

rsepassi avatar Nov 13 '17 22:11 rsepassi

it worked,tks

2877992943 avatar Nov 14 '17 06:11 2877992943