Visualizing-Convnets
Visualizing-Convnets copied to clipboard
Missing How to generate the GIF of filters weights evolving
Hi Justin Francis Thanks for this well-written article on visualizing convnets. In the end, you show a gif of how filters weights evolving. but the code snippet for that is missing could please add that to the notebook Thank you
I didn't include how to do it because I did it using imagemagik and the ubuntu terminal which is not compatible with all systems. The original code for creating the gif I lost.
But essentially you have one image that you want to use for the gif. At every say 5 training steps run that image into filter i.e. sess.run(conv1_2, feed_dict={X: someimage.reshape(1,224,224,1)}
In the example I obviously concatenated multiple images together.
Then use scipy to save that image as 'someimage'+str(step) into some directory and create a gif in terminal using
convert -delay 10 -loop 0 ls -v
image.gif
I implore you to try and figure it out!
Hello. When I try to vizualize CONV 1-1 i get this error. Can you help me please with some suggestions? Thanks a lot, Alex
ValueError Traceback (most recent call last) C:\Alex\Anaconda\lib\site-packages\tensorflow\python\client\session.py in init(self, fetches, contraction_fn) 299 self._unique_fetches.append(ops.get_default_graph().as_graph_element( --> 300 fetch, allow_tensor=True, allow_operation=True)) 301 except TypeError as e:
C:\Alex\Anaconda\lib\site-packages\tensorflow\python\framework\ops.py in as_graph_element(self, obj, allow_tensor, allow_operation) 3477 with self._lock: -> 3478 return self._as_graph_element_locked(obj, allow_tensor, allow_operation) 3479
C:\Alex\Anaconda\lib\site-packages\tensorflow\python\framework\ops.py in _as_graph_element_locked(self, obj, allow_tensor, allow_operation) 3561 if obj.graph is not self: -> 3562 raise ValueError("Operation %s is not an element of this graph." % obj) 3563 return obj
ValueError: Operation name: "init_2" op: "NoOp" input: "^conv1_1/weights1_1/Assign" input: "^conv1_1/biases1_1/Assign" input: "^conv1_1_1/weights1_1/Assign" input: "^conv1_1_1/biases1_1/Assign" is not an element of this graph.
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
C:\Alex\Anaconda\lib\site-packages\tensorflow\python\client\session.py in run(self, fetches, feed_dict, options, run_metadata) 927 try: 928 result = self._run(None, fetches, feed_dict, options_ptr, --> 929 run_metadata_ptr) 930 if run_metadata: 931 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)
C:\Alex\Anaconda\lib\site-packages\tensorflow\python\client\session.py in _run(self, handle, fetches, feed_dict, options, run_metadata) 1135 # Create a fetch handler to take care of the structure of fetches. 1136 fetch_handler = _FetchHandler( -> 1137 self._graph, fetches, feed_dict_tensor, feed_handles=feed_handles) 1138 1139 # Run request and get response.
C:\Alex\Anaconda\lib\site-packages\tensorflow\python\client\session.py in init(self, graph, fetches, feeds, feed_handles) 469 """ 470 with graph.as_default(): --> 471 self._fetch_mapper = _FetchMapper.for_fetch(fetches) 472 self._fetches = [] 473 self._targets = []
C:\Alex\Anaconda\lib\site-packages\tensorflow\python\client\session.py in for_fetch(fetch) 269 if isinstance(fetch, tensor_type): 270 fetches, contraction_fn = fetch_fn(fetch) --> 271 return _ElementFetchMapper(fetches, contraction_fn) 272 # Did not find anything. 273 raise TypeError('Fetch argument %r has invalid type %r' % (fetch,
C:\Alex\Anaconda\lib\site-packages\tensorflow\python\client\session.py in init(self, fetches, contraction_fn) 305 except ValueError as e: 306 raise ValueError('Fetch argument %r cannot be interpreted as a ' --> 307 'Tensor. (%s)' % (fetch, str(e))) 308 except KeyError as e: 309 raise ValueError('Fetch argument %r cannot be interpreted as a '
ValueError: Fetch argument <tf.Operation 'init_2' type=NoOp> cannot be interpreted as a Tensor. (Operation name: "init_2" op: "NoOp" input: "^conv1_1/weights1_1/Assign" input: "^conv1_1/biases1_1/Assign" input: "^conv1_1_1/weights1_1/Assign" input: "^conv1_1_1/biases1_1/Assign" is not an element of this graph.)