Conv1D卷积自动编码器,用于Keras中的文本



我如何解决此问题

valueerror:检查目标时错误:预期的cond-decode3具有形状(无,14、300(,但具有形状的数组(6559,16,300(

NUM_WORDS = 3
pool_size = 2
x = Input(shape=(16, 300), name="input")
h = x
h = Conv1D(filters=300, kernel_size=NUM_WORDS,
             activation="relu", padding='same', name='Conv1')(h)
h = MaxPooling1D(pool_size=pool_size, name='Maxpool1')(h)
h = Conv1D(filters=150, kernel_size=NUM_WORDS,
             activation="relu", padding='same', name='Conv2')(h)
h = MaxPooling1D(pool_size=pool_size,  name="Maxpool2")(h)
h = Flatten() (h)
h = Dense(10, name='embedding') (h)
y = h
y = Dense(600, activation="relu") (y)
y = Reshape((4, 150)) (y)
y = Conv1D(filters=150, kernel_size=NUM_WORDS,
             activation="relu", padding='same', name='conv-decode1')(y)
y = UpSampling1D(size=pool_size, name='upsampling1')(y)
y = Conv1D(filters=300, kernel_size=NUM_WORDS,
             activation="relu", padding='same', name='conv-decode2')(y)
y = UpSampling1D(size=pool_size, name='upsampling2')(y)

return Model(inputs=x, outputs=y, name='AE'), Model(inputs=x, outputs=h, name='encoder')

您还有这个问题吗?您的1D AE不包含该层的定义:conv-decode3

我刚刚添加了汇编并打印了模型 - 对MEE看起来不错 - 输入形状等于输出形状。Jan

y = UpSampling1D(size=pool_size, name='upsampling2')(y)
autoencoderM = Model(x, y)
myLoss='mean_squared_error'
autoencoderM.compile(optimizer='adadelta', loss=myLoss)
autoencoderM.summary() # will print


图层(类型(输出形状param#

输入(inputlayer((无,16,300(0


conv1(conv1d((无,16,300(270300


。。。


conv-decode2(conv1d((无,8,300(135300


UPSMPLING2(UPSampling1d((无,16,300(0

总参数:621,010

相关内容

  • 没有找到相关文章

最新更新