我正在使用 Keras 构建一个 CNN,并将以下 Conv1D 作为我的第一层:
cnn.add(Conv1D(
filters=512,
kernel_size=3,
strides=2,
activation=hyperparameters["activation_fn"],
kernel_regularizer=getattr(regularizers, hyperparameters["regularization"])(hyperparameters["regularization_rate"]),
input_shape=(1000, 1),
))
我正在使用以下功能进行培训:
cnn.fit(
x=train_df["payload"].tolist(),
y=train_df["label"].tolist(),
batch_size=hyperparameters["batch_size"],
epochs=hyperparameters["epochs"],
)
其中 train_df 是一个包含两列的 pandas 数据帧,其中,对于每一行,标签是一个 int(0 或 1),有效负载是一个用零填充/截断为 1000 长度的浮点数组。 train_df 是 15641。
模型编译,但在训练期间,我收到此错误:
ValueError: Error when checking model input: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 1 array(s), but instead got the following list of 15641 arrays: [array([[0.09019608],
[0.01176471],
[0.01176471],
[0. ],
[0.30196078],
[0. ],
[0. ],
[0. ],
[0. ],
[0....
我查看了这篇文章并尝试将我的输入更改为 1000 个浮点长列表的 ndarray,但最终出现了另一个错误:
ValueError: Error when checking input: expected conv1d_1_input to have 3 dimensions, but got array with shape (15641, 1000)
有任何想法吗?