我对Conv1D产生的输出形状有点困惑。考虑我使用的代码如下(为了清晰起见,省略了很多代码):
input_shape = x_train_2trans.shape
# (7425, 24, 1)
model.add(Conv1D(filters=4, input_shape=input_shape[1:], kernel_size=(3), activation=LeakyReLU))
model.add(Dropout(0.2))
model.add(Dense(1))我尝试了3种不同的内核大小(3、2和1 ),其中产生的输出大小为:
(256,2500,12,1),(256,2500,18,1),(256,2500,24,1)。
我感到困惑的是,内核大小的每一滴都有6的差异。据我理解,对于内核大小为3的,12应该是21;而对于内核大小为2的18应该是22,这样才能适应具有指定内核大小的24的形状。
提前谢谢。
发布于 2021-08-11 02:35:57
最有可能的是,问题在于输入数据。
这是一个玩具的例子。
import numpy as np
from tensorflow.keras import layers
input = np.ones((100,24,1))
input_shape = input.shape
layer = layers.Conv1D(filters=4, input_shape=input_shape[1:], kernel_size=(2))# Kernel=2
out = layer(input)
out.shape
layer = layers.Conv1D(filters=4, input_shape=input_shape[1:], kernel_size=(4))# Kernel=4
out = layer(input)
out.shape输出- TensorShape(100、23、4) TensorShape(100、21、4)
https://datascience.stackexchange.com/questions/99857
复制相似问题