当前位置:网站首页>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
边栏推荐
- 十一道家常小菜详细攻略[图文并茂]
- Science bosses say | Hong Kong rhubarb KaiBin teacher take you unlock the relationship between the matrix and 6 g
- 国际原子能机构总干事称乌克兰扎波罗热核电站安全形势堪忧
- Detailed explanation of DNS query principle
- MySQL内部函数介绍
- Creo 9.0 基准特征:基准轴
- Why is pnpm hitting npm and yarn dimensionality reduction?
- XCODE12 在使用模拟器(SIMULATOR)时编译错误的解决方法
- 嵌入式实操----基于RT1170 移植memtester做SDRAM测试(二十五)
- 链表中的数字相加----链表专题
猜你喜欢
随机推荐
openpyxl操作Excel文件
Two-table query average grouping in sql server
六年团队Leader实战秘诀|程序员最重要的八种软技能 - 脸皮薄容易耽误事 - 自我营销
2022.8.3
seata源码解析:事务状态及全局锁的存储
XSS靶机通关以及XSS介绍
ECCV 2022 Oral Video Instance Segmentation New SOTA: SeqFormer & IDOL and CVPR 2022 Video Instance Segmentation Competition Champion Scheme...
tensorflow.keras无法引入layers
【 a daily topic 】 1403. The increasing order of the sequence, boy
leetcode refers to Offer 10- II. Frog jumping steps
IT研发/开发流程规范效能的思考总结
16 kinds of fragrant rice recipes
树状数组模版+例题
放大器OPA855的噪声计算实例
Undefined symbols for architecture arm64解决方案
tear apart loneliness
科普大佬说 | 港大黄凯斌老师带你解锁黑客帝国与6G的关系
Why is pnpm hitting npm and yarn dimensionality reduction?
MySQL内部函数介绍
动态库之间回调函数使用