【问题标题】:HSTACK CNN output with Lambda function带有 Lambda 函数的 HSTACK CNN 输出
【发布时间】:2018-02-16 17:21:30
【问题描述】:

我制作了一种使用CNNLSTMNN 呈现here

CNN 层之后,我使用Lambda 函数将每个过滤器(在CNN 创建的图像)一个接一个地提供给一个LSTM

现在我想更改它以将所有 Filters 水平连接在一起的 LSTM 提供给 LSTM。

我见过一些水平连接图像的代码,例如:

images = encoded_imgs[0,:,:,:] // eg: first output of a CNN layer

print(images[1,1,:].size)

image=images[:,:,0]
for i in range(1,10):
    image=hstack((image,images[:,:,i]))   

但我如何将它应用到 lambda 函数以更改我的示例以将所有内容输入到一个 LSTM 中?

【问题讨论】:

    标签: python tensorflow keras conv-neural-network lstm


    【解决方案1】:

    好的,我设法在 lambda 函数之后使用合并 concat 轴 2 来“个性化”每个“过滤图像”

            conv2=Conv2D(filters,(3,3), padding="same")(conv1)
            conv2=AveragePooling2D(pool_size=(2, 1), strides=(1, 1))(conv2)
            conv2=Activation("relu")(conv2)
            channels=Dropout(0.40)(conv2)
            filtersVec=[]
            for x in range(0,filters):
                filterImg=Lambda(lambda element : element[:,x,:,:])(channels)              
                filtersVec.append(filterImg)
            merged = merge(filtersVec, mode='concat',concat_axis=2)
            lstm=Bidirectional(LSTM(20),merge_mode='concat',dropout=0.35)(merged)
            classificationLayer=Dense(classes)(lstm)
            classificationLayer=Activation("softmax")(classificationLayer) 
    

    【讨论】:

      猜你喜欢
      • 2021-12-16
      • 1970-01-01
      • 2022-04-11
      • 1970-01-01
      • 1970-01-01
      • 2019-05-19
      • 2023-01-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多