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

A little problem about merge function #7

Closed GeorgeKAHChen closed 5 years ago

GeorgeKAHChen commented 5 years ago

Thanks for your sharing and paper, which showed us an excellent idea in pedestrian re-identification. However, when I run your sample code with your sample dataset, something wrong in the function keras.layers.merge()

And the error is TypeError: 'module' object is not callable

First, I thought my tensorflow or keras environment have some wrong or conda have problems. But after long time research and testing, I found the problem is not caused by environment or system. Then I try to find the introduction of function merge, but I can only find information about this LAYER rather than MERGE FUNCTION identity! ( https://keras.io/layers/merge/ ) Finally, I got the solution here:

https://github.com/keras-team/keras/issues/3921#issuecomment-306031159 .

It seems this layer is not exist anymore. Then I changed code from merge(.., mode = "", dot_axis=**) to dot (.., axis = **) (or average, concatenate) and now it works.

It seems you need to upgrade your code as soon as possible and solve this little but annoying problem. Thanks~

iamhankai commented 5 years ago

Good job. This is due to the version of Keras. The code is best run on Keras 1.2.1.

GeorgeKAHChen commented 5 years ago

Good job. This is due to the version of Keras. The code is best run on Keras 1.2.1.

Ok I got it, thanks.

This time I found two new problems:

  1. In cub_demo.py (Line 65 - 67)

    65     prob = Dropout(dropout)(pool)
    66     prob = Dense(nb_class)(pool)
    67     prob = Activation(activation='softmax',name=name)(prob)

    In this part of code, it seems line 65 (Dropout Layer) did nothing. Because prob in line 66 is inherited from poor itself rather than prob above (ling 65). Is this a mistake or this layer is unnecessary in the network? Or I misunderstand the code/network?

  2. Another problem is how to output final feature identity? I found a switch called "flag_test". However, when I turn on this flag, the outputs are classes after classification rather than feature. We want to do more researching and studying using this A3M feature with a new classifier in re-id problems. So how can I get feature directly?

Thank you so much for your help~

iamhankai commented 5 years ago
  1. It's a bug. Thx~ I fixed it (https://github.com/iamhankai/attribute-aware-attention/commit/a2be08e28a86435a94601fa4652d4e7ba347a417).
  2. To extract feature for reid, you should change https://github.com/iamhankai/attribute-aware-attention/blob/ab3210705524bcb56f0121de0bcd47f3f93fb6c5/cub_demo.py#L138

to out_list.append(final_fea). The final feature in the output list can be used for person re-id.