Skip to content
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

Error facing [Help me] #22

Open
MuruganR96 opened this issue Oct 22, 2020 · 3 comments
Open

Error facing [Help me] #22

MuruganR96 opened this issue Oct 22, 2020 · 3 comments

Comments

@MuruganR96
Copy link

Running Command:

python cub_demo.py ResNet50 /home/dell/Videos/Object_Tracking/attribute-aware-atte
ntion/dataset/CUB_200_2011

Requirements:

  1. pip install keras==1.2.1
  2. pip install theano

added additionally, for backend set as 'theano'

import os
os.environ['KERAS_BACKEND'] = 'theano'

Error 1: ImportError: cannot import name inplace_increment

Deleting the cache manually worked.
rm -rf ~/.theano

Error 2: AttributeError: 'module' object has no attribute 'ifelse'

Your version of theano is probably too new for that version of Keras. You should try downgrading theano to 0.9.x,
pip install theano==0.9.0

Error 3: ValueError: Negative dimension size caused by subtracting 3 from 2 for 'MaxPool' (op: 'MaxPool') with input shapes: [?,2,2240,64].

i followed @iamhankai sir suggestion . changed "image_data_format" to "channels_first".
sudo gedit $HOME/.keras/keras.json

{
    "floatx": "float32",
    "epsilon": 1e-07,
    "backend": "tensorflow",
    "image_data_format": "channels_first"
}.

Error 4: ValueError: total size of new array must be unchanged

Traceback (most recent call last):
  File "cub_demo.py", line 102, in <module>
    share_fea_map = Reshape((final_dim, L), name='reshape_layer')(share_fea_map)        
  File "/home/dell/Videos/Object_Tracking/env_a3m/local/lib/python2.7/site-packages/keras/engine/topology.py", line 572, in __call__
    self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
  File "/home/dell/Videos/Object_Tracking/env_a3m/local/lib/python2.7/site-packages/keras/engine/topology.py", line 635, in add_inbound_node
    Node.create_node(self, inbound_layers, node_indices, tensor_indices)
  File "/home/dell/Videos/Object_Tracking/env_a3m/local/lib/python2.7/site-packages/keras/engine/topology.py", line 170, in create_node
    output_shapes = to_list(outbound_layer.get_output_shape_for(input_shapes[0]))
  File "/home/dell/Videos/Object_Tracking/env_a3m/local/lib/python2.7/site-packages/keras/layers/core.py", line 373, in get_output_shape_for
    self.target_shape)
  File "/home/dell/Videos/Object_Tracking/env_a3m/local/lib/python2.7/site-packages/keras/layers/core.py", line 367, in _fix_unknown_dimension
    raise ValueError(msg)
ValueError: total size of new array must be unchanged

I saw @iamhankai suggestion for this issue. but not understand clearly. I have few doubts, please help me @iamhankai @Muneeb699 sir. it is my request.

The input image size is 448448, not 224224.

  • here mentioned input image size/shape, exactly what are the width and height?
  • where I need to change the code?
  • either dataset/CUB_200_2011/images, all images need to resize?

Please guide me to solve this issue @iamhankai, sir.

Thanks and Regards
Murugan Rajenthiran

@iamhankai
Copy link
Owner

The input image size can be changed here:

img_rows, img_cols = 448, 448

@MuruganR96
Copy link
Author

MuruganR96 commented Oct 23, 2020

solved the issue. the problem is didn't get the right output feature map shape for activation_49

Traceback (most recent call last):
  File "cub_demo.py", line 102, in <module>
    share_fea_map = Reshape((final_dim, L), name='reshape_layer')(share_fea_map)

while doing Reshape, activation_49 shape mismatching with (final_dim, L) shape.

right requirements:
pip install keras==1.2.1
pip install tensorflow==1.2.0 --ignore-installed

activation_49 (Activation)       (None, 14, 14, 2048)  0           merge_16[0][0]                   
____________________________________________________________________________________________________
avg_pool (AveragePooling2D)      (None, 2, 2, 2048)    0           activation_49[0][0]              
====================================================================================================
Total params: 23,587,712
Trainable params: 23,534,592
Non-trainable params: 53,120

what was wrong here is,
requirements
pip install theano==0.9.0

