一、模型
可调整的预处理层卷积核大小
1.主模型
from keras import layers, Sequential, Model
from keras.layers import Conv2D, BatchNormalization, ReLU,MaxPool2D,Layer,GlobalAvgPool2D,Dense,Input
class ResNet18(Model):
def __init__(self, class_num,in_shape, pre_filter_size=7):
"""
:param in_shape: the shape of each example
:param class_num: the number of classes
:param pre_filter_size: the size of filters in the preprocessing layer
"""
super().__init__()
# preprocessing layer
self.pl = Sequential([
Conv2D(64,(pre_filter_size,pre_filter_size),strides=2,padding='same'),
BatchNormalization(),
ReLU(),
MaxPool2D(pool_size=(3,3),strides=2,padding='same')
])
self.input_layer = Input(in_shape) # used to reveal output shape
# Residual Blocks
self.block1 =