![](/img/trans.png)
[英]ValueError: Input 0 of layer max_pooling1d is incompatible with the layer: expected ndim=3, found ndim=4. Full shape received: (None, 128, 1, 32)
[英]ValueError: Input 0 of layer "max_pooling1d" is incompatible with the layer: expected ndim=3, found ndim=4. Full shape received: (None, 51644, 29, 32)
您的数据是 2D(类似图片),而您正在尝试使用接受 1D 对象(序列)的 model。 您需要使用 model 来接受您想要使用的数据类型,或者您需要转换您的数据以适合您的 model。
将input_shape
从(train_shape[0], train_shape[1], 1)
更改为(train_shape[1], 1)
。 当您使用Conv1D
时,假设您正在使用序列数据。 所以在这种情况下train_shape[0]
是batch_size
, train_shape[1]
是number of time-steps
即sequence length
,最后一个1
是每个时间戳number of features
。
重要的是, keras
不需要您输入batch_size
,它自动默认为None
并且输入形状自动变为(None, train_shape[1], 1)
,这样它就可以使用任何批量大小,所以不需要输入第一个维度。 但是,如果您想自己输入batch size
,请使用batch_input_shape
而不是input_shape
。
还要在 output 层中使用softmax
function 而不是sigmoid
,因为 output 层中有多个神经元。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.