标签:sea 数据集 kernel size 爬取 处理 style rop ==
1.手写数字数据集
2.图片数据预处理
3.设计卷积神经网络结构
# 导入相关包 # sequential设计层数 from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense,Dropout,Flatten,Conv2D,MaxPool2D #建立模型 model=Sequential() ks=(3,3) ips=X_train.shape[1:] #一层卷积 model.add(Conv2D(filters=16, kernel_size=ks, padding=‘same‘, input_shape=ips,activation=‘relu‘)) #池化层1 model.add(MaxPool2D(pool_size=(2,2))) model.add(Dropout(0.25)) #二层卷积 model.add(Conv2D(filters=32,kernel_size=ks,padding=‘same‘,activation=‘relu‘)) #池化层2 model.add(MaxPool2D(pool_size=(2,2))) model.add(Dropout(0.25)) #三层卷积 model.add(Conv2D(filters=64,kernel_size=ks,padding=‘same‘,activation=‘relu‘)) #四层卷积 model.add(Conv2D(filters=128,kernel_size=ks,padding=‘same‘,activation=‘relu‘)) #池化层3 model.add(MaxPool2D(pool_size=(2,2))) model.add(Dropout(0.25)) model.add(Flatten()) #平坦层 model.add(Dense(128,activation=‘relu‘)) #dense全连接层 model.add(Dropout(0.25)) model.add(Dense(10,activation=‘softmax‘)) #激活函数 softmax分类 model.summary()
Model: "sequential"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
conv2d (Conv2D) (None, 8, 8, 16) 160
_________________________________________________________________
max_pooling2d (MaxPooling2D) (None, 4, 4, 16) 0
_________________________________________________________________
dropout (Dropout) (None, 4, 4, 16) 0
_________________________________________________________________
conv2d_1 (Conv2D) (None, 4, 4, 32) 4640
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 2, 2, 32) 0
_________________________________________________________________
dropout_1 (Dropout) (None, 2, 2, 32) 0
_________________________________________________________________
conv2d_2 (Conv2D) (None, 2, 2, 64) 18496
_________________________________________________________________
conv2d_3 (Conv2D) (None, 2, 2, 128) 73856
_________________________________________________________________
max_pooling2d_2 (MaxPooling2 (None, 1, 1, 128) 0
_________________________________________________________________
dropout_2 (Dropout) (None, 1, 1, 128) 0
_________________________________________________________________
flatten (Flatten) (None, 128) 0
_________________________________________________________________
dense (Dense) (None, 128) 16512
_________________________________________________________________
dropout_3 (Dropout) (None, 128) 0
_________________________________________________________________
dense_1 (Dense) (None, 10) 1290
=================================================================
Total params: 114,954
Trainable params: 114,954
Non-trainable params: 0
_________________________________________________________________
4.模型训练
5.模型评价
补交以前的一份作业
因为爬取天气数据用了很长时间。网址:https://www.cnblogs.com/ccla/p/12732967.html
标签:sea 数据集 kernel size 爬取 处理 style rop ==
原文地址:https://www.cnblogs.com/ccla/p/13125277.html