且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Keras上的损失层使用两个输入层和numpy操作

更新时间:2023-12-03 10:56:04

否,执行梯度下降需要使用梯度,因此,与只有符号损失的数字损失相比,如果您只有数值损失,则无法进行微分.通过Keras.

No, gradients are needed to perform gradient descent, so if you only have a numerical loss, it cannot be differentiated, in contrast to a symbolic loss that is required by Keras.

您唯一的机会是使用keras.backend函数来实现损失,或者使用另一个可以让您手动指定梯度的深度学习框架.您仍然需要以某种方式计算梯度.

Your only chance is to implement your loss using keras.backend functions or to use another Deep Learning framework that might let you specify the gradient manually. You still would need to compute the gradient somehow.