crlz182 / Netvlad-Keras

This is a Keras implementation of the Netvlad network for visual place recognition.
22 stars 6 forks source link

error in load weights #1

Open alighofrani95 opened 4 years ago

alighofrani95 commented 4 years ago

By running example.py I faced with error...

ValueError: Layer #14 (named "net_vlad_1" in the current model) was found to correspond to layer net_vlad_1 in the save file. However the new layer net_vlad_1 expects 1 weights, but the saved weights have 2 elements.

Lu-Feng commented 4 years ago

By running example.py I faced with error...

ValueError: Layer #14 (named "net_vlad_1" in the current model) was found to correspond to layer net_vlad_1 in the save file. However the new layer net_vlad_1 expects 1 weights, but the saved weights have 2 elements.

Hello, have you solved this error? I also faced with it.

LiuZhenyao commented 4 years ago

通过运行example.py我遇到了错误...

ValueError:第14层(在当前模型中名为“ net_vlad_1”)对应于保存文件中的net_vlad_1层。但是,新层net_vlad_1期望权重为1,但是保存的权重为2个元素。

i also encountered the same problem!

Carlz182 commented 4 years ago

Hi all,

thanks for reporting this. I will try to figure out what went wrong. Could you please tell me which version of tensorflow you are using?

Lu-Feng commented 4 years ago

Hi all,

thanks for reporting this. I will try to figure out what went wrong. Could you please tell me which version of tensorflow you are using?

I'm using tensorflow 1.10.0

LiuZhenyao commented 4 years ago

大家好,

感谢您举报。我将尝试找出问题所在。您能告诉我您使用的是哪个版本的tensorflow吗?

1.11.0

Carlz182 commented 4 years ago

To solve this problem go to netvladlayer.py and comment out the following line

self._trainable_weights.append(self.conv.trainable_weights[0])

This adds the kernel weights to the model's list of trainable. Then you should be able to load the weights. This occurs only when using older tensorflow versions because I did not have the problem using 1.14 back then. Let me know if that solved your issue.

Lu-Feng commented 4 years ago

To solve this problem go to netvladlayer.py and comment out the following line

self._trainable_weights.append(self.conv.trainable_weights[0])

This adds the kernel weights to the model's list of trainable. Then you should be able to load the weights. This occurs only when using older tensorflow versions because I did not have the problem using 1.14 back then. Let me know if that solved your issue.

I have solved it with your help, thank you very much

LiuZhenyao commented 4 years ago

要解决此问题,请转到netvladlayer.py并注释掉以下行

self._trainable_weights.append(self.conv.trainable_weights[0])

这会将内核权重添加到模型的可训练列表中。然后,您应该能够加载权重。这仅在使用较旧的tensorflow版本时发生,因为那时我没有使用1.14的问题。让我知道这是否解决了您的问题。

thank you so much, it works well

Yongjie-L commented 3 years ago

To solve this problem go to netvladlayer.py and comment out the following line

self._trainable_weights.append(self.conv.trainable_weights[0])

This adds the kernel weights to the model's list of trainable. Then you should be able to load the weights. This occurs only when using older tensorflow versions because I did not have the problem using 1.14 back then. Let me know if that solved your issue.

Hi! Could you please provide the version of keras and tensorflow used to load the model? There are some errors related to the version. Thanks.