简体   繁体   English

如何将从 cnn 密集层提取的特征传递给另一个 cnn?

[英]How to pass feature extracted from cnn dense layer to another cnn?

I implemented a cnn-1 for multi-label image classification.我实现了一个用于多标签图像分类的 cnn-1。 Then i extracted features from the dense layer and got a shape.然后我从密集层中提取特征并得到一个形状。 [600,1024] [600,1024]

600 = total images 600 = 总图像

I used PCA on this and got shape [600,1].我对此使用了 PCA 并得到了 [600,1] 的形状。

Now i passed this to svm and accuracy is very low 20%.现在我将其传递给 svm,准确率非常低 20%。

I wanna pass this to a cnn and check accuracy.我想将其传递给 cnn 并检查准确性。 Kindly plz help me.请帮助我。

There are many things you may have to reconsider.您可能需要重新考虑很多事情。 First of all, PCA is supposed to come up with a single number that has to carry the burden of representing your 1024 numbers.首先,PCA 应该提出一个必须承担表示 1024 个数字的负担的数字。 That is astronomically difficult, you may have to reconsider projecting your data to such low dimensionality.这在天文学上是困难的,您可能不得不重新考虑将数据投影到如此低的维度。 CNNs will never work with a single number as input. CNN 永远不会使用单个数字作为输入。 To answer your comment, to pass cnn1 features to cnn2 you do not flatten your vectors (meaning you will not have an output of shape (600, 1024) rather a number like (600,3,32,32) where 3 represents the input filters (ie R GB in pictures with color and these 32s represent in 2D case --since you mentioned image classification I assume 2D convs-- the image size). Covolutional layers allow you to define the output filters. That is the second number in our example. The image size after the convolution depends on other parameters such as kernel size and stride, don't worry about it for now. The point being is that if you want your image to go through a second conv layer after your first, you need to make sure your second conv layer accepts as input filters the output filters of the first conv layer. That's all I can tell you based on the data I was provided. Once again, using PCA to go from dimensionality 1024 to dimensiona要回答您的评论,要将 cnn1 功能传递给 cnn2,您不会展平您的向量(这意味着您不会拥有形状为 (600, 1024) 的 output,而是像 (600,3,32,32) 这样的数字,其中 3 代表输入过滤器(即彩色图片中的 R GB,这些 32 代表二维情况——因为你提到图像分类,我假设二维转换——图像大小)。卷积层允许你定义 output 过滤器。这是第二个数字我们的示例。卷积后的图像大小取决于其他参数,例如 kernel 大小和步幅,现在不要担心。关键是,如果您希望图像在第一个之后通过第二个卷积层变为 go,你需要确保你的第二个conv层接受第一个conv层的output过滤器作为输入过滤器。这就是我根据我提供的数据可以告诉你的全部。再一次,使用PCA从维度1024到维度go lity 1 is not recommended, at least not by me.不推荐 lity 1,至少我不推荐。

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

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