-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVGG_3D.py
54 lines (39 loc) · 1.84 KB
/
VGG_3D.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
import tensorflow as tf
from tensorflow.keras.models import Model
from tensorflow.keras.layers import Input, Conv3D, MaxPooling3D, Dense, GlobalMaxPooling3D, Dropout, BatchNormalization
from tensorflow.keras.optimizers import Adam
from config import *
def VGG3D(inputs,num_classes):
inputs = inputs
x = inputs
x = Conv3D(32, (3, 3, 3), padding='same', activation='relu')(x)
x = Conv3D(32, (3, 3, 3), padding='same', activation='relu')(x)
x = MaxPooling3D(pool_size=(2, 2, 2))(x)
if TRAIN_CLASSIFY_USE_BN:
x = BatchNormalization()(x)
x = Conv3D(64, (3, 3, 3), padding='same', activation='relu')(x)
x = Conv3D(64, (3, 3, 3), padding='same', activation='relu')(x)
x = MaxPooling3D(pool_size=(2, 2, 2))(x)
if TRAIN_CLASSIFY_USE_BN:
x = BatchNormalization()(x)
x = Conv3D(128, (3, 3, 3), padding='same', activation='relu')(x)
x = Conv3D(128, (3, 3, 3), padding='same', activation='relu')(x)
x = Conv3D(128, (3, 3, 3), padding='same', activation='relu')(x)
x = MaxPooling3D(pool_size=(2, 2, 2))(x)
if TRAIN_CLASSIFY_USE_BN:
x = BatchNormalization()(x)
x = Conv3D(256, (3, 3, 3), padding='same', activation='relu')(x)
x = Conv3D(256, (3, 3, 3), padding='same', activation='relu')(x)
x = Conv3D(256, (3, 3, 3), padding='same', activation='relu')(x)
x = MaxPooling3D(pool_size=(2, 2, 2))(x)
if TRAIN_CLASSIFY_USE_BN:
x = BatchNormalization()(x)
x = Conv3D(512, (3, 3, 3), padding='same', activation='relu')(x)
x = Conv3D(512, (3, 3, 3), padding='same', activation='relu')(x)
x = Conv3D(512, (3, 3, 3), padding='same', activation='relu')(x)
x = GlobalMaxPooling3D()(x)
x = Dense(32, activation='relu')(x)
x = Dropout(0.5)(x)
x = Dense(units=num_classes,activation='sigmoid')(x)
model = Model(inputs=inputs, outputs=x)
return model