当前位置:网站首页>21 Days of Deep Learning - Convolutional Neural Networks (CNN): Clothing Image Classification (Day 3)
21 Days of Deep Learning - Convolutional Neural Networks (CNN): Clothing Image Classification (Day 3)
2022-08-05 09:14:00 【Qingyuan Warm Song】
Table of Contents
1.1 Image input form of convolutional neural network
1.3 class_names[np.argmax(pre[1])]
First, new learning
1.1 Image input form of convolutional neural network
The input of the convolutional neural network (CNN) is in the form of a tensor (image_height, image_width,
color_channels), which contains the image height, width and color information.There is no need to enter batch size.color_channels is (R, G, B) corresponding to the three color channels of RGB respectively.In this example, our CNN input, a picture from the fashion_mnist dataset, is of shape (28, 28, 1) i.e. a grayscale image.We need to assign the shape to the parameter input_shape when declaring the first layer.
model = models.Sequential([layers.Conv2D(32, (3, 3), activation='relu', input_shape=(28, 28, 1)), #convolution layer 1, convolution kernel 3*3layers.MaxPooling2D((2, 2)), #pooling layer 1, 2*2 samplinglayers.Conv2D(64, (3, 3), activation='relu'), #Convolution layer 2, convolution kernel 3*3layers.MaxPooling2D((2, 2)), #pooling layer 2, 2*2 samplinglayers.Conv2D(64, (3, 3), activation='relu'), #Convolution layer 3, convolution kernel 3*3layers.Flatten(), #Flatten layer, connecting the convolutional layer and the fully connected layerlayers.Dense(64, activation='relu'), #Full connection layer, further feature extractionlayers.Dense(10) #Output layer, output expected result])model.summary() # print network structure
So in the convolutional layer 1, the shape value of the image should be passed in
1.2 About compilation
Before you are ready to train your model, you need to set it up a bit more.The following is added in the compilation step of the model:
(1) loss function (loss): used to measure the accuracy of the model during training.You will want to minimize this function in order to "steer" the model in the right direction.
Loss functions include predicted value and actual squared difference (binary cross entropy), mean squared difference, etc.
(2) Optimizer ((optimizer): Determines how the model is updated based on the data it sees and its own loss function.
Help update parameters in real time
(3) metrics: used to monitor training and testing steps.The following examples use accuracy, which is the ratio of images that are correctly classified.
1.3 class_names[np.argmax(pre[1])]
See below
import numpy as npa = np.array([3, 1, 2, 4, 6, 1])b=np.argmax(a)# Take out the index corresponding to the maximum value of the element in a. At this time, the maximum value is 6, and the corresponding position index value is 4, (the index value starts from 0 by default)print(b)#4
Reference: np.argmax()_wanghua609's blog-CSDN blog_np.argmax
So np.argmax(pre[1]) is the index value i of the maximum confidence of the first image in the test set for the clothing in 10
From class_names[ i ]: take out the name
边栏推荐
- 上海控安技术成果入选市经信委《2021年上海市网络安全产业创新攻关成果目录》
- 欧盟 | 地平线 2020 ENSEMBLE:D2.13 SOTIF Safety Concept(上)
- ts/js 函数传参带函数写法
- 微信小程序请求封装
- 阿里云存储的数据库是怎么自动加快加载速度的呢www.cxsdkt.cn怎么设置案例?
- thinkPHP5 realizes clicks (data increment/decrement)
- 16种香饭做法全攻略
- There is only one switch, how to realize the nqa of master-slave automatic switching
- 请问大佬们 ,使用 Flink SQL CDC 是不是做不到两个数据库的实时同步啊
- 【LeetCode】623. 在二叉树中增加一行
猜你喜欢
Creo 9.0 基准特征:基准平面
eKuiper Newsletter 2022-07|v1.6.0:Flow 编排 + 更好用的 SQL,轻松表达业务逻辑
链表中的数字相加----链表专题
sql server中 两表查询 平均数 分组
js 图形操作一(兼容pc、移动端实现 draggable属性 拖放效果)
接口全周期的生产力利器Apifox
CCVR eases heterogeneous federated learning based on classifier calibration
Comprehensively explain what is the essential difference between GET and POST requests?Turns out I always misunderstood
【Excel实战】--图表联动demo_001
How to make a puzzle in PS, self-study PS software photoshop2022, PS make a puzzle effect
随机推荐
XSS靶机通关以及XSS介绍
为什么我推荐使用智能化async?
thinkPHP5 realizes clicks (data increment/decrement)
8.4 Summary of the mock competition
Controller-----controller
JS syntax usage
ECCV 2022 Oral 视频实例分割新SOTA:SeqFormer&IDOL及CVPR 2022 视频实例分割竞赛冠军方案...
接口全周期的生产力利器Apifox
DPU — 功能特性 — 安全系统的硬件卸载
HStreamDB Newsletter 2022-07|分区模型优化、数据集成框架进一步完善
Example of Noise Calculation for Amplifier OPA855
动态内存开辟(C语言)
Two-table query average grouping in sql server
使用稀疏 4D 卷积对 3D LiDAR 数据中的运动对象进行后退分割(IROS 2022)
15.1.1、md—md的基础语法,快速的写文本备忘录
轩辕实验室丨欧盟EVITA项目预研 第一章(四)
512-color chromatogram
2.4G无线收发模块的应用
Neuron Newsletter 2022-07|新增非 A11 驱动、即将支持 OPC DA
施一公:科学需要想象,想象来自阅读