1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
class InceptionV4(tf.keras.Model): def __init__(self): super(InceptionV4, self).__init__() self.stem = Stem() self.inception_a = build_inception_block_a(4) self.reduction_a = ReductionA(k=192, l=224, m=256, n=384) self.inception_b = build_inception_block_b(7) self.reduction_b = ReductionB() self.inception_c = build_inception_block_c(3) self.avgpool = tf.keras.layers.AveragePooling2D(pool_size=(8, 8)) self.dropout = tf.keras.layers.Dropout(rate=0.2) self.flat = tf.keras.layers.Flatten() self.fc = tf.keras.layers.Dense(units=NUM_CLASSES, activation=tf.keras.activations.softmax)
def call(self, inputs, training=None, mask=None): x = self.stem(inputs, training=training) x = self.inception_a(x, training=training) x = self.reduction_a(x, training=training) x = self.inception_b(x, training=training) x = self.reduction_b(x, training=training) x = self.inception_c(x, training=training) x = self.avgpool(x) x = self.dropout(x, training=training) x = self.flat(x) x = self.fc(x)
return x
|