Python 3.x ValueError:未知损耗函数:三重态_损耗

Python 3.x ValueError:未知损耗函数:三重态_损耗,python-3.x,tensorflow,Python 3.x,Tensorflow,尝试将模型转换为tflite或.pb文件时出现以下错误: ValueError:未知损耗函数:三重态_损耗 我检查了StackOverflow和GitHub中发布的不同解决方案,但它们都不适用于我的代码 #calculates triplet loss def triplet_loss(y_true, y_pred, alpha = 0.2): anchor, positive, negative = y_pred[0], y_pred[1], y_pred[2] # tri

尝试将模型转换为tflite或.pb文件时出现以下错误:

ValueError:未知损耗函数:三重态_损耗

我检查了StackOverflow和GitHub中发布的不同解决方案,但它们都不适用于我的代码

#calculates triplet loss
def triplet_loss(y_true, y_pred, alpha = 0.2):

    anchor, positive, negative = y_pred[0], y_pred[1], y_pred[2]

    # triplet loss formula 
    pos_dist = tf.reduce_sum( tf.square(tf.subtract(anchor, positive)) )
    neg_dist = tf.reduce_sum( tf.square(tf.subtract(anchor, negative)) )
    basic_loss = pos_dist - neg_dist + alpha
    loss = tf.maximum(basic_loss, 0.0)
    return loss

# load the model    
model = load_model('facenet_model/model.h5', custom_objects={'triplet_loss': triplet_loss})
我相信我必须对三重态损失函数进行一些修改,以解决值错误