我正在尝试在自定义 keras 损失函数中将Tensor转换为numpy数组,但是下面出现错误。
AttributeError:“ Tensor”对象没有属性“ _numpy”
这是我的自定义损失函数,
def custom_loss(y_true, y_pred):
true_np = K.eval(y_true) # <- I want to convert "y_true" to numpy array
pred_np = K.eval(y_pred) # <- I want to convert "y_pred" to numpy array
...
return
在自定义损失中,“ y_true”和“ y_test”的类型为 Tensor ,但是我猜K.eval()只能转换 Easer Tensor 。
但是,我找不到将Tensor转换为Eager Tensor的方法...
任何人都不知道吗?