MCPcopy Create free account
hub / github.com/tdeboissiere/DeepLearningImplementations / transition

Function transition

DenseNet/densenet.py:41–69  ·  view source on GitHub ↗

Apply BatchNorm, Relu 1x1Conv2D, optional dropout and Maxpooling2D :param x: keras model :param concat_axis: int -- index of contatenate axis :param nb_filter: int -- number of filters :param dropout_rate: int -- dropout rate :param weight_decay: int -- weight decay factor

(x, concat_axis, nb_filter,
               dropout_rate=None, weight_decay=1E-4)

Source from the content-addressed store, hash-verified

39
40
41def transition(x, concat_axis, nb_filter,
42 dropout_rate=None, weight_decay=1E-4):
43 """Apply BatchNorm, Relu 1x1Conv2D, optional dropout and Maxpooling2D
44
45 :param x: keras model
46 :param concat_axis: int -- index of contatenate axis
47 :param nb_filter: int -- number of filters
48 :param dropout_rate: int -- dropout rate
49 :param weight_decay: int -- weight decay factor
50
51 :returns: model
52 :rtype: keras model, after applying batch_norm, relu-conv, dropout, maxpool
53
54 """
55
56 x = BatchNormalization(axis=concat_axis,
57 gamma_regularizer=l2(weight_decay),
58 beta_regularizer=l2(weight_decay))(x)
59 x = Activation('relu')(x)
60 x = Conv2D(nb_filter, (1, 1),
61 kernel_initializer="he_uniform",
62 padding="same",
63 use_bias=False,
64 kernel_regularizer=l2(weight_decay))(x)
65 if dropout_rate:
66 x = Dropout(dropout_rate)(x)
67 x = AveragePooling2D((2, 2), strides=(2, 2))(x)
68
69 return x
70
71
72def denseblock(x, concat_axis, nb_layers, nb_filter, growth_rate,

Callers 1

DenseNetFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected