ValueError:值张量(“normalize_element/component_0:0”,shape=(),dtype=int32,device=/device:CPU:0)的列组不足以进行批处理

2024-04-18 08:22:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图用估计器进行预测,但我得到了以下错误:

ValueError: Value Tensor("normalize_element/component_0:0", shape=(), dtype=int32, device=/device:CPU:0) has insufficient rank for batching.
pred = {"Team1":10764 ,
"Team1Rank":51,
"Team1Prediction":17,
"Team2":8211,
"Team2Rank":81,
"Team2Prediction":1,
"Odds1":1.3,
"Odds2":3.2,
"BestOf":3
}

def pred_fn(features, batch_size=960):
    db = tf.data.Dataset.from_tensor_slices((dict(features))).batch(batch_size)
    return db

predictions = classifier.predict(
    input_fn=lambda: pred_fn(pred))

print(list(predictions))

我遵循标准指南,尝试不同的事情,但没有任何效果


Tags: dbsizevaluedevice错误batchelementfn