-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathmodel_resnet.py
25 lines (20 loc) · 918 Bytes
/
model_resnet.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
import tensorflow as tf
import util
upsample = False
def build_model(x, scale, training, reuse):
hidden_size = 128
bottleneck_size = 32
x = tf.layers.conv2d(x, hidden_size, 1, activation=None, name='in', reuse=reuse)
for i in range(10):
x = util.crop_by_pixel(x, 1) + conv(x, hidden_size, bottleneck_size, training, 'conv'+str(i), reuse)
x = tf.nn.relu(x)
x = tf.layers.conv2d(x, 3, 1, activation=None, name='out', reuse=reuse)
return x
def conv(x, hidden_size, bottleneck_size, training, name, reuse):
x = tf.nn.relu(x)
x = tf.layers.conv2d(x, bottleneck_size, 1, activation=None, name=name+'_proj', reuse=reuse)
x = tf.nn.relu(x)
x = tf.layers.conv2d(x, bottleneck_size, 3, activation=None, name=name+'_filt', reuse=reuse)
x = tf.nn.relu(x)
x = tf.layers.conv2d(x, hidden_size, 1, activation=None, name=name+'_recv', reuse=reuse)
return x