我尝试过重新塑造它,但出现了错误。在使用RNN之前,我必须先重新塑造它。有什么建议吗?
X_train=np.reshape(Y,(Y.shape[0],Y.shape[1],1))
IndexError: 元组索引超出范围 数据集
回答:
你的数据集很可能是1D的,不是2D的。你的代码在2D数据上运行得很好:
import numpy as npY = np.random.rand(3, 4)print(Y)Y = np.reshape(Y, (Y.shape[0], Y.shape[1], 1))print(Y)
结果是
[[0.94716449 0.46469876 0.74290887 0.11051443] [0.31187829 0.26831897 0.37580931 0.23038081] [0.46578756 0.81175453 0.98348175 0.02975313]]
[[[0.94716449] [0.46469876] [0.74290887] [0.11051443]] [[0.31187829] [0.26831897] [0.37580931] [0.23038081]] [[0.46578756] [0.81175453] [0.98348175] [0.02975313]]]