在keras自定义损失中使用图层输出
Use layer output in keras custom loss
我正在Keras中开发一个自定义损失函数,我需要第一层输出。
如何找回?
def custom_loss(y_true, y_pred):
cross = K.mean(K.binary_crossentropy(y_true, y_pred), axis = 1)
layer_output = model.get_layer_output(1) # this is what i'd like to use
return cross + perturb
我正在Keras中开发一个自定义损失函数,我需要第一层输出。
如何找回?
def custom_loss(y_true, y_pred):
cross = K.mean(K.binary_crossentropy(y_true, y_pred), axis = 1)
layer_output = model.get_layer_output(1) # this is what i'd like to use
return cross + perturb