-
Notifications
You must be signed in to change notification settings - Fork 0
/
BaseModel.py
29 lines (24 loc) · 1.41 KB
/
BaseModel.py
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
import tensorflow as tf
from Model import Model
class BaseModel(Model):
"""Build & use DCNN model.
Includes post-processing.
"""
def __init__(self, image_size, clf_name, loadFrom=None, lr=1e-4, eps=1e-8):
super().__init__(image_size, clf_name, loadFrom=loadFrom, lr=lr, eps=eps)
def set_model(self):
inputs = tf.keras.Input(shape=self.image_size+(3,))
x = tf.keras.layers.Conv2D(32, 3, activation=tf.nn.leaky_relu, padding='same')(inputs)
x = tf.keras.layers.Conv2D(32, 3, activation=tf.nn.leaky_relu, padding='same')(x)
x = tf.keras.layers.MaxPool2D(2)(x)
x = tf.keras.layers.Conv2D(64, 3, activation=tf.nn.leaky_relu, padding='same')(x)
x = tf.keras.layers.Conv2D(64, 3, activation=tf.nn.leaky_relu, padding='same')(x)
x = tf.keras.layers.MaxPool2D(2)(x)
x = tf.keras.layers.Conv2D(128, 3, activation=tf.nn.leaky_relu, padding='same')(x)
x = tf.keras.layers.Conv2D(128, 3, activation=tf.nn.leaky_relu, padding='same')(x)
x = tf.keras.layers.UpSampling2D(2)(x)
x = tf.keras.layers.Conv2D(64, 3, activation=tf.nn.leaky_relu, padding='same')(x)
x = tf.keras.layers.UpSampling2D(2)(x)
x = tf.keras.layers.Conv2D(32, 3, activation=tf.nn.leaky_relu, padding='same')(x)
outputs = tf.keras.layers.Conv2D(2, 1, activation=tf.nn.softmax)(x)
self.model = tf.keras.Model(inputs=inputs, outputs=outputs)