【发布时间】:2021-09-23 18:09:53
【问题描述】:
我正在尝试了解卷积层在神经网络中的工作原理。我为类似问题找到了两个不同的相关帖子并尝试了这些建议,但无法解决。
- Keras dimensionality in convolutional layer mismatch
- ValueError: Input 0 is incompatible with layer conv_1: expected ndim=3, found ndim=4
import tensorflow as tf
model_valid = tf.keras.Sequential([
tf.keras.layers.Flatten(input_shape=(10,)),
tf.keras.layers.Dense(16, activation='relu'),
tf.keras.layers.Conv1D(16, kernel_size=(2), activation='relu', padding='same'),
tf.keras.layers.MaxPooling1D(pool_size=(4), strides=3, padding='valid'),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(1, activation='softmax')
])
model_valid.summary()
我收到Input 0 of layer conv1d_37 is incompatible with the layer: expected ndim=3, found ndim=2. Full shape received: [None, 16] 的不兼容问题。构建卷积层时会出现问题。
【问题讨论】:
标签: python tensorflow keras neural-network conv-neural-network