Commit 40ea559a authored by Felix Bragman's avatar Felix Bragman

standard mt vgg

parent 28138819
Pipeline #12592 failed with stages
in 9 seconds
......@@ -9,37 +9,28 @@ from niftynet.network.base_net import BaseNet
from niftynet.layer.fully_connected import FullyConnectedLayer
class VGG16Net(BaseNet):
class MT1_VGG16Net(BaseNet):
"""
Implementation of VGG16-Net:
Simonyan and Zisserman, "Very Deep Convolutional Networks for
Large-Scale Image Recogntion", ICLR 2015
- Original paper trained on 224 x 224 RGB image
- No batch-norm in original paper and no drop-out
- Batch-norm is default in this implementation
- Preprocessing in paper: RGB image de-meaned based on training data
e.g. I[:, :, 0] = I[:, :, 0] = meanRed
I[:, :, 1] = I[:, :, 1] = meanGreen
I[:, :, 2] = I[:, :, 2] = meanBlue
- Conv layers: 'padding' = SAME, 'stride' = 1
- Max pool: 'window' = 2x2, 'stride' = 2
Multi-task VGG net
Sharing done by:
1) split just before last FC unit that is fed into loss function
e.g. fc (1x1) --> l2 loss (age regression)
fc (1x2) --> binary softmax cross entropy (gender - 0/1)
"""
def __init__(self,
num_classes,
task1_classes,
task2_classes,
w_initializer=None,
w_regularizer=None,
b_initializer=None,
b_regularizer=None,
acti_func='relu',
name='VGG16Net'):
name='MT1_VGG16Net'):
super(VGG16Net, self).__init__(
num_classes=num_classes,
super(MT1_VGG16Net, self).__init__(
task1_classes=task1_classes,
task2_classes=task2_classes,
w_initializer=w_initializer,
w_regularizer=w_regularizer,
b_initializer=b_initializer,
......@@ -57,10 +48,17 @@ class VGG16Net(BaseNet):
{'name': 'layer_4', 'n_features': 512, 'kernel_size': 3, 'repeat': 3},
{'name': 'maxpool_4'},
{'name': 'layer_5', 'n_features': 512, 'kernel_size': 3, 'repeat': 3},
{'name': 'maxpool_5'},
{'name': 'maxpool_5'}]
self.task1_layers = [
{'name': 'fc_1', 'n_features': 4096},
{'name': 'fc_2', 'n_features': 4096},
{'name': 'fc_3', 'n_features': task1_classes}]
self.task2_layers = [
{'name': 'fc_1', 'n_features': 4096},
{'name': 'fc_2', 'n_features': 4096},
{'name': 'fc_3', 'n_features': num_classes}]
{'name': 'fc_3', 'n_features': task2_classes}]
def layer_op(self, images, is_training=True, layer_id=-1, **unused_kwargs):
#assert layer_util.check_spatial_dims(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment