Commit 44db7958 authored by Felix Bragman's avatar Felix Bragman

fixed bugs in VGG

parent 2463bf20
Pipeline #12598 failed with stages
in 8 seconds
......@@ -62,7 +62,7 @@ class VGG16Net(BaseNet):
{'name': 'maxpool_5'},
{'name': 'fc_1', 'n_features': 4096},
{'name': 'fc_2', 'n_features': 4096},
{'name': 'fc_3', 'n_features': num_classes}]
{'name': 'fc_3', 'n_features': self.num_classes}]
def layer_op(self, images, is_training=True, layer_id=-1, **unused_kwargs):
......@@ -88,9 +88,10 @@ class 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:
if layer_iter == len(self.layers)-1:
fc_layer = FullyConnectedLayer(
n_output_chns=layer['n_features'],
w_initializer=self.initializers['w'],
......@@ -98,56 +99,40 @@ class VGG16Net(BaseNet):
)
flow = fc_layer(flow)
layer_instances.append((fc_layer, flow))
continue
# all other
else:
if layer_type == 'maxpool':
downsample_layer = DownSampleLayer(
kernel_size=2,
func='MAX',
stride=2)
flow = downsample_layer(flow)
layer_instances.append((downsample_layer, flow))
elif layer_type == 'layer':
for _ in range(repeat_conv):
conv_layer = ConvolutionalLayer(
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))
elif layer_type == 'fc':
# In case we want multiple convs before first maxpool
if repeat_conv > 1:
for _ in range(repeat_conv-1):
conv_layer = ConvolutionalLayer(
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:
if layer_type == 'maxpool':
downsample_layer = DownSampleLayer(
kernel_size=2,
func='MAX',
stride=2)
flow = downsample_layer(flow)
layer_instances.append((downsample_layer, flow))
elif layer_type == 'layer':
for _ in range(repeat_conv):
conv_layer = ConvolutionalLayer(
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))
elif layer_type == 'fc':
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 = fc_layer(flow)
layer_instances.append((fc_layer, flow))
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 = fc_layer(flow)
layer_instances.append((fc_layer, flow))
if is_training:
self._print(layer_instances)
......
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