Train an Image Classifier using Keras.

栏目: IT技术 · 发布时间: 4年前

内容简介:I have used sequential API to stack multiple layers of convolution, max-pooling layers with a flatten as well as some dense layers.I strongly recommend you to first build your basics of the working of CNN and get used to all the terminologies that are comm

I have used sequential API to stack multiple layers of convolution, max-pooling layers with a flatten as well as some dense layers.

I strongly recommend you to first build your basics of the working of CNN and get used to all the terminologies that are common in CNNs.

Let’s look at the architecture in detail.

The first layer is a Convolutional Layer that will take an image as an input of size (300 * 300* 3). Then using the activation argument we can apply different activation functions like ‘relu’, ‘tanh’, ‘sigmoid’, ‘softmax’ e.t.c, here I have applied ‘relu’ activation function.

Let’s talk about the number and size of the filters in the first layer we have used.

Through a Kernel size parameter, we could set the size of the filter as we have set it as (5*5), and using filters parameter we could set the number of filters we want to use and in our architecture, it is set to 32.

Now the second layer is a Maxpooling layer that can be applied simply by calling the MaxPooling2D function.

Similarly the third and the fourth layers are the Convolutional and the Maxpooling layers respectively.

Now we’ll flatten out the feature map using flatten function so that we could use those extracted features as an input to the Multi-Layer Perceptron for the classification.

After flattening out the feature map I have used 3 hidden layers that have 128, 64, and 32 number of neurons respectively.

You could build these hidden layers easily with the help of the Dense() method, also you could pass the activation function that you want to apply.

In the end, the last layer also called an Output layer has 2 neurons that give out the likelihood of two classes.

Check that I have used the Softmax activation function in the last layer as it converts the final information in the probability distribution for multiple classes.

Now let’s see the summary of our model using a summary() method.


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

程序员代码面试指南:IT名企算法与数据结构题目最优解

程序员代码面试指南:IT名企算法与数据结构题目最优解

左程云 / 电子工业出版社 / 2015-9 / 79.00元

这是一本程序员面试宝典!书中对IT名企代码面试各类题目的最优解进行了总结,并提供了相关代码实现。针对当前程序员面试缺乏权威题目汇总这一痛点,本书选取将近200道真实出现过的经典代码面试题,帮助广大程序员的面试准备做到万无一失。“刷”完本书后,你就是“题王”!__eol__本书采用题目+解答的方式组织内容,并把面试题类型相近或者解法相近的题目尽量放在一起,读者在学习本书时很容易看出面试题解法之间的联......一起来看看 《程序员代码面试指南:IT名企算法与数据结构题目最优解》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具