简体   繁体   English

Keras CNN错误conv1d_13层的输入0与层不兼容::预期min_ndim=3,发现ndim=2

[英]Keras CNN error Input 0 of layer conv1d_13 is incompatible with the layer: : expected min_ndim=3, found ndim=2

I have dataset 9 columns.我有数据集 9 列。 Column 1-8 is feature, column 9 is class of dataset.第 1-8 列是特征,第 9 列是数据集的类别。 I use CNN to classify like this code.我使用 CNN 来分类这样的代码。

model = Sequential()
model.add(Conv1D(64, 2, activation="relu", input_shape=(8,1)))
model.add(Flatten())

model.add(Dense(1, activation='sigmoid'))
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
model.fit(X, y, epochs=150, batch_size=10)

It show error like this.它显示这样的错误。

ValueError: Input 0 of layer conv1d_13 is incompatible with the layer: : expected min_ndim=3, found ndim=2. Full shape received: (None, 8)

How to fix it?如何解决?

Try:尝试:

X = X[..., None]

to add an additional dimension to X .X添加一个额外的维度。 See also this .另请参阅

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Keras Conv1D ValueError:层顺序的输入 0 与层不兼容::预期 min_ndim=3,发现 ndim=2 - Keras Conv1D ValueError: Input 0 of layer sequential is incompatible with the layer: : expected min_ndim=3, found ndim=2 Keras Conv2D - ValueError:层序的输入 0 与层不兼容::预期 min_ndim=4,发现 ndim=3 - Keras Conv2D - ValueError: Input 0 of layer sequential is incompatible with the layer: : expected min_ndim=4, found ndim=3 Keras Conv1d输入形状问题,conv1d层的输入0与层不兼容::预期min_ndim=3,发现ndim=2 - Keras Conv1d input shape problem, Input 0 of layer conv1d is incompatible with the layer: : expected min_ndim=3, found ndim=2 ValueError: 层 conv1d 的输入 0 与层不兼容: : 预期 min_ndim=3, 发现 ndim=2 - ValueError: Input 0 of layer conv1d is incompatible with the layer: : expected min_ndim=3, found ndim=2 在 Tensorflow 中创建 model 时出错。 ValueError: 层 conv2d_1 的输入 0 与层不兼容: : 预期 min_ndim=4, 发现 ndim=3 - Error with creating a model in Tensorflow. ValueError: Input 0 of layer conv2d_1 is incompatible with the layer: : expected min_ndim=4, found ndim=3 ValueError:conv2d 层的输入 0 与层不兼容::预期 min_ndim=4,发现 ndim=3。 收到的完整形状:(2240、70、3) - ValueError: Input 0 of layer conv2d is incompatible with the layer: : expected min_ndim=4, found ndim=3. Full shape received: (2240, 70, 3) ValueError:层“conv2d”的输入 0 与层不兼容:预期 min_ndim=4,发现 ndim=3。 收到的完整形状:(28、28、1) - ValueError: Input 0 of layer "conv2d" is incompatible with the layer: expected min_ndim=4, found ndim=3. Full shape received: (28, 28, 1) 层“conv2d”的输入 0 与层不兼容:预期 min_ndim=4,发现 ndim=3。 收到的完整形状:(32、28、28) - Input 0 of layer "conv2d" is incompatible with the layer: expected min_ndim=4, found ndim=3. Full shape received: (32, 28, 28) 层 conv1d_39 的输入 0 与层不兼容::预期 min_ndim=3,发现 ndim=2。 收到的完整形状:(无,64) - Input 0 of layer conv1d_39 is incompatible with the layer: : expected min_ndim=3, found ndim=2. Full shape received: (None, 64) 层 conv1d 的输入 0 与层不兼容::预期 min_ndim=3,发现 ndim=2。 收到的完整形状:(无,30) - Input 0 of layer conv1d is incompatible with the layer: : expected min_ndim=3, found ndim=2. Full shape received: (None, 30)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM