我有一个神经网络,它接受输入I并输出一个实向量W。对于某些特定情况,我需要向W添加一个符号函数,然后将其输入到损失函数中来计算我的损失。即:
W = NN(I); #the output of the neural network
W = sign(W); #can be realized by the Lambda layer in keras
loss = loss_func(W) #compute the loss with the result after sign function
是的,这真的很奇怪,但在我的工作中是必要的。在我之前的工作中,没有sign函数,它工作得很好。但是