【问题标题】:UnimplementedError: "Cast string to float is not supported" | Function call stack: predict_functionUnimplementedError:“不支持将字符串转换为浮点数” |函数调用栈:predict_function
【发布时间】:2021-08-27 03:54:27
【问题描述】:

我正在尝试进行多变量时间序列预测,但是当我调用 model.predict(input_x, verbose=1) 时它会返回

UnimplementedError:  Cast string to float is not supported
     [[node sequential_5/Cast (defined at <ipython-input-6-ebf024c56d89>:111) ]] [Op:__inference_predict_function_78009]

Function call stack:
predict_function

但是,当我打印出 input_xtype(input_x) 时,我得到了

[[['Signal_1']
  ['Signal_2']
  ['Signal_3']
  ['Signal_4']
  ['Signal_5']]]
<class 'numpy.ndarray'>

根据Tensorflow documentation,这应该是可接受的输入形式:

输入样本。它可能是: 一个 Numpy 数组(或类似数组),或一个数组列表(如果模型有多个输入)

【问题讨论】:

  • 你确定输入的是数字
  • “Signal_1”代表什么?只是一个字符串?还是应该是数组名甚至文件名?
  • 信号 1-5 的名称是我要使用的 CSV 数据的列名

标签: python numpy tensorflow machine-learning numpy-ndarray


【解决方案1】:

输入必须是整数数组,您需要将字符串输入编码为整数

【讨论】:

    猜你喜欢
    • 2020-08-11
    • 1970-01-01
    • 1970-01-01
    • 2019-03-02
    • 2017-03-04
    • 2011-11-25
    • 2022-06-28
    • 1970-01-01
    • 2014-09-25
    相关资源
    最近更新 更多