awentzonline / image-analogies

Generate image analogies using neural matching and blending.
MIT License
3.52k stars 283 forks source link

Error while running example ("Cannot convert %s to TensorType" % str_x, type(x)) #35

Closed Cybrak closed 7 years ago

Cybrak commented 7 years ago

Hello guys, I am try to run the examples and I keep getting this error.

File "/home/cyb/image-analogies/venv/local/lib/python2.7/site-packages/theano/tensor/basic.py", line 208, 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'>)

Would you have any clues how to fix that ? Thanks a lot!

getarobo commented 7 years ago

any solve or hack found? thanks~

getarobo commented 7 years ago

i have figured out.

keras 2.x -> keras 1.1.2
pip uninstall keras
pip install keras==1.1.2

set keras to use theano instead of tensorflow
sudo vi ~/.keras/keras.json
(change backend from tensorflow to theano)
Cybrak commented 7 years ago

Hahaha Thank you I'll try that !!

neilpanchal commented 6 years ago

@getarobo I followed your instructions to run with Theano instead of Tensorflow, but I am stuck with a couple of things:

Using Theano 1.0.1, I am getting old GPU architecture error - This has to do with Keras making direct gpuarray calls.

"You are importing theano.sandbox.cuda. This is the old GPU back-end and "
unittest.case.SkipTest: You are importing theano.sandbox.cuda. This is the old GPU back-end and is removed from Theano. Use Theano 0.9 to use it. Even better, transition to the new GPU back-end! See https://github.com/Theano/Theano/wiki/Converting-to-the-new-gpu-back-end%28gpuarray%29

So, I downgraded Theano to 0.9 version and I am now seeing this:

examples / ➞  ./render-example.sh arch ../vgg16_weights.h5
Only using analogy loss
Using Theano backend.
Traceback (most recent call last):
  File "/Users/carbon/Dev/anaconda/envs/DL-analogy/bin/make_image_analogy.py", line 12, in <module>
    import image_analogy.argparser
  File "/Users/carbon/Dev/anaconda/envs/DL-analogy/lib/python3.6/site-packages/image_analogy/argparser.py", line 4, in <module>
    from keras import backend as K
  File "/Users/carbon/Dev/anaconda/envs/DL-analogy/lib/python3.6/site-packages/keras/__init__.py", line 2, in <module>
    from . import backend
  File "/Users/carbon/Dev/anaconda/envs/DL-analogy/lib/python3.6/site-packages/keras/backend/__init__.py", line 64, in <module>
    from .theano_backend import *
  File "/Users/carbon/Dev/anaconda/envs/DL-analogy/lib/python3.6/site-packages/keras/backend/theano_backend.py", line 1, in <module>
    import theano
  File "/Users/carbon/Dev/anaconda/envs/DL-analogy/lib/python3.6/site-packages/theano/__init__.py", line 80, in <module>
    from theano.scan_module import (scan, map, reduce, foldl, foldr, clone,
  File "/Users/carbon/Dev/anaconda/envs/DL-analogy/lib/python3.6/site-packages/theano/scan_module/__init__.py", line 41, in <module>
    from theano.scan_module import scan_opt
  File "/Users/carbon/Dev/anaconda/envs/DL-analogy/lib/python3.6/site-packages/theano/scan_module/scan_opt.py", line 60, in <module>
    from theano import tensor, scalar
  File "/Users/carbon/Dev/anaconda/envs/DL-analogy/lib/python3.6/site-packages/theano/tensor/__init__.py", line 9, in <module>
    from theano.tensor.subtensor import *
  File "/Users/carbon/Dev/anaconda/envs/DL-analogy/lib/python3.6/site-packages/theano/tensor/subtensor.py", line 27, in <module>
    from cutils_ext.cutils_ext import inplace_increment
ImportError: cannot import name 'inplace_increment'
neilpanchal commented 6 years ago

Also, someone knowleageable enough needs to fix the Tensorflow error. Theano is dead. TF is the way forward.

mike-truk commented 6 years ago

@neilpanchal I recently hit the same issue. After upgrading/downgrading Theano try flushing the Theano cache with "theano-cache clear" or "theano-cache purge". If neither of those work, removing the cache directory with "rm -rf ~/.theano" should do the job.