def jia_xi_net(images, training, nlabels, scope_name='classifier', scope_reuse=False): with tf.variable_scope(scope_name) as scope: if scope_reuse: scope.reuse_variables() conv1_1 = layers.conv3D_layer(images, 'conv1_1', num_filters=32) pool1 = layers.max_pool_layer3d(conv1_1) conv2_1 = layers.conv3D_layer(pool1, 'conv2_1', num_filters=64) pool2 = layers.max_pool_layer3d(conv2_1) conv3_1 = layers.conv3D_layer(pool2, 'conv3_1', num_filters=128) conv3_2 = layers.conv3D_layer(conv3_1, 'conv3_2', num_filters=128) pool3 = layers.max_pool_layer3d(conv3_2) conv4_1 = layers.conv3D_layer(pool3, 'conv4_1', num_filters=256) conv4_2 = layers.conv3D_layer(conv4_1, 'conv4_2', num_filters=256) pool4 = layers.max_pool_layer3d(conv4_2) dense1 = layers.dense_layer(pool4, 'dense1', hidden_units=512) dense2 = layers.dense_layer(dense1, 'dense2', hidden_units=nlabels, activation=tf.identity) return dense2
def jia_xi_net_multitask_ordinal(images, training, nlabels, n_age_thresholds=5, scope_name='classifier', scope_reuse=False): with tf.variable_scope(scope_name) as scope: if scope_reuse: scope.reuse_variables() conv1_1 = layers.conv3D_layer(images, 'conv1_1', num_filters=32) pool1 = layers.max_pool_layer3d(conv1_1) conv2_1 = layers.conv3D_layer(pool1, 'conv2_1', num_filters=64) pool2 = layers.max_pool_layer3d(conv2_1) conv3_1 = layers.conv3D_layer(pool2, 'conv3_1', num_filters=128) conv3_2 = layers.conv3D_layer(conv3_1, 'conv3_2', num_filters=128) pool3 = layers.max_pool_layer3d(conv3_2) conv4_1 = layers.conv3D_layer(pool3, 'conv4_1', num_filters=256) conv4_2 = layers.conv3D_layer(conv4_1, 'conv4_2', num_filters=256) pool4 = layers.max_pool_layer3d(conv4_2) dense1 = layers.dense_layer(pool4, 'dense1', hidden_units=512) diagnosis = layers.dense_layer(dense1, 'dense2', hidden_units=nlabels, activation=tf.identity) dense_ages = layers.dense_layer(pool4, 'dense_ages', hidden_units=512) ages_logits = [] for ii in range(n_age_thresholds): ages_logits.append( layers.dense_layer(dense_ages, 'age_%s' % str(ii), hidden_units=2, activation=tf.identity)) return diagnosis, ages_logits
def unet3D_bn_modified(images, training, nlabels): images_padded = tf.pad(images, [[0, 0], [44, 44], [44, 44], [16, 16], [0, 0]], 'CONSTANT') conv1_1 = layers.conv3D_layer_bn(images_padded, 'conv1_1', num_filters=32, kernel_size=(3,3,3), training=training, padding='VALID') conv1_2 = layers.conv3D_layer_bn(conv1_1, 'conv1_2', num_filters=64, kernel_size=(3,3,3), training=training, padding='VALID') pool1 = layers.max_pool_layer3d(conv1_2, kernel_size=(2,2,1), strides=(2,2,1)) conv2_1 = layers.conv3D_layer_bn(pool1, 'conv2_1', num_filters=64, kernel_size=(3,3,3), training=training, padding='VALID') conv2_2 = layers.conv3D_layer_bn(conv2_1, 'conv2_2', num_filters=128, kernel_size=(3,3,3), training=training, padding='VALID') pool2 = layers.max_pool_layer3d(conv2_2, kernel_size=(2,2,1), strides=(2,2,1)) conv3_1 = layers.conv3D_layer_bn(pool2, 'conv3_1', num_filters=128, kernel_size=(3,3,3), training=training, padding='VALID') conv3_2 = layers.conv3D_layer_bn(conv3_1, 'conv3_2', num_filters=256, kernel_size=(3,3,3), training=training, padding='VALID') pool3 = layers.max_pool_layer3d(conv3_2, kernel_size=(2,2,2), strides=(2,2,2)) conv4_1 = layers.conv3D_layer_bn(pool3, 'conv4_1', num_filters=256, kernel_size=(3,3,3), training=training, padding='VALID') conv4_2 = layers.conv3D_layer_bn(conv4_1, 'conv4_2', num_filters=512, kernel_size=(3,3,3), training=training, padding='VALID') upconv3 = layers.deconv3D_layer_bn(conv4_2, name='upconv3', kernel_size=(4, 4, 4), strides=(2, 2, 2), num_filters=512, training=training) concat3 = layers.crop_and_concat_layer([upconv3, conv3_2], axis=4) conv5_1 = layers.conv3D_layer_bn(concat3, 'conv5_1', num_filters=256, kernel_size=(3,3,3), training=training, padding='VALID') conv5_2 = layers.conv3D_layer_bn(conv5_1, 'conv5_2', num_filters=256, kernel_size=(3,3,3), training=training, padding='VALID') upconv2 = layers.deconv3D_layer_bn(conv5_2, name='upconv2', kernel_size=(4, 4, 2), strides=(2, 2, 1), num_filters=256, training=training) concat2 = layers.crop_and_concat_layer([upconv2, conv2_2], axis=4) conv6_1 = layers.conv3D_layer_bn(concat2, 'conv6_1', num_filters=128, kernel_size=(3,3,3), training=training, padding='VALID') conv6_2 = layers.conv3D_layer_bn(conv6_1, 'conv6_2', num_filters=128, kernel_size=(3,3,3), training=training, padding='VALID') upconv1 = layers.deconv3D_layer_bn(conv6_2, name='upconv1', kernel_size=(4, 4, 2), strides=(2, 2, 1), num_filters=128, training=training) concat1 = layers.crop_and_concat_layer([upconv1, conv1_2], axis=4) conv8_1 = layers.conv3D_layer_bn(concat1, 'conv8_1', num_filters=64, kernel_size=(3,3,3), training=training, padding='VALID') conv8_2 = layers.conv3D_layer_bn(conv8_1, 'conv8_2', num_filters=64, kernel_size=(3,3,3), training=training, padding='VALID') pred = layers.conv3D_layer_bn(conv8_2, 'pred', num_filters=nlabels, kernel_size=(1,1,1), activation=tf.identity, training=training, padding='VALID') return pred
def FCN_multitask_ordinal_bn(images, training, nlabels, n_age_thresholds=5, bn_momentum=0.99, scope_name='classifier', scope_reuse=False): with tf.variable_scope(scope_name) as scope: if scope_reuse: scope.reuse_variables() conv1_1 = layers.conv3D_layer_bn(images, 'conv1_1', num_filters=32, training=training, bn_momentum=bn_momentum) pool1 = layers.max_pool_layer3d(conv1_1) conv2_1 = layers.conv3D_layer_bn(pool1, 'conv2_1', num_filters=64, training=training, bn_momentum=bn_momentum) pool2 = layers.max_pool_layer3d(conv2_1) conv3_1 = layers.conv3D_layer_bn(pool2, 'conv3_1', num_filters=128, training=training, bn_momentum=bn_momentum) conv3_2 = layers.conv3D_layer_bn(conv3_1, 'conv3_2', num_filters=128, training=training, bn_momentum=bn_momentum) pool3 = layers.max_pool_layer3d(conv3_2) conv4_1 = layers.conv3D_layer_bn(pool3, 'conv4_1', num_filters=256, training=training, bn_momentum=bn_momentum) conv4_2 = layers.conv3D_layer_bn(conv4_1, 'conv4_2', num_filters=256, training=training, bn_momentum=bn_momentum) pool4 = layers.max_pool_layer3d(conv4_2) conv5_1 = layers.conv3D_layer_bn(pool4, 'conv5_1', num_filters=256, training=training, bn_momentum=bn_momentum) conv5_2 = layers.conv3D_layer_bn(conv5_1, 'conv5_2', num_filters=256, training=training, bn_momentum=bn_momentum) convD_1 = layers.conv3D_layer_bn(conv5_2, 'convD_1', num_filters=256, training=training, bn_momentum=bn_momentum) convD_2 = layers.conv3D_layer_bn(convD_1, 'convD_2', num_filters=nlabels, training=training, bn_momentum=bn_momentum, kernel_size=(1, 1, 1), activation=tf.identity) diag_logits = layers.reduce_avg_layer3D(convD_2, name='diagnosis_avg') convA_1 = layers.conv3D_layer_bn(pool4, 'convA_1', num_filters=256, training=training, bn_momentum=bn_momentum) ages_logits = [] for ii in range(n_age_thresholds): age_activations = layers.conv3D_layer_bn(convA_1, 'convA_2_%d' % ii, num_filters=2, training=training, bn_momentum=bn_momentum, kernel_size=(1, 1, 1), activation=tf.identity) ages_logits.append( layers.reduce_avg_layer3D(age_activations, name='age_avg_%d' % ii)) return diag_logits, ages_logits
def FCN_disc_bn(images, training, nlabels, bn_momentum=0.99, scope_name='discriminator', scope_reuse=False): with tf.variable_scope(scope_name) as scope: if scope_reuse: scope.reuse_variables() conv1_1 = layers.conv3D_layer_bn(images, 'conv1_1', num_filters=32, training=training, bn_momentum=bn_momentum) pool1 = layers.max_pool_layer3d(conv1_1) conv2_1 = layers.conv3D_layer_bn(pool1, 'conv2_1', num_filters=64, training=training, bn_momentum=bn_momentum) pool2 = layers.max_pool_layer3d(conv2_1) conv3_1 = layers.conv3D_layer_bn(pool2, 'conv3_1', num_filters=128, training=training, bn_momentum=bn_momentum) conv3_2 = layers.conv3D_layer_bn(conv3_1, 'conv3_2', num_filters=128, training=training, bn_momentum=bn_momentum) pool3 = layers.max_pool_layer3d(conv3_2) conv4_1 = layers.conv3D_layer_bn(pool3, 'conv4_1', num_filters=256, training=training, bn_momentum=bn_momentum) conv4_2 = layers.conv3D_layer_bn(conv4_1, 'conv4_2', num_filters=256, training=training, bn_momentum=bn_momentum) pool4 = layers.max_pool_layer3d(conv4_2) conv5_1 = layers.conv3D_layer_bn(pool4, 'conv5_1', num_filters=256, training=training, bn_momentum=bn_momentum) conv5_2 = layers.conv3D_layer_bn(conv5_1, 'conv5_2', num_filters=256, training=training, bn_momentum=bn_momentum) convD_1 = layers.conv3D_layer_bn(conv5_2, 'convD_1', num_filters=256, training=training, bn_momentum=bn_momentum) convD_2 = layers.conv3D_layer_bn(convD_1, 'convD_2', num_filters=nlabels, training=training, bn_momentum=bn_momentum, kernel_size=(1, 1, 1), activation=tf.identity) diag_logits = layers.reduce_avg_layer3D(convD_2, name='diagnosis_avg') return diag_logits
def pool_fc_discriminator_bs2(x, training, scope_name='discriminator', scope_reuse=False): with tf.variable_scope(scope_name) as scope: if scope_reuse: scope.reuse_variables() conv1_1 = layers.conv3D_layer(x, 'dconv1_1', kernel_size=(3, 3, 3), num_filters=8, strides=(1, 1, 1), activation=layers.leaky_relu) pool1 = layers.max_pool_layer3d(conv1_1) conv2_1 = layers.conv3D_layer(pool1, 'dconv2_1', kernel_size=(3, 3, 3), num_filters=16, strides=(1, 1, 1), activation=layers.leaky_relu) pool2 = layers.max_pool_layer3d(conv2_1) conv3_1 = layers.conv3D_layer(pool2, 'dconv3_1', kernel_size=(3, 3, 3), num_filters=16, strides=(1, 1, 1), activation=layers.leaky_relu) conv3_2 = layers.conv3D_layer_bn(conv3_1, 'dconv3_2', kernel_size=(3, 3, 3), num_filters=16, strides=(1, 1, 1), activation=layers.leaky_relu, training=training) pool3 = layers.max_pool_layer3d(conv3_2) conv4_1 = layers.conv3D_layer(pool3, 'dconv4_1', kernel_size=(3, 3, 3), num_filters=16, strides=(1, 1, 1), activation=layers.leaky_relu) conv4_2 = layers.conv3D_layer(conv4_1, 'dconv4_2', kernel_size=(3, 3, 3), num_filters=16, strides=(1, 1, 1), activation=layers.leaky_relu) pool4 = layers.max_pool_layer3d(conv4_2) conv5_1 = layers.conv3D_layer(pool4, 'dconv5_1', kernel_size=(3, 3, 3), num_filters=16, strides=(1, 1, 1), activation=layers.leaky_relu) conv5_2 = layers.conv3D_layer(conv5_1, 'dconv5_2', kernel_size=(3, 3, 3), num_filters=16, strides=(1, 1, 1), activation=layers.leaky_relu) pool5 = layers.max_pool_layer3d(conv5_2) conv6_1 = layers.conv3D_layer(pool5, 'dconv6_1', kernel_size=(3, 3, 3), num_filters=16, strides=(1, 1, 1), activation=layers.leaky_relu) conv6_2 = layers.conv3D_layer(conv6_1, 'dconv6_2', kernel_size=(3, 3, 3), num_filters=16, strides=(1, 1, 1), activation=layers.leaky_relu) pool6 = layers.max_pool_layer3d(conv6_2) dense1 = layers.dense_layer(pool6, 'ddense1', hidden_units=256, activation=layers.leaky_relu) dense2 = layers.dense_layer(dense1, 'ddense2', hidden_units=1, activation=tf.identity) return dense2