【发布时间】:2020-02-21 01:58:44
【问题描述】:
我正在努力使 LSTM 工作。我在 Stack Overflow 上发现了一个问题:
Neural Network LSTM input shape from dataframe
这似乎对我有所帮助,但实际上我遇到了另一个问题:无法重塑数据,但我按照“指令”执行所有步骤。
我有 48 行 × 22 列的数据集,其中第一列是日期。标签列与该数据集分离。所以我有 21 个预测特征。
但是当我这样做时
# Extract your training data
X_train_init = np.asarray(DF.padded_input_vectors)
print(X_train_init.shape)
# Use hstack to and reshape to make the inputs a 3d vector
X_train = np.hstack(X_train_init).reshape(len(DF),max_sequence_length,21)
y_train = np.hstack(np.asarray(train_target)).reshape(len(DF),1)
我明白了:
(48,)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-14-ea37bd9226df> in <module>
3 print(X_train_init.shape)
4 # Use hstack to and reshape to make the inputs a 3d vector
----> 5 X_train = np.hstack(X_train_init).reshape(len(DF),max_sequence_length,21)
6 y_train = np.hstack(np.asarray(train_target)).reshape(len(DF),1)
ValueError: cannot reshape array of size 48 into shape (48,48,21)
【问题讨论】:
标签: python tensorflow lstm