-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run error #5
Comments
Hallo jindongwang, Unfortunately our code only supports the theano backend and not tensorflow. However, theano is only used in the file domain_regularizer.py. One simple fix would be to use the keras backend functionality, wherever theano is used (indicated by 'T.'), forcing it to use tensorflow. I.e. using
instead of
and
instead of
I have tested this solution with python 2.7 and keras 1.1.0. More details on the requirements can be found in requirements.txt. Downgrading keras works well if you are using pip with
and python 3.5 should work. If You have futher problems I would be happy to help. |
Thank you @wzell for your kind reply! |
I think this has something to do with the change of the keras backend from theano to tensorflow, see e.g. |
Thanks for that! In fact I'm very interested in the CMD metric and want to use it independently as MMD. Is this possible?
|
Yes, this works. See exp_office.py for an example. |
I'm using Python3.5+Tensorflow1.2+Keras on Windows 10, and I get the following error:
`C:\Users\jindongwang\Anaconda3\python.exe C:/Users/jindongwang/Desktop/cmd-master/exp_office.py
Using TensorFlow backend.
WARNING (theano.configdefaults): g++ not detected ! Theano will be unable to execute optimized C-implementations (for both CPU and GPU) and will default to Python implementations. Performance will be severely degraded. To remove this warning, set Theano flags cxx to an empty string.
Loading office image data...
Found 2817 images belonging to 31 classes.
Found 498 images belonging to 31 classes.
Found 795 images belonging to 31 classes.
Creating/Loading image representations via VGG_16 model...
C:\Users\jindongwang\Anaconda3\lib\site-packages\keras\legacy\interfaces.py:86: UserWarning: Update your
Conv2D
call to the Keras 2 API:Conv2D(64, (3, 3), activation="relu")
'
call to the Keras 2 API: ' + signature) C:\Users\jindongwang\Anaconda3\lib\site-packages\keras\legacy\interfaces.py:86: UserWarning: Update your
Conv2Dcall to the Keras 2 API:
Conv2D(128, (3, 3), activation="relu")'
call to the Keras 2 API: ' + signature)Traceback (most recent call last):
File "C:\Users\jindongwang\Anaconda3\lib\site-packages\tensorflow\python\framework\common_shapes.py", line 671, in _call_cpp_shape_fn_impl
input_tensors_as_shapes, status)
File "C:\Users\jindongwang\Anaconda3\lib\contextlib.py", line 66, in exit
next(self.gen)
File "C:\Users\jindongwang\Anaconda3\lib\site-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 'max_pooling2d_2/MaxPool' (op: 'MaxPool') with input shapes: [?,1,112,128].
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/jindongwang/Desktop/cmd-master/exp_office.py", line 53, in
'amazon', N_IMAGES_AM)
File "C:\Users\jindongwang\Desktop\cmd-master\models\office_mmatch.py", line 154, in create_img_repr
vgg16 = self.VGG_16(weights_file)
File "C:\Users\jindongwang\Desktop\cmd-master\models\office_mmatch.py", line 285, in VGG_16
model.add(MaxPooling2D((2,2), strides=(2,2)))
File "C:\Users\jindongwang\Anaconda3\lib\site-packages\keras\models.py", line 455, in add
output_tensor = layer(self.outputs[0])
File "C:\Users\jindongwang\Anaconda3\lib\site-packages\keras\engine\topology.py", line 554, in call
output = self.call(inputs, **kwargs)
File "C:\Users\jindongwang\Anaconda3\lib\site-packages\keras\layers\pooling.py", line 154, in call
data_format=self.data_format)
File "C:\Users\jindongwang\Anaconda3\lib\site-packages\keras\layers\pooling.py", line 217, in _pooling_function
pool_mode='max')
File "C:\Users\jindongwang\Anaconda3\lib\site-packages\keras\backend\tensorflow_backend.py", line 3014, in pool2d
x = tf.nn.max_pool(x, pool_size, strides, padding=padding)
File "C:\Users\jindongwang\Anaconda3\lib\site-packages\tensorflow\python\ops\nn_ops.py", line 1769, in max_pool
name=name)
File "C:\Users\jindongwang\Anaconda3\lib\site-packages\tensorflow\python\ops\gen_nn_ops.py", line 1605, in _max_pool
data_format=data_format, name=name)
File "C:\Users\jindongwang\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 767, in apply_op
op_def=op_def)
File "C:\Users\jindongwang\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 2508, in create_op
set_shapes_for_outputs(ret)
File "C:\Users\jindongwang\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1873, in set_shapes_for_outputs
shapes = shape_func(op)
File "C:\Users\jindongwang\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1823, in call_with_requiring
return call_cpp_shape_fn(op, require_shape_fn=True)
File "C:\Users\jindongwang\Anaconda3\lib\site-packages\tensorflow\python\framework\common_shapes.py", line 610, in call_cpp_shape_fn
debug_python_shape_fn, require_shape_fn)
File "C:\Users\jindongwang\Anaconda3\lib\site-packages\tensorflow\python\framework\common_shapes.py", line 676, in _call_cpp_shape_fn_impl
raise ValueError(err.message)
ValueError: Negative dimension size caused by subtracting 2 from 1 for 'max_pooling2d_2/MaxPool' (op: 'MaxPool') with input shapes: [?,1,112,128].
Process finished with exit code 1`
What can I do?
The text was updated successfully, but these errors were encountered: