tf_cnnvis: Fetch argument None has invalid type

Hi. I’m having a lot of trouble trying to get your function to work. I’m getting an error now that looks like it is coming from your deconvolution functions. Could you please let me know what you think the solution is?

Code I used:

is_loaded=tf_cnnvis.deconv_visualization(graph_or_path=tf.get_default_graph(),
                                         value_feed_dict={x_pl:x_batch, y_gt:targets_batch, is_training:False, valid_eval_accs:1000.0, valid_xent:1000.0},
                                         layers='r',
                                         path_logdir="c:/p17/logs/tf_cnnvis/flowers/1/logs",
                                         path_outdir="c:/p17/logs/tf_cnnvis/flowers/1/out")

Thanks.

INFO:tensorflow:Restoring parameters from model\tmp-model
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-13-41761d870143> in <module>()
      3                                          layers='r',
      4                                          path_logdir="c:/p17/logs/tf_cnnvis/flowers/1/logs",
----> 5                                          path_outdir="c:/p17/logs/tf_cnnvis/flowers/1/out")

C:\Users\username\Anaconda3\envs\tfGPU\lib\site-packages\tf_cnnvis-1.0.0-py3.5.egg\tf_cnnvis\tf_cnnvis.py in deconv_visualization(graph_or_path, value_feed_dict, input_tensor, layers, path_logdir, path_outdir)
    381 def deconv_visualization(graph_or_path, value_feed_dict, input_tensor = None, layers = 'r', path_logdir = './Log', path_outdir = "./Output"):
    382 	is_success = _get_visualization(graph_or_path, value_feed_dict, input_tensor = input_tensor, layers = layers, method = "deconv", 
--> 383 		path_logdir = path_logdir, path_outdir = path_outdir)
    384         return is_success
    385 def deepdream_visualization(graph_or_path, value_feed_dict, layer, classes, input_tensor = None, path_logdir = './Log', path_outdir = "./Output"):

C:\Users\username\Anaconda3\envs\tfGPU\lib\site-packages\tf_cnnvis-1.0.0-py3.5.egg\tf_cnnvis\tf_cnnvis.py in _get_visualization(graph_or_path, value_feed_dict, input_tensor, layers, path_logdir, path_outdir, method)
    149                         elif layers != None and layers.lower() in dict_layer.keys():
    150                                 layer_type = dict_layer[layers.lower()]
--> 151                                 is_success = _visualization_by_layer_type(g, value_feed_dict, input_tensor, layer_type, method, path_logdir, path_outdir)
    152                         else:
    153                                 is_success = False

C:\Users\username\Anaconda3\envs\tfGPU\lib\site-packages\tf_cnnvis-1.0.0-py3.5.egg\tf_cnnvis\tf_cnnvis.py in _visualization_by_layer_type(graph, value_feed_dict, input_tensor, layer_type, method, path_logdir, path_outdir)
    202 
    203         for layer in layers:
--> 204                 is_success = _visualization_by_layer_name(graph, value_feed_dict, input_tensor, layer, method, path_logdir, path_outdir)
    205         return is_success
    206 

C:\Users\username\Anaconda3\envs\tfGPU\lib\site-packages\tf_cnnvis-1.0.0-py3.5.egg\tf_cnnvis\tf_cnnvis.py in _visualization_by_layer_name(graph, value_feed_dict, input_tensor, layer_name, method, path_logdir, path_outdir)
    263                         elif method == "deconv":
    264                                 # deconvolution
--> 265                                 results = _deconvolution(graph, sess, op_tensor, X, feed_dict)
    266                         elif method == "deepdream":
    267                                 # deepdream

C:\Users\username\Anaconda3\envs\tfGPU\lib\site-packages\tf_cnnvis-1.0.0-py3.5.egg\tf_cnnvis\tf_cnnvis.py in _deconvolution(graph, sess, op_tensor, X, feed_dict)
    310                                                 c += 1
    311                                 if c > 0:
--> 312                                         out.extend(sess.run(reconstruct[:c], feed_dict = feed_dict))
    313         return out
    314 def _deepdream(graph, sess, op_tensor, X, feed_dict, layer, path_outdir, path_logdir):

C:\Users\username\Anaconda3\envs\tfGPU\lib\site-packages\tensorflow\python\client\session.py in run(self, fetches, feed_dict, options, run_metadata)
    787     try:
    788       result = self._run(None, fetches, feed_dict, options_ptr,
--> 789                          run_metadata_ptr)
    790       if run_metadata:
    791         proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

C:\Users\username\Anaconda3\envs\tfGPU\lib\site-packages\tensorflow\python\client\session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
    982     # Create a fetch handler to take care of the structure of fetches.
    983     fetch_handler = _FetchHandler(
--> 984         self._graph, fetches, feed_dict_string, feed_handles=feed_handles)
    985 
    986     # Run request and get response.

C:\Users\username\Anaconda3\envs\tfGPU\lib\site-packages\tensorflow\python\client\session.py in __init__(self, graph, fetches, feeds, feed_handles)
    408     """
    409     with graph.as_default():
--> 410       self._fetch_mapper = _FetchMapper.for_fetch(fetches)
    411     self._fetches = []
    412     self._targets = []

C:\Users\username\Anaconda3\envs\tfGPU\lib\site-packages\tensorflow\python\client\session.py in for_fetch(fetch)
    228     elif isinstance(fetch, (list, tuple)):
    229       # NOTE(touts): This is also the code path for namedtuples.
--> 230       return _ListFetchMapper(fetch)
    231     elif isinstance(fetch, dict):
    232       return _DictFetchMapper(fetch)

C:\Users\username\Anaconda3\envs\tfGPU\lib\site-packages\tensorflow\python\client\session.py in __init__(self, fetches)
    335     """
    336     self._fetch_type = type(fetches)
--> 337     self._mappers = [_FetchMapper.for_fetch(fetch) for fetch in fetches]
    338     self._unique_fetches, self._value_indices = _uniquify_fetches(self._mappers)
    339 

C:\Users\username\Anaconda3\envs\tfGPU\lib\site-packages\tensorflow\python\client\session.py in <listcomp>(.0)
    335     """
    336     self._fetch_type = type(fetches)
--> 337     self._mappers = [_FetchMapper.for_fetch(fetch) for fetch in fetches]
    338     self._unique_fetches, self._value_indices = _uniquify_fetches(self._mappers)
    339 

C:\Users\username\Anaconda3\envs\tfGPU\lib\site-packages\tensorflow\python\client\session.py in for_fetch(fetch)
    225     if fetch is None:
    226       raise TypeError('Fetch argument %r has invalid type %r' %
--> 227                       (fetch, type(fetch)))
    228     elif isinstance(fetch, (list, tuple)):
    229       # NOTE(touts): This is also the code path for namedtuples.

TypeError: Fetch argument None has invalid type <class 'NoneType'>

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 22 (10 by maintainers)

Most upvoted comments

@falaktheoptimist I’ve tried it out. Here for the deconvolution it works!

@BhagyeshVikani , Thank you very much , it works. because i use slim , so don’t need to feed value_feed_dict, just pass the image to input_tensor.