Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 预测股票价格时的LSTM形状误差_Python_Tensorflow - Fatal编程技术网

Python 预测股票价格时的LSTM形状误差

Python 预测股票价格时的LSTM形状误差,python,tensorflow,Python,Tensorflow,我正在学习如何用张量流预测股票价格的教程。 但每次我运行我的脚本,我总是得到一个形状错误 Traceback (most recent call last): File "main.py", line 38, in <module> model.add(LSTM(units=50, return_sequences=True, input_shape=(x_train.shape[1], 1))) AttributeError: 'list' obje

我正在学习如何用张量流预测股票价格的教程。 但每次我运行我的脚本,我总是得到一个形状错误

Traceback (most recent call last):
  File "main.py", line 38, in <module>
    model.add(LSTM(units=50, return_sequences=True, input_shape=(x_train.shape[1], 1)))
AttributeError: 'list' object has no attribute 'shape'
回溯(最近一次呼叫最后一次):
文件“main.py”,第38行,在
add(LSTM(单位=50,返回序列=True,输入形状=(x\u train.shape[1],1)))
AttributeError:“列表”对象没有属性“形状”
我知道stackoverflow上有一些类似的答案,但老实说,我是ML的新手,所以我对给出的答案没什么意义

完整代码如下:
神经网络的输入必须是一个numpy数组。似乎您正在尝试输入python列表。 要将列表转换为numpy数组,请执行以下操作:

nparray = np.array(python_list)
用输入和答案来做。(x_列车和y_列车)。在代码中,您只是将测试数据转换为numpy数组


它给出了一个错误,因为x_train.shape[1]不存在。Python列表没有“shape”属性,numpy数组有。

x\u train
一个
list
对象吗?谢谢,我找到了