简体   繁体   English

如何将从 ccn1 提取的特征传递给另一个 cnn2?

[英]How to pass features extracted from ccn1 to another cnn2?

i made a cnn and from the third conv layer i extracted the features so that the shape is (600,12,12,128)我制作了一个 cnn 并从第三个 conv 层提取了特征,使得形状为 (600,12,12,128)

600 = training images 12x12128 = for a single image 600 = 训练图像 12x12128 = 对于单个图像

Now i want to pass these to another cnn2 as an input But i want the input shape to be (600,12,12,1).现在我想将这些作为输入传递给另一个 cnn2 但我希望输入形状为 (600,12,12,1)。

How to change the shape?如何改变形状?

Try with Lambda layer in order to slice the output tensor from cnn1:尝试使用Lambda 层,以便从 cnn1 中切出 output 张量:

model=models.Sequential()

model.add(cnn1)

model.add(Lambda(lambda x : x[:,:,i])) # with 0 <= i < 128

model.add(cnn2)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM