Вы можете следить за сетью ниже, чтобы избежать проблемы нехватки памяти, добавив слой maxpooling
после каждых двух слоев свертки.
model = Sequential()
model.add(Conv_Base)
model.add(Conv2D(input_shape=(32,32,3),filters=64,kernel_size=(3,3),padding="same", activation="relu"))
model.add(Conv2D(filters=64,kernel_size=(3,3),padding="same", activation="relu"))
model.add(MaxPool2D(pool_size=(2,2),strides=(2,2),padding="same"))
model.add(Conv2D(filters=128, kernel_size=(3,3), activation='relu',padding="same"))
model.add(Conv2D(filters=128, kernel_size=(3,3), padding="same", activation="relu"))
model.add(MaxPool2D(pool_size=(2,2),strides=(2,2),padding="same"))
model.add(Conv2D(filters=128, kernel_size=(3,3), padding="same", activation="relu"))
model.add(Conv2D(filters=256, kernel_size=(3,3), padding="same", activation="relu"))
model.add(MaxPool2D(pool_size=(2,2),strides=(2,2),padding="same"))
model.add(Conv2D(filters=256, kernel_size=(3,3), padding="same", activation="relu"))
model.add(Conv2D(filters=256, kernel_size=(3,3), padding="same", activation="relu"))
model.add(MaxPool2D(pool_size=(2,2),strides=(2,2),padding="same"))
model.add(Conv2D(filters=256, kernel_size=(3,3), padding="same", activation="relu"))
model.add(Conv2D(filters=512, kernel_size=(3,3), padding="same", activation="relu"))
model.add(MaxPool2D(pool_size=(2,2),strides=(2,2),padding="same"))
model.add(Conv2D(filters=512, kernel_size=(3,3), padding="same", activation="relu"))
model.add(Conv2D(filters=512, kernel_size=(3,3), padding="same", activation="relu"))
model.add(MaxPool2D(pool_size=(2,2),strides=(2,2),padding="same"))
model.add(Conv2D(filters=512, kernel_size=(3,3), padding="same", activation="relu"))
model.add(Conv2D(filters=512, kernel_size=(3,3), padding="same", activation="relu"))
model.add(MaxPool2D(pool_size=(2,2),strides=(2,2),padding="same"))
model.add(Flatten())
model.add(Dense(units=4096,activation="relu"))
model.add(Dense(units=2048,activation="relu"))
model.add(Dropout(0.5))
model.add(Dense(10, activation='softmax'))
model.summary()
Вывод:
Model: "sequential_2"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
vgg19 (Model) (None, 1, 1, 512) 20024384
_________________________________________________________________
conv2d_16 (Conv2D) (None, 1, 1, 64) 294976
_________________________________________________________________
conv2d_17 (Conv2D) (None, 1, 1, 64) 36928
_________________________________________________________________
max_pooling2d_8 (MaxPooling2 (None, 1, 1, 64) 0
_________________________________________________________________
conv2d_18 (Conv2D) (None, 1, 1, 128) 73856
_________________________________________________________________
conv2d_19 (Conv2D) (None, 1, 1, 128) 147584
_________________________________________________________________
max_pooling2d_9 (MaxPooling2 (None, 1, 1, 128) 0
_________________________________________________________________
conv2d_20 (Conv2D) (None, 1, 1, 128) 147584
_________________________________________________________________
conv2d_21 (Conv2D) (None, 1, 1, 256) 295168
_________________________________________________________________
max_pooling2d_10 (MaxPooling (None, 1, 1, 256) 0
_________________________________________________________________
conv2d_22 (Conv2D) (None, 1, 1, 256) 590080
_________________________________________________________________
conv2d_23 (Conv2D) (None, 1, 1, 256) 590080
_________________________________________________________________
max_pooling2d_11 (MaxPooling (None, 1, 1, 256) 0
_________________________________________________________________
conv2d_24 (Conv2D) (None, 1, 1, 256) 590080
_________________________________________________________________
conv2d_25 (Conv2D) (None, 1, 1, 512) 1180160
_________________________________________________________________
max_pooling2d_12 (MaxPooling (None, 1, 1, 512) 0
_________________________________________________________________
conv2d_26 (Conv2D) (None, 1, 1, 512) 2359808
_________________________________________________________________
conv2d_27 (Conv2D) (None, 1, 1, 512) 2359808
_________________________________________________________________
max_pooling2d_13 (MaxPooling (None, 1, 1, 512) 0
_________________________________________________________________
conv2d_28 (Conv2D) (None, 1, 1, 512) 2359808
_________________________________________________________________
conv2d_29 (Conv2D) (None, 1, 1, 512) 2359808
_________________________________________________________________
max_pooling2d_14 (MaxPooling (None, 1, 1, 512) 0
_________________________________________________________________
flatten_1 (Flatten) (None, 512) 0
_________________________________________________________________
dense_3 (Dense) (None, 4096) 2101248
_________________________________________________________________
dense_4 (Dense) (None, 2048) 8390656
_________________________________________________________________
dropout_1 (Dropout) (None, 2048) 0
_________________________________________________________________
dense_5 (Dense) (None, 10) 20490
=================================================================
Total params: 43,922,506
Trainable params: 43,922,506
Non-trainable params: 0