使用keras实现Inception结构 发表于 2019-04-16 | 分类于 ML/DL Inception结构 代码12345678910111213141516171819202122232425262728import kerasfrom keras.layers import Input, Conv2D, MaxPooling2Dfrom keras.models import Model# 定义输入图像尺寸inputs = Input(shape=(256, 256, 3))# 定义第一个分支tower_1 = Conv2D(64, (1, 1), padding='same', activation='relu')(inputs)# 定义第二个分支tower_2 = Conv2D(64, (1, 1), padding='same', activation='relu')(inputs)tower_2 = Conv2D(64, (3, 3), padding='same', activation='relu')(tower_2)# 定义第三个分支tower_3 = Conv2D(64, (1, 1), padding='same', activation='relu')(inputs)tower_3 = Conv2D(64, (5, 5), padding='same', activation='relu')(tower_3)# 定义第四个分支tower_4 = MaxPooling2D((3, 3), strides=(1, 1), padding='same')(inputs)tower_4 = Conv2D(64, (1, 1), padding='same', activation='relu')(tower_4)output = keras.layers.concatenate([tower_1, tower_2, tower_3, tower_4], axis=1)model = Model(inputs=inputs, outputs=output)model.compile(...)model.fit(...)