请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

but expected one of: numbers.Real

图片描述
具体问题发生在serialize_example函数中,对比了您的代码没有出现任何误差,但是无法复现…在这一节的回答列表中您提到在Ubuntu上运行没有问题,但是在Windows中有无解决方案?

正在回答 回答被采纳积分+3

3回答

陶丽丹 2022-03-10 12:02:11

def serialize_example(x, y):

    '''Converts x, y to tf.train.Example and serialize'''

    x = x.numpy()

    y = y.numpy()

    features = tf.train.Features(

        feature = {

            "inputs_features": tf.train.Feature(float_list = tf.train.FloatList(value = x)),

            "label": tf.train.Feature(float_list = tf.train.FloatList(value = y)),

            "shape": tf.train.Feature(int64_list = tf.train.Int64List(value = x.shape))

        }

    )

    example = tf.train.Example(features = features)

    return example.SerializeToString()


# 不知道为啥,这样就能行了

0 回复 有任何疑惑可以回复我~
z1121532091 2021-04-24 18:26:53

在windows环境下遇到了同样的问题,搜了一下应该是在Win10下使用python3.8就会有这样的bug,换成3.7可以运行:https://github.com/tensorflow/tensorflow/issues/41304

0 回复 有任何疑惑可以回复我~
正十七 2021-03-21 23:56:22

抱歉同学,这个问题我还真无法回答,因为咱们的代码确实没有在windows上测试过,搜了一番,只找到这个相关问答:https://stackoverflow.com/questions/54441603/tensorflow-error-has-type-list-but-expected-one-of-int-long-float

0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号