-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathFCNdense.py
More file actions
35 lines (24 loc) · 1.15 KB
/
FCNdense.py
File metadata and controls
35 lines (24 loc) · 1.15 KB
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
32
33
34
35
import tensorflow as tf
def FCN_model(len_classes=2, dropout_rate=0.2):
input = tf.keras.layers.Input(shape=(None, None, 3))
x = tf.keras.layers.Conv2D(filters=32, kernel_size=3, strides=1)(input)
x = tf.keras.layers.Dropout(dropout_rate)(x)
x = tf.keras.layers.BatchNormalization()(x)
x = tf.keras.layers.Activation('relu')(x)
x = tf.keras.layers.MaxPooling2D()(x)
x = tf.keras.layers.Conv2D(filters=64, kernel_size=3, strides=1)(x)
x = tf.keras.layers.Dropout(dropout_rate)(x)
x = tf.keras.layers.BatchNormalization()(x)
x = tf.keras.layers.Activation('relu')(x)
x = tf.keras.layers.GlobalMaxPooling2D()(x)
x = tf.keras.layers.Flatten()(x)
x = tf.keras.layers.Dense(units=32)(x)
x = tf.keras.layers.Activation('relu')(x)
x = tf.keras.layers.Dense(units=len_classes)(x)
predictions = tf.keras.layers.Activation('softmax')(x)
model = tf.keras.Model(inputs=input, outputs=predictions)
print(model.summary())
print(f'Total number of layers: {len(model.layers)}')
return model
if __name__ == "__main__":
FCN_model(len_classes=2, dropout_rate=0.2)