Commit d156c501 authored by Felix Bragman's avatar Felix Bragman

fixed bugs that existed in initiall vgg16 body

parent 44db7958
Pipeline #12601 failed with stages
in 9 seconds
......@@ -48,68 +48,40 @@ class MT1_VGG16Net(BaseNet):
{'name': 'layer_4', 'n_features': 512*2, 'kernel_size': 3, 'repeat': 3},
{'name': 'maxpool_4'},
{'name': 'layer_5', 'n_features': 512*2, 'kernel_size': 3, 'repeat': 3},
{'name': 'maxpool_5'}]
{'name': 'maxpool_5'},
{'name': 'fc_1', 'n_features': 4096*2},
{'name': 'fc_2', 'n_features': 4096*2}]
self.task1_layers = [
{'name': 'fc_1', 'n_features': 4096*2},
{'name': 'fc_2', 'n_features': 4096*2},
{'name': 'fc_3', 'n_features': task1_classes}]
{'name': 'task_1_out', 'n_features': task1_classes}]
self.task2_layers = [
{'name': 'fc_1', 'n_features': 4096*2},
{'name': 'fc_2', 'n_features': 4096*2},
{'name': 'fc_3', 'n_features': task2_classes}]
{'name': 'task_2_out', 'n_features': task2_classes}]
def layer_op(self, images, is_training=True, layer_id=-1, **unused_kwargs):
#assert layer_util.check_spatial_dims(
# images, lambda x: x % 224 == 0)
# main network graph
flow, layer_instances = self.create_main_network_graph(images, is_training)
# add task 1 output
flow_t1 = flow
for layer_iter, layer in enumerate(self.task1_layers):
if layer_iter == len(self.layers)-1:
task1_layer = self.task1_layers
fc_layer = FullyConnectedLayer(
n_output_chns=layer['n_features'],
n_output_chns=task1_layer['n_features'],
w_initializer=self.initializers['w'],
w_regularizer=self.regularizers['w'],
)
task1_out = fc_layer(flow_t1)
task1_out = fc_layer(flow)
layer_instances.append((fc_layer, task1_out))
else:
fc_layer = FullyConnectedLayer(
n_output_chns=layer['n_features'],
acti_func=self.acti_func,
w_initializer=self.initializers['w'],
w_regularizer=self.regularizers['w'],
)
flow_t1 = fc_layer(flow_t1)
layer_instances.append((fc_layer, flow_t1))
# add task 1 output
flow_t2 = flow
for layer_iter, layer in enumerate(self.task2_layers):
if layer_iter == len(self.layers) - 1:
# add task 2 output
task2_layer = self.task2_layers
fc_layer = FullyConnectedLayer(
n_output_chns=layer['n_features'],
n_output_chns=task1_layer['n_features'],
w_initializer=self.initializers['w'],
w_regularizer=self.regularizers['w'],
)
task2_out = fc_layer(flow_t2)
task2_out = fc_layer(flow)
layer_instances.append((fc_layer, task2_out))
else:
fc_layer = FullyConnectedLayer(
n_output_chns=layer['n_features'],
acti_func=self.acti_func,
w_initializer=self.initializers['w'],
w_regularizer=self.regularizers['w'],
)
flow_t2 = fc_layer(flow_t2)
layer_instances.append((fc_layer, flow_t2))
if is_training:
self._print(layer_instances)
......@@ -141,34 +113,20 @@ class MT1_VGG16Net(BaseNet):
name=layer['name'])
flow = conv_layer(images, is_training)
layer_instances.append((conv_layer, flow))
repeat_conv = repeat_conv - 1
# last layer
elif layer_iter == len(self.layers)-1:
downsample_layer = DownSampleLayer(
kernel_size=2,
func='MAX',
stride=2)
flow = downsample_layer(flow)
layer_instances.append((downsample_layer, flow))
# all other
else:
# In case we want multiple convs before first maxpool
if repeat_conv > 1:
for _ in range(repeat_conv-1):
conv_layer = ConvolutionalLayer(
if layer_iter == len(self.layers) - 1:
fc_layer = FullyConnectedLayer(
n_output_chns=layer['n_features'],
kernel_size=layer['kernel_size'],
acti_func=self.acti_func,
w_initializer=self.initializers['w'],
w_regularizer=self.regularizers['w'],
name=layer['name'])
flow = conv_layer(flow, is_training)
layer_instances.append((conv_layer, flow))
else:
)
flow = fc_layer(flow)
layer_instances.append((fc_layer, flow))
continue
# all other
if layer_type == 'maxpool':
downsample_layer = DownSampleLayer(
kernel_size=2,
......
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