【发布时间】:2021-01-05 17:20:54
【问题描述】:
我正在尝试将pandas DataFrame 正确地塑造成与Keras 的方法timeseries_dataset_from_array() 兼容的格式。主要问题在于数据集中的大量特征,这意味着要使用 for 循环:
x_reshaped = [tf.reshape(x_train.iloc[:-seq_length, column].values, (-1, 1))
for column in range(len(x_train.columns))]
当我跑步时:
tf.keras.preprocessing.timeseries_dataset_from_array(x_reshaped, y_reshaped,
sequence_length=seq_length,
batch_size=bs)
我收到此错误消息AttributeError: 'list' object has no attribute 'shape',因为x_reshaped 被视为向量的列表,而不是矩阵。
我也试过用tf.TensorArray()创建训练矩阵,但是没用。
【问题讨论】:
标签: python pandas tensorflow keras tf.keras