[4f54f1]: / model_definition / default.py

Download this file

79 lines (71 with data), 2.4 kB

 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
import tensorflow as tf
import config
from model_utils import calculate_conv_output_size
n_x = config.IMAGE_PXL_SIZE_X
n_y = config.IMAGE_PXL_SIZE_Y
n_z = config.SLICES
# This handles padding in both convolution and pooling layers
strides = [[2, 2, 2],
[2, 3, 3],
[1, 1, 1],
[2, 2, 2],
[1, 1, 1],
[1, 1, 1],
[2, 2, 2]]
filters = [[4, 5, 5],
[3, 4, 4],
[3, 3, 3],
[3, 3, 3],
[3, 3, 3],
[3, 3, 3],
[3, 3, 3]]
padding_types = ['VALID'] * 7
# Default network config used with more slices
# and larger convololution stride on first layer
default_config = {
'weights': [
# Convolution layers
('wc1', tf.truncated_normal([4, 5, 5, config.NUM_CHANNELS, 16], stddev=0.01)),
('wc2', tf.truncated_normal([3, 3, 3, 16, 64], stddev=0.01)),
('wc3', tf.truncated_normal([3, 3, 3, 64, 64], stddev=0.01)),
('wc4', tf.truncated_normal([3, 3, 3, 64, 32], stddev=0.01)),
# Fully connected layers
('wd1', tf.truncated_normal([calculate_conv_output_size(n_x, n_y, n_z,
strides,
filters,
padding_types,
32),
100], stddev=0.01)),
('wd2', tf.truncated_normal([100, 50], stddev=0.01)),
('wout', tf.truncated_normal([50, config.N_CLASSES], stddev=0.01))
],
'biases': (
# Convolution layers
('bc1', tf.zeros([16])),
('bc2', tf.constant(1.0, shape=[64])),
('bc3', tf.zeros([64])),
('bc4', tf.constant(1.0, shape=[32])),
# Fully connected layers
('bd1', tf.constant(1.0, shape=[100])),
('bd2', tf.constant(1.0, shape=[50])),
('bout', tf.constant(1.0, shape=[config.N_CLASSES]))
),
'pool_strides': [
[1, 2, 3, 3, 1],
[1, 2, 2, 2, 1],
[],
[1, 2, 2, 2, 1],
],
'pool_windows': [
[1, 3, 4, 4, 1],
[1, 3, 3, 3, 1],
[],
[1, 3, 3, 3, 1],
],
'strides': [
[1, 2, 2, 2, 1],
[1, 1, 1, 1, 1],
[1, 1, 1, 1, 1],
[1, 1, 1, 1, 1],
]
}