activation_49 (Activation)       (None, 0, 14, 2048)   0           merge_16[0][0]                   
____________________________________________________________________________________________________
avg_pool (AveragePooling2D)      (None, 0, 2, 2048)    0           activation_49[0][0]              
====================================================================================================
Total params: 23,587,712
Trainable params: 23,534,592
Non-trainable params: 53,120

@MuruganR96
Copy link
Author

ValueError: Shape must be rank 2 but is rank 3 for 'MatMul_29' (op: 'MatMul') with input shapes: [?,196,512], [?,512].

Traceback (most recent call last):
  File "/home/dell/Videos/Object_Tracking/env_a3mv2/lib/python3.6/site-packages/tensorflow/python/framework/common_shapes.py", line 671, in _call_cpp_shape_fn_impl
    input_tensors_as_shapes, status)
  File "/usr/lib/python3.6/contextlib.py", line 88, in __exit__
    next(self.gen)
  File "/home/dell/Videos/Object_Tracking/env_a3mv2/lib/python3.6/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: Shape must be rank 2 but is rank 3 for 'MatMul_29' (op: 'MatMul') with input shapes: [?,196,512], [?,512].

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "cub_demo.py", line 104, in <module>
    attn1 = merge([id_fea_map,attr_fea_list[i]], mode='dot', dot_axes=(2,1)) 
  File "/home/dell/Videos/Object_Tracking/env_a3mv2/lib/python3.6/site-packages/keras/engine/topology.py", line 1680, in merge
    name=name)
  File "/home/dell/Videos/Object_Tracking/env_a3mv2/lib/python3.6/site-packages/keras/engine/topology.py", line 1301, in __init__
    self.add_inbound_node(layers, node_indices, tensor_indices)
  File "/home/dell/Videos/Object_Tracking/env_a3mv2/lib/python3.6/site-packages/keras/engine/topology.py", line 635, in add_inbound_node
    Node.create_node(self, inbound_layers, node_indices, tensor_indices)
  File "/home/dell/Videos/Object_Tracking/env_a3mv2/lib/python3.6/site-packages/keras/engine/topology.py", line 172, in create_node
    output_tensors = to_list(outbound_layer.call(input_tensors, mask=input_masks))
  File "/home/dell/Videos/Object_Tracking/env_a3mv2/lib/python3.6/site-packages/keras/engine/topology.py", line 1409, in call
    output = K.batch_dot(l1, l2, self.dot_axes)
  File "/home/dell/Videos/Object_Tracking/env_a3mv2/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 884, in batch_dot
    out = tf.matmul(x, y, adjoint_a=adj_x, adjoint_b=adj_y)
  File "/home/dell/Videos/Object_Tracking/env_a3mv2/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py", line 1816, in matmul
    a, b, transpose_a=transpose_a, transpose_b=transpose_b, name=name)
  File "/home/dell/Videos/Object_Tracking/env_a3mv2/lib/python3.6/site-packages/tensorflow/python/ops/gen_math_ops.py", line 1217, in _mat_mul
    transpose_b=transpose_b, name=name)
  File "/home/dell/Videos/Object_Tracking/env_a3mv2/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 767, in apply_op
    op_def=op_def)
  File "/home/dell/Videos/Object_Tracking/env_a3mv2/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 2508, in create_op
    set_shapes_for_outputs(ret)
  File "/home/dell/Videos/Object_Tracking/env_a3mv2/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1873, in set_shapes_for_outputs
    shapes = shape_func(op)
  File "/home/dell/Videos/Object_Tracking/env_a3mv2/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1823, in call_with_requiring
    return call_cpp_shape_fn(op, require_shape_fn=True)
  File "/home/dell/Videos/Object_Tracking/env_a3mv2/lib/python3.6/site-packages/tensorflow/python/framework/common_shapes.py", line 610, in call_cpp_shape_fn
    debug_python_shape_fn, require_shape_fn)
  File "/home/dell/Videos/Object_Tracking/env_a3mv2/lib/python3.6/site-packages/tensorflow/python/framework/common_shapes.py", line 676, in _call_cpp_shape_fn_impl
    raise ValueError(err.message)
ValueError: Shape must be rank 2 but is rank 3 for 'MatMul_29' (op: 'MatMul') with input shapes: [?,196,512], [?,512].

How to solve this issue @iamhankai, sir? please help me to solve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants