Closed velikodniy closed 7 years ago
When I try to start INetwork with --content_loss_type 1
I get this error message:
Traceback (most recent call last):
File "INetwork.py", line 463, in <module>
combination_features)
File "INetwork.py", line 429, in content_loss
multiplier = 1 / (2. * channels ** 0.5 * size ** 0.5)
TypeError: unsupported operand type(s) for ** or pow(): 'Tensor' and 'float'
I use the latest Tensorflow:
tensorflow==1.2.0
tensorflow-gpu==1.2.0
I didn't know that int_shape is specific for Keras. It is not mentioned in the documentation. But the type returned by K.shape()
is different for different backends. So I don't know any simple way to fix it without using backend-specific functions.
There was a few other problems with the loss measure, and python 2 support for float type division was missing.
I've pushed a fix for the losses. Thanks for your help.
Just getting started with this code, I had to back out this change because it was causing errors.
python INetwork.py \
images/inputs/content/blue-moon-lake.jpg \
images/inputs/style/starry_night.jpg \
outputs/starry_moon.jpg
Model loaded.
Traceback (most recent call last):
File "INetwork.py", line 478, in <module>
combination_features)
File "INetwork.py", line 440, in content_loss
channels = K.int_shape(base)[channel_dim]
File "/usr/local/anaconda/lib/python3.6/site-packages/keras/backend/theano_backend.py", line 250, in int_shape
raise TypeError('Not a Keras tensor:', x)
TypeError: ('Not a Keras tensor:', Subtensor{int64, ::, ::, ::}.0)
@dribnet Interesting. Does the K.shape() version work ?
@dribnet Can you see if replacing line 440 of INetwork.py with this works ?
try:
channels = K.int_shape(base)[channel_dim]
except TypeError:
channels = K.shape(base)[channel_dim]
Yes - things seem to be working again after commit 037a8a78, thanks!
That's good. Sorry for the trouble.
Can you describe this error ? I use Tensorflow backend currently and do not see this error.
Also, int_shape is specific to Tensorflow, whereas shape is general to all backend. I would prefer to keep shape.