iamhankai / attribute-aware-attention

[ACM MM 2018] Attribute-Aware Attention Model for Fine-grained Representation Learning
https://arxiv.org/abs/1901.00392
156 stars 30 forks source link

Error facing [Help me] #22

Open MuruganR96 opened 4 years ago

MuruganR96 commented 4 years ago

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.

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

Thanks and Regards Murugan Rajenthiran

iamhankai commented 4 years ago

The input image size can be changed here: https://github.com/iamhankai/attribute-aware-attention/blob/4b4cf873d6e398f1e64891dbc34ccb8fbd891f30/cub_demo.py#L51

MuruganR96 commented 4 years ago

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

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, _activation49 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 commented 4 years ago

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.