image-analogies
image-analogies copied to clipboard
Cannot convert Tensor("ExpandDims:0", shape=(1, 256, 32, 22), dtype=float32) to TensorType'
I tried running an example and I am getting a ton of errors:
(DL) ♦ examples / ➞ ./render-example.sh arch ../vgg16_weights.h5
Only using analogy loss
/Users/carbon/Dev/anaconda/envs/DL/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
from ._conv import register_converters as _register_converters
Using TensorFlow backend.
Tensorflow detected. Forcing --a-scale-mode=match (A images are scaled to same size as B images)
Using brute-force model
Scale factor 0.25 "A" shape (1, 3, 128, 89) "B" shape (1, 3, 128, 89)
2018-01-14 10:28:44.742492: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:859] OS X does not support NUMA - returning NUMA node zero
2018-01-14 10:28:44.742578: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1206] Found device 0 with properties:
name: GeForce GTX 1080 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.6705
pciBusID: 0000:01:00.0
totalMemory: 11.00GiB freeMemory: 8.34GiB
2018-01-14 10:28:44.742589: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1300] Adding visible gpu device 0
2018-01-14 10:28:44.951639: I tensorflow/core/common_runtime/gpu/gpu_device.cc:987] Creating TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 8064 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:01:00.0, compute capability: 6.1)
Building loss...
WARNING:tensorflow:From /Users/carbon/Dev/anaconda/envs/DL/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:1247: calling reduce_sum (from tensorflow.python.ops.math_ops) with keep_dims is deprecated and will be removed in a future version.
Instructions for updating:
keep_dims is deprecated, use keepdims instead
Precomputing static features...
Building and combining losses...
Traceback (most recent call last):
File "/Users/carbon/Dev/anaconda/envs/DL/lib/python3.6/site-packages/theano/tensor/type.py", line 269, in dtype_specs
}[self.dtype]
KeyError: 'object'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/carbon/Dev/anaconda/envs/DL/lib/python3.6/site-packages/theano/tensor/basic.py", line 246, in constant
ttype = TensorType(dtype=x_.dtype, broadcastable=bcastable)
File "/Users/carbon/Dev/anaconda/envs/DL/lib/python3.6/site-packages/theano/tensor/type.py", line 51, in __init__
self.dtype_specs() # error checking is done there
File "/Users/carbon/Dev/anaconda/envs/DL/lib/python3.6/site-packages/theano/tensor/type.py", line 272, in dtype_specs
% (self.__class__.__name__, self.dtype))
TypeError: Unsupported dtype for TensorType: object
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/carbon/Dev/anaconda/envs/DL/lib/python3.6/site-packages/theano/tensor/basic.py", line 194, in as_tensor_variable
return constant(x, name=name, ndim=ndim)
File "/Users/carbon/Dev/anaconda/envs/DL/lib/python3.6/site-packages/theano/tensor/basic.py", line 266, in constant
raise TypeError("Could not convert %s to TensorType" % x, type(x))
TypeError: ('Could not convert Tensor("ExpandDims:0", shape=(1, 256, 32, 22), dtype=float32) to TensorType', <class 'tensorflow.python.framework.ops.Tensor'>)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/carbon/Dev/anaconda/envs/DL/bin/make_image_analogy.py", line 27, in <module>
image_analogy.main.main(args, model_class)
File "/Users/carbon/Dev/anaconda/envs/DL/lib/python3.6/site-packages/image_analogy/main.py", line 71, in main
model.build(a_image, ap_image, b_image, (1, img_num_channels, img_height, img_width))
File "/Users/carbon/Dev/anaconda/envs/DL/lib/python3.6/site-packages/image_analogy/models/base.py", line 23, in build
loss = self.build_loss(a_image, ap_image, b_image)
File "/Users/carbon/Dev/anaconda/envs/DL/lib/python3.6/site-packages/image_analogy/models/analogy.py", line 37, in build_loss
patch_stride=self.args.patch_stride)
File "/Users/carbon/Dev/anaconda/envs/DL/lib/python3.6/site-packages/image_analogy/losses/analogy.py", line 28, in analogy_loss
best_a_prime_patches = find_analogy_patches(a, a_prime, b, patch_size=patch_size, patch_stride=patch_stride)
File "/Users/carbon/Dev/anaconda/envs/DL/lib/python3.6/site-packages/image_analogy/losses/analogy.py", line 14, in find_analogy_patches
a_patches, a_patches_norm = patches.make_patches(K.variable(a), patch_size, patch_stride)
File "/Users/carbon/Dev/anaconda/envs/DL/lib/python3.6/site-packages/image_analogy/losses/patches.py", line 14, in make_patches
mode='valid')
File "/Users/carbon/Dev/anaconda/envs/DL/lib/python3.6/site-packages/theano/tensor/nnet/neighbours.py", line 714, in images2neibs
return Images2Neibs(mode)(ten4, neib_shape, neib_step)
File "/Users/carbon/Dev/anaconda/envs/DL/lib/python3.6/site-packages/theano/gof/op.py", line 615, in __call__
node = self.make_node(*inputs, **kwargs)
File "/Users/carbon/Dev/anaconda/envs/DL/lib/python3.6/site-packages/theano/tensor/nnet/neighbours.py", line 101, in make_node
ten4 = T.as_tensor_variable(ten4)
File "/Users/carbon/Dev/anaconda/envs/DL/lib/python3.6/site-packages/theano/tensor/basic.py", line 200, in as_tensor_variable
raise AsTensorError("Cannot convert %s to TensorType" % str_x, type(x))
theano.tensor.var.AsTensorError: ('Cannot convert Tensor("ExpandDims:0", shape=(1, 256, 32, 22), dtype=float32) to TensorType', <class 'tensorflow.python.framework.ops.Tensor'>)
@neilpanchal I hit a wall with this same issue. Not sure if it is keras, theano, or tensorflow?
FWIW -- I'm using theano 1.0.1, keras 2.1.2, tensorflow-gpu 1.4.1 and Cuda8 on Ubuntu 17.10.
Anyone got the issue resolved? or anyone who ran it on GPU?
I was able to get this to run on a GPU using the theano backend.
-
Get pygpu to work. This was terrible both on windows and linux. Here's what I did on windows: https://github.com/Theano/Theano/issues/6681#issuecomment-482819279. Linux was more or less the same except it had no problem with my library filenames.
-
Configure ~/.theanorc:
[global]
device = cuda
floatX = float32
[gpuarray]
preallocate = -1
-
Verify theano can use the gpu: http://deeplearning.net/software/theano/tutorial/using_gpu.html#testing-theano-with-gpu
-
export KERAS_BACKEND=theano
I was able to get the winterize example to run on a GPU, but I had to disable memory preallocation or it would run out of memory. There's a performance hit for doing this, but maybe it would work without it if you had a GPU with more than 8 GB RAM.
Here's the state of all my libraries. The most important was Keras==1.1.1.
absl-py==0.7.1
astor==0.7.1
backports.weakref==1.0rc1
bleach==1.5.0
Cython==0.25
gast==0.2.2
grpcio==1.19.0
h5py==2.5.0
html5lib==0.9999999
Keras==1.1.1
Keras-Applications==1.0.7
Keras-Preprocessing==1.0.9
Mako==1.0.8
Markdown==3.1
MarkupSafe==1.1.1
mock==2.0.0
nose==1.3.7
numpy==1.16.2
pbr==5.1.3
Pillow==3.1.1
protobuf==3.7.1
pygpu==0.7.6
PyYAML==3.11
scikit-learn==0.17
scipy==0.17.0
six==1.10.0
tensorboard==1.13.1
tensorflow==1.13.1
tensorflow-estimator==1.13.0
tensorflow-tensorboard==0.1.8
termcolor==1.1.0
Theano==1.0.4
Werkzeug==0.15.2