我正在为我的 tflearn 模型创建一个自定义目标函数。目标函数很复杂,需要我迭代预测和正确的输出,并添加不基于索引的某些部分。我找不到使它与张量数据类型一起工作的方法。
我使用下面的标准列表编写了一个版本。
errorBuild = 0
errorCheck = 0
def CustomLoss(y_pred, y_true):
for value, index in enumerate(y_true):
if y_true[index] == 0:
errorBuild += y_pred[index]
else:
errorBuild += y_pred[index] - y_true[index]
errorCheck += math.abs(errorBuild)
return errorCheck
似乎没有办法遍历张量的各个值。我应该在目标函数中创建一个新会话并评估张量吗?
我在这里先向您的帮助表示感谢