forked from nyukat/BIRADS_classifier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
models_tf.py
50 lines (36 loc) · 2.47 KB
/
models_tf.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
import layers_tf as layers
def baseline(x, parameters, nodropout_probability=None, gaussian_noise_std=None):
if gaussian_noise_std is not None:
x = layers.all_views_gaussian_noise_layer(x, gaussian_noise_std)
# first conv sequence
h = layers.all_views_conv_layer(x, 'conv1', number_of_filters=32, filter_size=[3, 3], stride=[2, 2])
# second conv sequence
h = layers.all_views_max_pool(h, stride=[3, 3])
h = layers.all_views_conv_layer(h, 'conv2a', number_of_filters=64, filter_size=[3, 3], stride=[2, 2])
h = layers.all_views_conv_layer(h, 'conv2b', number_of_filters=64, filter_size=[3, 3], stride=[1, 1])
h = layers.all_views_conv_layer(h, 'conv2c', number_of_filters=64, filter_size=[3, 3], stride=[1, 1])
# third conv sequence
h = layers.all_views_max_pool(h, stride=[2, 2])
h = layers.all_views_conv_layer(h, 'conv3a', number_of_filters=128, filter_size=[3, 3], stride=[1, 1])
h = layers.all_views_conv_layer(h, 'conv3b', number_of_filters=128, filter_size=[3, 3], stride=[1, 1])
h = layers.all_views_conv_layer(h, 'conv3c', number_of_filters=128, filter_size=[3, 3], stride=[1, 1])
# fourth conv sequence
h = layers.all_views_max_pool(h, stride=[2, 2])
h = layers.all_views_conv_layer(h, 'conv4a', number_of_filters=128, filter_size=[3, 3], stride=[1, 1])
h = layers.all_views_conv_layer(h, 'conv4b', number_of_filters=128, filter_size=[3, 3], stride=[1, 1])
h = layers.all_views_conv_layer(h, 'conv4c', number_of_filters=128, filter_size=[3, 3], stride=[1, 1])
# fifth conv sequence
h = layers.all_views_max_pool(h, stride=[2, 2])
h = layers.all_views_conv_layer(h, 'conv5a', number_of_filters=256, filter_size=[3, 3], stride=[1, 1])
h = layers.all_views_conv_layer(h, 'conv5b', number_of_filters=256, filter_size=[3, 3], stride=[1, 1])
h = layers.all_views_conv_layer(h, 'conv5c', number_of_filters=256, filter_size=[3, 3], stride=[1, 1])
# Pool, flatten, and fully connected layers
h = layers.all_views_global_avg_pool(h)
h = layers.all_views_flattening_layer(h)
h = layers.fc_layer(h, number_of_units=1024)
h = layers.dropout_layer(h, nodropout_probability)
y_prediction_birads = layers.softmax_layer(h, number_of_outputs=3)
return y_prediction_birads
class BaselineBreastModel:
def __init__(self, parameters, x, nodropout_probability=None, gaussian_noise_std=None):
self.y_prediction_birads = baseline(x, parameters, nodropout_probability, gaussian_noise_std)