File size: 882 Bytes
17124c2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from src.common import SIZE


def build_model(seed=42):
    from tensorflow import keras

    layers = keras.layers
    inputs = keras.Input((SIZE, SIZE, 3), name="rgb_pixels_0_255")
    x = layers.RandomFlip("horizontal_and_vertical", seed=seed)(inputs)
    x = layers.RandomRotation(0.5, fill_mode="reflect", seed=seed + 1)(x)
    x = layers.Rescaling(1 / 255.0)(x)
    for filters in (16, 32, 64):
        x = layers.Conv2D(filters, 3, padding="same", use_bias=False)(x)
        x = layers.BatchNormalization()(x)
        x = layers.Activation("relu")(x)
        x = layers.MaxPooling2D()(x)
    x = layers.Conv2D(96, 3, padding="same", activation="relu")(x)
    x = layers.GlobalAveragePooling2D()(x)
    x = layers.Dropout(0.25, seed=seed + 2)(x)
    outputs = layers.Dense(5, activation="softmax", name="land_cover")(x)
    return keras.Model(inputs, outputs, name="CELYRIX")