XMing666
2020-04-28 09:58TensorFlow2.0 编写的 tensor 转 example 的函数出现类型问题
相关代码:
# 将 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)>
- 点赞
- 回答
- 收藏
- 复制链接分享
0条回答
为你推荐
- 使用tensor做BP算法后出现错误,求助大佬!!
- tensorflow
- 1个回答
- 请求大神帮帮我,加载MNIST数据集后,显示IndexError: too many indices for tensor of dimension 0
- 深度学习
- 神经网络
- 机器学习
- 人工智能
- 2个回答
- 转到uint8到float32
- math
- 1个回答
- Golang Model sessionn上的Tensorflow运行错误:nil-Operation。 如果输出是使用Scope对象创建的,请参见Scope.Err()了解详细信息
- tensorflow
- 2个回答
- tensorflow.GraphDef was modified concurrently during serialization
- 深度学习
- 人工智能
- tensorflow
- python
- 机器学习
- 2个回答
换一换