models icon indicating copy to clipboard operation
models copied to clipboard

/models/research/slim/slim_warkthrough.ipynb error!

Open shipengai opened this issue 8 years ago • 19 comments

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

shipengai avatar Dec 28 '17 06:12 shipengai

Exact same problem on Mac OS X Python 2.7

yigitsa avatar Jan 01 '18 20:01 yigitsa

@sguada

skye avatar Jan 03 '18 01:01 skye

Exact same problem on Win10 Python 3.6

EthanYuan avatar Jan 11 '18 05:01 EthanYuan

same problem on Ubuntu Python 3.6

xumine avatar Jan 13 '18 08:01 xumine

same issue OS X and Python 3.5

viralbthakar avatar Feb 07 '18 13:02 viralbthakar

Exact same problem on Win10 Python 3.5

FuxiCV avatar Mar 09 '18 07:03 FuxiCV

same issue OS X and Python 3.6

mucun1988 avatar Apr 02 '18 02:04 mucun1988

same issue Win7 Python 3.5

Knight-H avatar Jun 12 '18 03:06 Knight-H

same issue Ubuntu + Python 3.6

sebastianffx avatar Jun 19 '18 20:06 sebastianffx

same issue for Win 10 and Python 3.6. It's been 6 months and nothing on this issue?

SAmmarAbbas avatar Jul 07 '18 00:07 SAmmarAbbas

Same issue Ubuntu + Python 3.5

PiaCuk avatar Jul 07 '18 15:07 PiaCuk

Same issue Ubuntu + python 2.7

muzi-8 avatar Sep 15 '18 08:09 muzi-8

Same issue OS X + Python 3.6

Yiwen0201 avatar Oct 16 '18 18:10 Yiwen0201

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.

zwqnju avatar Dec 26 '18 08:12 zwqnju

Modifications have been completed to evaluation.py in #21020. Hence closed.

msymp avatar Jan 04 '19 20:01 msymp

Modifications have been completed to evaluation.py in #21020. Hence closed.

Where could I get it?

ShihuaiXu avatar Mar 25 '19 04:03 ShihuaiXu

@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 avatar Apr 03 '19 14:04 antelidakis

@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))

dannykuo25 avatar May 02 '19 01:05 dannykuo25

I am also having this issue

raineydavid avatar Jun 07 '19 14:06 raineydavid