tensorfreitas / Siamese-Networks-for-One-Shot-Learning

Implementation of Siamese Neural Networks for One-shot Image Recognition

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The training went wrong.

lwzhaojun opened this issue · comments

First of all, thanks to your code, I have a deeper understanding of the paper.I met a problem in the training process, I hope the author can help me to solve it.Thank you.Here's the problem.
Traceback (most recent call last):
File "D:\PyCharm 5.0.3\helpers\pydev\pydevd.py", line 2407, in
globals = debugger.run(setup['file'], None, None, is_module)
File "D:\PyCharm 5.0.3\helpers\pydev\pydevd.py", line 1798, in run
launch(file, globals, locals) # execute the script
File "D:\PyCharm 5.0.3\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "D:/software/github/Siamese-Networks-for-One-Shot-Learning/train_siamese_network.py", line 59, in
main()
File "D:/software/github/Siamese-Networks-for-One-Shot-Learning/train_siamese_network.py", line 31, in main
tensorboard_log_path=tensorboard_log_path
File "D:/software/github/Siamese-Networks-for-One-Shot-Learning\siamese_network.py", line 72, in init
l2_regularization_penalization)
File "D:/software/github/Siamese-Networks-for-One-Shot-Learning\siamese_network.py", line 142, in _construct_siamese_architecture
momentum=0.5)
File "D:/software/github/Siamese-Networks-for-One-Shot-Learning\modified_sgd.py", line 42, in init
self.lr = K.variable(lr, name='lr')
AttributeError: can't set attribute

Excuse me, how did you solve this problem? I have the same problem now.

it solved this problem
you can
Replace:
self.lr = K.variable(lr, name='lr')
with:
self.lr = K.variable(lr, name='learning_rate')

I use tensorflow-gpu version is 2.1.0 and keras version is 2.3.1

I solved the problem according to the following URL
keras-team/keras#12379

Thank you for sharing Liao. I guess that with the new versions of keras and tensorflow some adjustments need to be made to the code.