/models/research/slim/slim_warkthrough.ipynb error!
TypeError: 'module' object is not callable When run Let's compute various evaluation metrics on the test set.
with tf.Graph().as_default():
inputs, targets = convert_data_to_tensors(x_test, y_test)
predictions, end_points = regression_model(inputs, is_training=False)
# Specify metrics to evaluate:
names_to_value_nodes, names_to_update_nodes = slim.metrics.aggregate_metric_map({
'Mean Squared Error': slim.metrics.streaming_mean_squared_error(predictions, targets),
'Mean Absolute Error': slim.metrics.streaming_mean_absolute_error(predictions, targets)
})
# Make a session which restores the old graph parameters, and then run eval.
sv = tf.train.Supervisor(logdir=ckpt_dir)
with sv.managed_session() as sess:
metric_values = slim.evaluation.evaluation(
sess,
num_evals=1, # Single pass over data
eval_op=names_to_update_nodes.values(),
final_op=names_to_value_nodes.values())
names_to_values = dict(zip(names_to_value_nodes.keys(), metric_values))
for key, value in names_to_values.items():
print('%s: %f' % (key, value))
then the error shows:
INFO:tensorflow:Restoring parameters from /tmp/regression_model/model.ckpt
INFO:tensorflow:Starting standard services.
INFO:tensorflow:Starting queue runners.
INFO:tensorflow:Saving checkpoint to path /tmp/regression_model/model.ckpt
INFO:tensorflow:Error reported to Coordinator: <type 'exceptions.TypeError'>, 'module' object is not callable
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-10-33510a38425e> in <module>()
16 num_evals=1, # Single pass over data
17 eval_op=names_to_update_nodes.values(),
---> 18 final_op=names_to_value_nodes.values())
19
20 names_to_values = dict(zip(names_to_value_nodes.keys(), metric_values))
TypeError: 'module' object is not callable
Exact same problem on Mac OS X Python 2.7
@sguada
Exact same problem on Win10 Python 3.6
same problem on Ubuntu Python 3.6
same issue OS X and Python 3.5
Exact same problem on Win10 Python 3.5
same issue OS X and Python 3.6
same issue Win7 Python 3.5
same issue Ubuntu + Python 3.6
same issue for Win 10 and Python 3.6. It's been 6 months and nothing on this issue?
Same issue Ubuntu + Python 3.5
Same issue Ubuntu + python 2.7
Same issue OS X + Python 3.6
I have found out the error reason: the method slim.evaluation.evaluation() doesn't exist any longer. Maybe it should be replaced by slim.evaluation.evaluate_once(). See below:
https://github.com/tensorflow/tensorflow/issues/12357
https://github.com/tensorflow/tensorflow/pull/21020/commits/828257c82a6dfc1537547d226b25b7e394ff3cd4
That outdated documentation has been fixed. But I don't know how to fix this issue. I try to modify code like this:
metric_values = slim.evaluation.evaluate_once(
master='',
checkpoint_path=ckpt_dir,
logdir=ckpt_dir,
num_evals=1, # Single pass over data
eval_op=names_to_update_nodes.values(),
final_op=names_to_value_nodes.values())
But there comes another error: RuntimeError: Graph is finalized and cannot be modified.
I am just a newbie on tensorflow. I hope that an expert on tensorflow can solve this issue.
Modifications have been completed to evaluation.py in #21020. Hence closed.
Modifications have been completed to evaluation.py in #21020. Hence closed.
Where could I get it?
@msymp I am not use I follow if this is fixed. I came across the same error while trying the official slim notebook. Can you please point to a link with the solution? My enviroment is: Ubuntu: 16.04 LTS Python3: 3.5.2 TensorFlow: 1.12 NVIDIA Driver Version: 390.87 TensorFlow Models Git cloned at: 22 Nov 2018
@antelidakis @zwqnju @ShihuaiXu
Solutions:
Replace the code
sv = tf.train.Supervisor(logdir=ckpt_dir)
with sv.managed_session() as sess:
metric_values = slim.evaluation.evaluation(
sess,
num_evals=1, # Single pass over data
eval_op=names_to_update_nodes.values(),
final_op=names_to_value_nodes.values())
names_to_values = dict(zip(names_to_value_nodes.keys(), metric_values))
for key, value in names_to_values.items():
print('%s: %f' % (key, value))
by
metric_values = slim.evaluation.evaluate_once(
master='',
checkpoint_path='/tmp/regression_model/model.ckpt-5000', # set your own checkpoint path
logdir='log',
num_evals=1, # Single pass over data
eval_op=names_to_update_nodes,
final_op=names_to_value_nodes)
for key, value in metric_values.items():
print('%s: %f' % (key, value))
I am also having this issue