-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmodels.py
56 lines (43 loc) · 1.78 KB
/
models.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import tensorflow as tf
slim = tf.contrib.slim
__leaky_relu_alpha__ = 0.2
def __leaky_relu__(x, alpha=__leaky_relu_alpha__, name='Leaky_ReLU'):
return tf.maximum(x, alpha*x, name=name)
class NN_DUAL(object):
def __init__(self, input_, vs_name, reuse=False):
self.input = input_
self.vs_name = vs_name
self.reuse = reuse
self.output = None
self.var_list = None
self.build_model()
def build_model(self):
with tf.variable_scope(self.vs_name, reuse=self.reuse) as vs:
with slim.arg_scope([slim.fully_connected],
num_outputs=32,
activation_fn=__leaky_relu__):
fc_1 = slim.fully_connected(self.input)
fc_2 = slim.fully_connected(fc_1)
fc_3 = slim.fully_connected(fc_2, num_outputs=1, activation_fn=None)
self.output = fc_3
self.var_list = tf.contrib.framework.get_variables(vs)
class NN_MAP(object):
def __init__(self, input_, vs_name, reuse=False):
self.input = input_
self.vs_name = vs_name
self.reuse = reuse
self.output = None
self.var_list = None
self.build_model()
def build_model(self):
with tf.variable_scope(self.vs_name, reuse=self.reuse) as vs:
with slim.arg_scope([slim.fully_connected],
num_outputs=32,
activation_fn=__leaky_relu__):
fc_1 = slim.fully_connected(self.input)
fc_2 = slim.fully_connected(fc_1)
fc_3 = slim.fully_connected(fc_2, num_outputs=2, activation_fn=None)
self.output = fc_3
self.var_list = tf.contrib.framework.get_variables(vs)
if __name__ == '__main__':
pass