-
Notifications
You must be signed in to change notification settings - Fork 0
/
LongSkipModel.py
33 lines (28 loc) · 1.57 KB
/
LongSkipModel.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
30
31
32
33
import tensorflow as tf
from Model import Model
class LongSkipModel(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)
A = tf.keras.layers.Conv2D(32, 3, activation=tf.nn.leaky_relu, padding='same')(x)
x_ = tf.keras.layers.MaxPool2D(2)(A)
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)
B = tf.concat([x_, x], axis=3)
x_ = tf.keras.layers.MaxPool2D(2)(B)
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.concat([x_, x], axis=3)
x = tf.keras.layers.UpSampling2D(2)(x)
x = tf.concat([B, x], axis=3)
x = tf.keras.layers.Conv2D(64, 3, activation=tf.nn.leaky_relu, padding='same')(x)
x = tf.keras.layers.UpSampling2D(2)(x)
x = tf.concat([A, x], axis=3)
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)