-
Notifications
You must be signed in to change notification settings - Fork 2
/
vgg_net.py
99 lines (80 loc) · 4.03 KB
/
vgg_net.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import tensorflow as tf
def vgg_net(images, _data_format):
layer01 = tf.layers.conv2d(images, 64, 3,
padding="same",
activation=tf.nn.relu,
data_format=_data_format,
name="conv1/conv1_1")
layer02 = tf.layers.conv2d(layer01, 64, 3,
padding="same",
activation=tf.nn.relu,
data_format=_data_format,
name="conv1/conv1_2")
layer03 = tf.layers.max_pooling2d(layer02, 2, 2,
data_format=_data_format)
layer04 = tf.layers.conv2d(layer03, 128, 3,
padding="same",
activation=tf.nn.relu,
data_format=_data_format,
name="conv2/conv2_1")
layer05 = tf.layers.conv2d(layer04, 128, 3,
padding="same",
activation=tf.nn.relu,
data_format=_data_format,
name="conv2/conv2_2")
layer06 = tf.layers.max_pooling2d(layer05, 2, 2,
data_format=_data_format)
layer07 = tf.layers.conv2d(layer06, 256, 3,
padding="same",
activation=tf.nn.relu,
data_format=_data_format,
name="conv3/conv3_1")
layer08 = tf.layers.conv2d(layer07, 256, 3,
padding="same",
activation=tf.nn.relu,
data_format=_data_format,
name="conv3/conv3_2")
layer09 = tf.layers.conv2d(layer08, 256, 3,
padding="same",
activation=tf.nn.relu,
data_format=_data_format,
name="conv3/conv3_3")
layer10 = tf.layers.max_pooling2d(layer09, 2, 2,
data_format=_data_format)
layer11 = tf.layers.conv2d(layer10, 512, 3,
padding="same",
activation=tf.nn.relu,
data_format=_data_format,
name="conv4/conv4_1")
layer12 = tf.layers.conv2d(layer11, 512, 3,
padding="same",
activation=tf.nn.relu,
data_format=_data_format,
name="conv4/conv4_2")
layer13 = tf.layers.conv2d(layer12, 512, 3,
padding="same",
activation=tf.nn.relu,
data_format=_data_format,
name="conv4/conv4_3")
layer14 = tf.layers.max_pooling2d(layer13, 2, 1,
padding="same",
data_format=_data_format)
layer15 = tf.layers.conv2d(layer14, 512, 3,
padding="same",
activation=tf.nn.relu,
dilation_rate=2,
data_format=_data_format,
name="conv5/conv5_1")
layer16 = tf.layers.conv2d(layer15, 512, 3,
padding="same",
activation=tf.nn.relu,
dilation_rate=2,
data_format=_data_format,
name="conv5/conv5_2")
layer17 = tf.layers.conv2d(layer16, 512, 3,
padding="same",
activation=tf.nn.relu,
dilation_rate=2,
data_format=_data_format,
name="conv5/conv5_3")
return layer17