简体   繁体   English

Keras 中用于图像分类的 CNN 类型是什么?

[英]What is the type of CNN that is used in Keras for image classification?

I have a CNN architecture that I train to recognize some objects that I need to eventually use in real time and then use the output of detected objects for further work.我有一个 CNN 架构,我训练它来识别我最终需要实时使用的一些对象,然后使用检测到的对象的输出进行进一步的工作。 I have two questions regarding this that I need to have answered to evaluate the next step I need to make:我有两个与此相关的问题,我需要回答这些问题以评估我需要执行的下一步:

  1. As I studied CNN more, I found that there are different types of CNN such as faster CNN.随着我对 CNN 的研究越来越多,我发现有不同类型的 CNN,例如更快的 CNN。 So i want to know what type of architecture does Keras use when using its conv2d functions (I will provide a code for my CNN architecture below)所以我想知道 Keras 在使用其 conv2d 函数时使用什么类型的架构(我将在下面提供我的 CNN 架构的代码)

  2. The produced model helps me identify whether the object I am looking for is in the image or not, but I am looking to also find the region of the prediction in the image.生成的模型帮助我确定我正在寻找的对象是否在图像中,但我还希望在图像中找到预测区域。 Is this possible using this same architecture or do I need to use something else like YOLO?这可以使用相同的架构还是我需要使用其他类似 YOLO 的东西?


classifier = Sequential()

classifier.add(Conv2D(32, (3, 3), input_shape= (128, 128, 3), activation = 'relu' ))

classifier.add(MaxPooling2D(pool_size = (2, 2)))

classifier.add(Conv2D(64, (3, 3), activation = 'relu' ))
classifier.add(MaxPooling2D(pool_size = (2, 2)))

classifier.add(Conv2D(128, (3, 3), activation = 'relu' ))
classifier.add(MaxPooling2D(pool_size = (2, 2)))

classifier.add(Flatten())

classifier.add(Dense(units = 128, activation = 'relu'))
classifier.add(Dense(units = 1, activation = 'sigmoid'))

classifier.compile(optimizer = 'adam', loss = 'binary_crossentropy', metrics = ['accuracy'])

EDIT: To be more specific, i want to know if what tensorflow or whatever backend keras is using provide a base CNN and the way we define the architecture is what define what type of CNN we are using such as regional CNN, fast CNN or faster CNN?编辑:更具体地说,我想知道是否使用 tensorflow 或任何后端 keras 提供基础 CNN,我们定义架构的方式是定义我们使用的 CNN 类型,例如区域 CNN、快速 CNN 或更快美国有线电视新闻网? or is it something defined at a different level?或者它是在不同级别定义的?

I hope i made myself clear.我希望我说清楚了。

Regarding your first question: Keras is "just" a common API which can be used with different backends, namely TensorFlow, Theano, or CNTK.关于您的第一个问题:Keras “只是”一个通用 API,可用于不同的后端,即 TensorFlow、Theano 或 CNTK。

Keras defines a number of different convolutional layers in layers.convolutional , all of which are documented here . layers.convolutionallayers.convolutional定义了许多不同的卷积层,所有这些都记录在此处 Since you are using TensorFlow as your backend, you can have a look at backend.tensorflow_backend to find out which TensorFlow layers Keras is using.由于您使用 TensorFlow 作为后端,您可以查看backend.tensorflow_backend以了解 Keras 正在使用哪些 TensorFlow 层。

However, note that R-CNN, Fast R-CNN etc. are not special types of convolutional layers, but CNN architectures (just as YOLO is).但是,请注意 R-CNN、Fast R-CNN 等不是特殊类型的卷积层,而是 CNN 架构(就像 YOLO 一样)。 You can find out more about the general architectures in this blog post .您可以在这篇博文中找到有关一般架构的更多信息 You can find a Keras implementation of R-CNN on GitHub .您可以在 GitHub 上找到R-CNN 的 Keras 实现。

Regarding your second question: Your model works solely as an object detector.关于您的第二个问题:您的模型仅用作对象检测器。 To identify where in the image your object is placed, you will indeed need a different architecture.为了识别图像中的物体放置,你确实需要一个不同的架构。 Also, your training data will need to provide the object location.此外,您的训练数据将需要提供对象位置。

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

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