Пример #1
0
def make_model():
    model = Sequential()
    model.add(Input(shape=input_shape))

    model.add(Conv2D(32, kernel_size=(3, 3), padding='same'))
    model.add(ReLU())
    model.add(Conv2D(32, kernel_size=(3, 3), padding='same'))
    model.add(ReLU())
    model.add(Conv2D(32, kernel_size=(3, 3), padding='same'))
    model.add(ReLU())
    model.add(Conv2D(32, kernel_size=(3, 3), padding='same'))
    model.add(ReLU())
    model.add(Conv2D(32, kernel_size=(3, 3), padding='same'))
    model.add(ReLU())

    model.add(Flatten())
    model.add(Dense(2500, kernel_initializer='He'))
    model.add(ReLU())
    model.add(Dense(1500, kernel_initializer='He'))
    model.add(ReLU())
    model.add(Dense(10, kernel_initializer='He'))
    model.add(Softmax())

    model.summary()
    model.compile(Adam(), 'categorical_crossentropy', 'accuracy')

    return model
Пример #2
0
def make_model():
    model = Sequential()
    model.add(Input(shape=input_shape))
    model.add(Conv2D(32, kernel_size=(3, 3), padding='same'))
    model.add(BN_LAYER())
    model.add(ReLU())
    model.add(Conv2D(32, kernel_size=(3, 3), padding='same'))
    model.add(BN_LAYER())
    model.add(ReLU())
    model.add(MaxPooling2D(2, 2, stride=2))

    model.add(Conv2D(64, kernel_size=(3, 3), padding='same'))
    model.add(BN_LAYER())
    model.add(ReLU())
    model.add(Conv2D(64, kernel_size=(3, 3), padding='same'))
    model.add(BN_LAYER())
    model.add(ReLU())
    model.add(MaxPooling2D(2, 2, stride=2))

    model.add(Flatten())
    model.add(Dense(512, kernel_initializer='He'))
    model.add(BN_LAYER())
    model.add(ReLU())
    model.add(Dense(10, kernel_initializer='He'))
    model.add(Softmax())

    model.summary()
    model.compile(Adam(), loss='categorical_crossentropy', metric='accuracy')

    return model
Пример #3
0
def make_model():
    model = Sequential()
    model.add(Input(shape=input_shape))

    model.add(
        Conv2D(16,
               kernel_size=3,
               strides=1,
               padding='same',
               kernel_regularizer=l2(1e-4)))
    model.add(BatchNormalization_v2())
    model.add(ReLU())

    add_residual_block(model, num_filters=16)
    add_residual_block(model, num_filters=16)
    add_residual_block(model, num_filters=16)

    add_residual_block(model, num_filters=32, strides=2, cnn_shortcut=True)
    add_residual_block(model, num_filters=32)
    add_residual_block(model, num_filters=32)

    add_residual_block(model, num_filters=64, strides=2, cnn_shortcut=True)
    add_residual_block(model, num_filters=64)
    add_residual_block(model, num_filters=64)
    model.add(AveragePooling2DAll())

    model.add(Flatten())
    model.add(Dense(10, kernel_initializer='He'))
    model.add(Softmax())

    model.summary()
    model.compile(Adam(lr=0.001, decay=1e-4), 'categorical_crossentropy',
                  'accuracy')

    return model
Пример #4
0
def make_model():
    model = Sequential()
    model.add(Input(shape=input_shape))
    model.add(Dense(4096))
    model.add(LeakyReLU(0.2))
    model.add(Dense(2048))
    model.add(LeakyReLU(0.2))
    model.add(Dense(1024))
    model.add(LeakyReLU(0.2))
    model.add(Dense(512))
    model.add(LeakyReLU(0.2))
    model.add(Dense(256))
    model.add(LeakyReLU(0.2))
    model.add(Dense(10))
    model.add(Softmax())

    model.summary()
    model.compile(Momentum(), 'categorical_crossentropy', 'accuracy')

    return model
Пример #5
0
def make_model():
    model = Sequential()
    model.add(Input(shape=input_shape))
    model.add(Dense(4096))
    model.add(ReLU())
    model.add(Dense(4096))
    model.add(ReLU())
    model.add(Dense(4096))
    model.add(ReLU())
    model.add(Dense(4096))
    model.add(ReLU())
    model.add(Dense(4096))
    model.add(ReLU())
    model.add(Dense(10))
    model.add(Softmax())

    model.summary()
    model.compile(Adam(), 'categorical_crossentropy', 'accuracy')

    return model