elephanthunters / deep-dream-using-tensorflow Goto Github PK
View Code? Open in Web Editor NEWit's a practical guide on how to employ deep dream algorithm over your images using Tensorflow
it's a practical guide on how to employ deep dream algorithm over your images using Tensorflow
Recursive level: 0
Processing image:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
~/anaconda/lib/python3.6/site-packages/tensorflow/python/client/session.py in __init__(self, fetches, contraction_fn)
266 self._unique_fetches.append(ops.get_default_graph().as_graph_element(
--> 267 fetch, allow_tensor=True, allow_operation=True))
268 except TypeError as e:
~/anaconda/lib/python3.6/site-packages/tensorflow/python/framework/ops.py in as_graph_element(self, obj, allow_tensor, allow_operation)
2583 with self._lock:
-> 2584 return self._as_graph_element_locked(obj, allow_tensor, allow_operation)
2585
~/anaconda/lib/python3.6/site-packages/tensorflow/python/framework/ops.py in _as_graph_element_locked(self, obj, allow_tensor, allow_operation)
2662 if obj.graph is not self:
-> 2663 raise ValueError("Tensor %s is not an element of this graph." % obj)
2664 return obj
ValueError: Tensor Tensor("gradients_3/conv2d0_pre_relu/conv_grad/Conv2DBackpropInput:0", shape=(?, ?, ?, ?), dtype=float32) is not an element of this graph.
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
<ipython-input-57-5d83fc662529> in <module>()
1 img_result = recursive_optimize(layer_tensor=layer_tensor, image=image,
2 num_iterations=10, step_size=3.0, rescale_factor=0.7,
----> 3 num_repeats=4, blend=0.2)
<ipython-input-46-f2d8e35fb16c> in recursive_optimize(layer_tensor, image, num_repeats, rescale_factor, blend, num_iterations, step_size, tile_size)
42 num_iterations=num_iterations,
43 step_size=step_size,
---> 44 tile_size=tile_size)
45
46 # Upscale the resulting image back to its original size.
<ipython-input-46-f2d8e35fb16c> in recursive_optimize(layer_tensor, image, num_repeats, rescale_factor, blend, num_iterations, step_size, tile_size)
42 num_iterations=num_iterations,
43 step_size=step_size,
---> 44 tile_size=tile_size)
45
46 # Upscale the resulting image back to its original size.
<ipython-input-46-f2d8e35fb16c> in recursive_optimize(layer_tensor, image, num_repeats, rescale_factor, blend, num_iterations, step_size, tile_size)
42 num_iterations=num_iterations,
43 step_size=step_size,
---> 44 tile_size=tile_size)
45
46 # Upscale the resulting image back to its original size.
<ipython-input-46-f2d8e35fb16c> in recursive_optimize(layer_tensor, image, num_repeats, rescale_factor, blend, num_iterations, step_size, tile_size)
42 num_iterations=num_iterations,
43 step_size=step_size,
---> 44 tile_size=tile_size)
45
46 # Upscale the resulting image back to its original size.
<ipython-input-46-f2d8e35fb16c> in recursive_optimize(layer_tensor, image, num_repeats, rescale_factor, blend, num_iterations, step_size, tile_size)
57 num_iterations=num_iterations,
58 step_size=step_size,
---> 59 tile_size=tile_size)
60
61 return img_result
<ipython-input-45-e9bbe3685879> in optimize_image(layer_tensor, image, num_iterations, step_size, tile_size, show_gradient)
31 # This tells us how to change the image so as to
32 # maximize the mean of the given layer-tensor.
---> 33 grad = tiled_gradient(gradient=gradient, image=img)
34
35 # Blur the gradient with different amounts and add
<ipython-input-44-c9dbd0c7c029> in tiled_gradient(gradient, image, tile_size)
50
51 # Use TensorFlow to calculate the gradient-value.
---> 52 g = session.run(gradient, feed_dict=feed_dict)
53
54 # Normalize the gradient for the tile. This is
~/anaconda/lib/python3.6/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)
~/anaconda/lib/python3.6/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.
~/anaconda/lib/python3.6/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 = []
~/anaconda/lib/python3.6/site-packages/tensorflow/python/client/session.py in for_fetch(fetch)
236 if isinstance(fetch, tensor_type):
237 fetches, contraction_fn = fetch_fn(fetch)
--> 238 return _ElementFetchMapper(fetches, contraction_fn)
239 # Did not find anything.
240 raise TypeError('Fetch argument %r has invalid type %r' %
~/anaconda/lib/python3.6/site-packages/tensorflow/python/client/session.py in __init__(self, fetches, contraction_fn)
272 except ValueError as e:
273 raise ValueError('Fetch argument %r cannot be interpreted as a '
--> 274 'Tensor. (%s)' % (fetch, str(e)))
275 except KeyError as e:
276 raise ValueError('Fetch argument %r cannot be interpreted as a '
ValueError: Fetch argument <tf.Tensor 'gradients_3/conv2d0_pre_relu/conv_grad/Conv2DBackpropInput:0' shape=(?, ?, ?, ?) dtype=float32> cannot be interpreted as a Tensor. (Tensor Tensor("gradients_3/conv2d0_pre_relu/conv_grad/Conv2DBackpropInput:0", shape=(?, ?, ?, ?), dtype=float32) is not an element of this graph.)
First, a massive thank you for this tutorial. This is the best implementation for generating high quality images I've found so far. I have a question though.
In the notebook, you specify a way to select a range of features from a layer with
layer_tensor = model.layer_tensors[10][:,:,:,0:3]
I was wondering if you know a way to select specific features instead of a range of features. I generated images for almost all seperate features in the layers and found some interesting ones which I want to combine. I understand it has been quite some time since you created this tutorial. If you'd find the time to respond, I would be eternally grateful.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.