相关代码:
# 将 tensor 的 xy 数据转化成 example 中的数据,并进行序列化
def serialize_example(x, y):
"""Converts x, y to tf.train.Example and serialize"""
input_features = tf.train.FloatList(value = x)
label = tf.train.FloatList(value = y)
features = tf.train.Features(
feature = {
"input_features": tf.train.Feature(
float_list = input_features),
"label": tf.train.Feature(float_list = label)
}
)
example = tf.train.Example(features = features)
return example.SerializeToString()
TypeError: <tf.Tensor: id=249, shape=(), dtype=float32, numpy=0.63034356> has type <class 'tensorflow.python.framework.ops.EagerTensor'>, but expected one of: numbers.Real
数据类型<DatasetV1Adapter shapes: ((None, 8), (None, 1)), types: (tf.float32, tf.float32)>