我正在为二进制分类问题编写自定义指标。 该函数已执行,但是我有两个问题: -如果测试总是评估为true -我无法显示张量的值来对其进行调试
RETURNS是全局定义的一维数组
def total_winning(y_true, y_pred):
sess = K.get_session()
ze_zum = 0.0
for i in range(len(RETURNS)):
val = K.gather(y_pred,i)
val2 = RETURNS[i]
val = K.print_tensor(val, message='val = ')
#print( str(val.eval(session=sess)))
if (K.greater(val[0], 0.5)) is not None:
print( "Greater")
val3 = val2
else:
print( "Smaller")
val3 = 0
ze_zum = ze_zum + val3
return K.variable(value=ze_zum, dtype='float64' )
我想保持循环进行更复杂的测试
问题:
我尝试调试的东西
InvalidArgumentError(请参阅上面的回溯):您必须提供一个值 用于dtype float和shape的占位符张量'dense_1_input' [?,30] [[{{node density_1_input}} = Placeholderdtype = DT_FLOAT, 形状= [?, 30], _device =“ / job:localhost / replica:0 / task:0 / device:GPU:0”]] [[{{节点指标/ total_winning / embedding_lookup / _29}} = _Recvclient_terminated = false,recv_device =“ / job:localhost /副本:0 / task:0 / device:CPU:0”, send_device =“ / job:localhost /副本:0 / task:0 / device:GPU:0”, send_device_incarnation = 1, tensor_name =“ edge_33_metrics / total_winning / embedding_lookup”, tensor_type = DT_FLOAT, _device =“ / job:localhost /副本:0 /任务:0 /设备:CPU:0”]]