I am working on an image classification problem with multiple classes and I follow the siamese face recognition sample here . I have saved processed data in.npy format and I have used Lambda
in the siamese model. It shows an error in <lambda>
:
distance_euclid = Lambda( lambda tensors : K.abs( tensors[0] - tensors[1] ))( [output_x1 , output_x2] )
AttributeError: module 'tensorflow.python.keras' has no attribute 'abs'
Here are the package versions I'm using:
keras 2.3.1
python 3.6.10
tensorflow 2.1.0
abs
should be imported from tf.keras.backend
( tf.keras.backend.abs
) seems you are importing tf.python.keras
. In your import
modify this tf.python.keras
line to tf.keras.backend
In addition, don't forget to upgrade tensorflow
:
pip install -U tensorflow
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.