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

Implementation of Siamese Neural Networks for One-shot Image Recognition
605 stars 181 forks source link

The training went wrong. #10

Closed lwzhaojun closed 4 years ago

lwzhaojun commented 4 years ago

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

yuying950717 commented 3 years ago

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

LiaoPerry commented 3 years ago

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 https://github.com/keras-team/keras/issues/12379

tensorfreitas commented 3 years ago

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.