def resnet(n=18, nr_classes=10): input = Input(shape=(img_channels, img_rows, img_cols)) conv1 = conv_bn_relu( input, nb_filter=16, nb_row=3, nb_col=3, W_regularizer=l2(weight_decay)) # Filters, filter_size # Build residual blocks.. block_fn = _bottleneck block1 = residual_block(conv1, block_fn, nb_filters=16, repetations=n, is_first_layer=True) block2 = residual_block(block1, block_fn, nb_filters=32, repetations=n) block3 = residual_block(block2, block_fn, nb_filters=64, repetations=n, subsample=True) # Classifier block pool2 = AveragePooling2D(pool_size=(8, 8))(block3) flatten1 = Flatten()(pool2) final = Dense(units=nr_classes, kernel_initializer="he_normal", activation="softmax", kernel_regularizer=l2(weight_decay))(flatten1) model = Model(inputs=input, outputs=final) return model
def resnet(): input = Input(shape=(img_channels, img_rows, img_cols)) conv1 = conv_bn_relu(input, nb_filter=16, nb_row=3, nb_col=3, W_regularizer=l2(weight_decay)) # Build residual blocks.. block_fn = _bottleneck block1 = residual_block(conv1, block_fn, nb_filters=16, repetations=18, is_first_layer=True) block2 = residual_block(block1, block_fn, nb_filters=32, repetations=18) block3 = residual_block(block2, block_fn, nb_filters=64, repetations=18, subsample=True) # Classifier block pool2 = AveragePooling2D(pool_size=(8, 8))(block3) flatten1 = Flatten()(pool2) final = Dense(output_dim=10, init="he_normal", activation="softmax", W_regularizer=l2(weight_decay))(flatten1) model = Model(input=input, output=final) return model