Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Max Ehrlich
cdcnn
Commits
b0a76158
Verified
Commit
b0a76158
authored
Dec 04, 2018
by
Max Ehrlich
Browse files
Make sure to batch norm after downsampling convolution
parent
b19163d7
Changes
1
Hide whitespace changes
Inline
Side-by-side
models/blocks.py
View file @
b0a76158
...
...
@@ -20,6 +20,7 @@ class SpatialResBlock(nn.Module):
if
downsample
or
in_channels
!=
out_channels
:
stride
=
2
if
downsample
else
1
self
.
downsampler
=
nn
.
Conv2d
(
in_channels
=
in_channels
,
out_channels
=
out_channels
,
kernel_size
=
1
,
stride
=
stride
,
padding
=
0
,
bias
=
False
)
self
.
bn_ds
=
nn
.
BatchNorm2d
(
out_channels
)
else
:
self
.
downsampler
=
None
...
...
@@ -33,6 +34,7 @@ class SpatialResBlock(nn.Module):
if
self
.
downsampler
is
not
None
:
residual
=
self
.
downsampler
(
x
)
residual
=
self
.
bn_ds
(
residual
)
else
:
residual
=
x
...
...
@@ -58,6 +60,7 @@ class JpegResBlock(nn.Module):
if
spatial_resblock
.
downsampler
is
not
None
:
self
.
downsampler
=
jpeg_layers
.
Conv2d
(
spatial_resblock
.
downsampler
,
J_down
)
self
.
bn_ds
=
jpeg_layers
.
BatchNorm
(
spatial_resblock
.
bn_ds
)
else
:
self
.
downsampler
=
None
...
...
@@ -78,6 +81,7 @@ class JpegResBlock(nn.Module):
if
self
.
downsampler
is
not
None
:
residual
=
self
.
downsampler
(
x
)
residual
=
self
.
bn_ds
(
residual
)
else
:
residual
=
x
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment