Diff of /DESS/ModelResnet3D.py [000000] .. [6a4082]

Switch to unified view

a b/DESS/ModelResnet3D.py
1
# ==============================================================================
2
# Copyright (C) 2023 Haresh Rengaraj Rajamohan, Tianyu Wang, Kevin Leung, 
3
# Gregory Chang, Kyunghyun Cho, Richard Kijowski & Cem M. Deniz 
4
#
5
# This file is part of OAI-MRI-TKR
6
#
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU Affero General Public License as published
9
# by the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
11
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
# GNU Affero General Public License for more details.
16
17
# You should have received a copy of the GNU Affero General Public License
18
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
19
# ==============================================================================
20
#!/usr/bin/env python3
21
22
from keras.models import Sequential
23
from keras.optimizers import SGD, Adam
24
#from keras.layers import Dropout, Dense, Conv3D, MaxPooling3D,GlobalMaxPooling3D, GlobalAveragePooling3D, Activation, BatchNormalization,Flatten
25
from resnet3d import Resnet3DBuilder
26
import tensorflow as tf
27
def generate_model(learning_rate = 2 * 10 **(-4)):
28
    #auc = tf.keras.metrics.AUC()
29
    #model = Resnet3DBuilder.build_resnet_50((384, 384, 160, 1), 1)
30
    model = Resnet3DBuilder.build_resnet_18((352, 352, 144, 1), 1)
31
    model.compile(loss='binary_crossentropy',
32
                      metrics = ['accuracy'],
33
                      optimizer = Adam(lr=learning_rate,beta_1=0.99, beta_2=0.999))#SGD(lr=1e-2, momentum = 0.9))
34
    return model
35