keras-deep-dream
keras-deep-dream copied to clipboard
NOT WORKING
I can't seem to get this to work. I am running a VM Ubuntu with the latest keras and tensorflow CPU.
When I run it: deeplearning@deep-learning-virtual-machine:~/Desktop$ python3 deep_dream.py vgg16 jesse.png dream
I get the following: Using TensorFlow backend. (1080, 1620, 4) (900, 1350, 4) (750, 1125, 4) Starting octave 0 with dimensions 1125 x 750 Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/common_shapes.py", line 671, in _call_cpp_shape_fn_impl input_tensors_as_shapes, status) File "/usr/lib/python3.5/contextlib.py", line 66, in exit next(self.gen) File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status pywrap_tensorflow.TF_GetCode(status)) tensorflow.python.framework.errors_impl.InvalidArgumentError: Negative dimension size caused by subtracting 2 from 1 for 'block2_pool/MaxPool' (op: 'MaxPool') with input shapes: [?,1,375,128].
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "deep_dream.py", line 198, in
Am I doing something wrong? This looks like great work, I might just be a noob. Thanks
@gaara100 Could you be using tensorflow backend with "image_dim_ordering": "th" ?
I have the same error.
ValueError: Negative dimension size caused by subtracting 2 from 1 for 'block2_pool/MaxPool' (op: 'MaxPool') with input shapes: [?,1,800,128].
keras.json seems to be Ok:
{
"image_dim_ordering": "tf",
"epsilon": 1e-07,
"floatx": "float32",
"backend": "tensorflow"
}
In method preprocess_image the ordering is transposed for theano (depth, rows, columns), but the MaxPooling layer expects (because of your keras.json) an ordering for tensorflow (rows, columns, depth). Change the "image_dim_ordering" to "th" and it should work.
It doesn't help: no matter which image_dim_ordering I'm using ("th" or "tf"), error is the same:
ValueError: Negative dimension size caused by subtracting 2 from 1 for 'block2_pool/MaxPool' (op: 'MaxPool') with input shapes: [?,1,800,128]. I've tried to change line 87 of deep_dream.py to
img = img.transpose((0, 1, 2)).astype('float64')
with a same result.
And only iff I change my backend to Theano, it starts working, but I run into another error after 5 serconds:
Traceback (most recent call last): File "deep_dream.py", line 220, in
loss_and_grads = create_loss_function(dream, settings, model, img_shape) File "deep_dream.py", line 115, in create_loss_function assert layer_name in layer_dict.keys(), 'Layer ' + layer_name + ' not found in model.' AssertionError: Layer conv5_1 not found in model.
I'm not sure, that my Theano setup is Ok (never used it or Keras before), but my Tensorflow working for sure — I can work with a Tensorflow example of Deepdream.
The problem you are facing now is because conv5_1 is part of a different graph (model) than the one you selected.
btw with these settings { "image_dim_ordering": "th", "epsilon": 1e-07, "floatx": "float32", "backend": "tensorflow" }
everything worked fine for me