Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
SparseConvNet
Commits
8c706edd
Commit
8c706edd
authored
Oct 19, 2018
by
Benjamin Thomas Graham
Browse files
Leaky UNets
parent
55d55a6a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
13 deletions
+10
-13
sparseconvnet/batchNormalization.py
sparseconvnet/batchNormalization.py
+4
-7
sparseconvnet/networkArchitectures.py
sparseconvnet/networkArchitectures.py
+6
-6
No files found.
sparseconvnet/batchNormalization.py
View file @
8c706edd
...
@@ -80,15 +80,12 @@ class BatchNormReLU(BatchNormalization):
...
@@ -80,15 +80,12 @@ class BatchNormReLU(BatchNormalization):
class
BatchNormLeakyReLU
(
BatchNormalization
):
class
BatchNormLeakyReLU
(
BatchNormalization
):
def
__init__
(
self
,
nPlanes
,
eps
=
1e-4
,
momentum
=
0.9
):
def
__init__
(
self
,
nPlanes
,
eps
=
1e-4
,
momentum
=
0.9
,
leakiness
=
0.333
):
BatchNormalization
.
__init__
(
self
,
nPlanes
,
eps
,
momentum
,
True
,
0.333
)
BatchNormalization
.
__init__
(
self
,
nPlanes
,
eps
,
momentum
,
True
,
leakiness
)
def
__repr__
(
self
):
def
__repr__
(
self
):
s
=
'BatchLeakyNorm('
+
str
(
self
.
nPlanes
)
+
',eps='
+
str
(
self
.
eps
)
+
\
s
=
'BatchNormLeakyReLU('
+
str
(
self
.
nPlanes
)
+
',eps='
+
str
(
self
.
eps
)
+
\
',momentum='
+
str
(
self
.
momentum
)
+
',affine='
+
str
(
self
.
affine
)
',momentum='
+
str
(
self
.
momentum
)
+
',affine='
+
str
(
self
.
affine
)
+
',leakiness='
+
str
(
self
.
leakiness
)
+
')'
if
self
.
leakiness
>
0
:
s
=
s
+
',leakiness='
+
str
(
self
.
leakiness
)
s
=
s
+
')'
return
s
return
s
class
BatchNormalizationFunction
(
Function
):
class
BatchNormalizationFunction
(
Function
):
...
...
sparseconvnet/networkArchitectures.py
View file @
8c706edd
...
@@ -200,7 +200,7 @@ def SparseResNet(dimension, nInputPlanes, layers):
...
@@ -200,7 +200,7 @@ def SparseResNet(dimension, nInputPlanes, layers):
return
m
return
m
def
UNet
(
dimension
,
reps
,
nPlanes
,
residual_blocks
=
False
,
downsample
=
[
2
,
2
]):
def
UNet
(
dimension
,
reps
,
nPlanes
,
residual_blocks
=
False
,
downsample
=
[
2
,
2
]
,
leakiness
=
0
):
"""
"""
U-Net style network with VGG or ResNet-style blocks.
U-Net style network with VGG or ResNet-style blocks.
For voxel level prediction:
For voxel level prediction:
...
@@ -223,14 +223,14 @@ def UNet(dimension, reps, nPlanes, residual_blocks=False, downsample=[2, 2]):
...
@@ -223,14 +223,14 @@ def UNet(dimension, reps, nPlanes, residual_blocks=False, downsample=[2, 2]):
m
.
add
(
scn
.
ConcatTable
()
m
.
add
(
scn
.
ConcatTable
()
.
add
(
scn
.
Identity
()
if
a
==
b
else
scn
.
NetworkInNetwork
(
a
,
b
,
False
))
.
add
(
scn
.
Identity
()
if
a
==
b
else
scn
.
NetworkInNetwork
(
a
,
b
,
False
))
.
add
(
scn
.
Sequential
()
.
add
(
scn
.
Sequential
()
.
add
(
scn
.
BatchNormReLU
(
a
))
.
add
(
scn
.
BatchNorm
Leaky
ReLU
(
a
,
leakiness
=
leakiness
))
.
add
(
scn
.
SubmanifoldConvolution
(
dimension
,
a
,
b
,
3
,
False
))
.
add
(
scn
.
SubmanifoldConvolution
(
dimension
,
a
,
b
,
3
,
False
))
.
add
(
scn
.
BatchNormReLU
(
b
))
.
add
(
scn
.
BatchNorm
Leaky
ReLU
(
b
,
leakiness
=
leakiness
))
.
add
(
scn
.
SubmanifoldConvolution
(
dimension
,
b
,
b
,
3
,
False
)))
.
add
(
scn
.
SubmanifoldConvolution
(
dimension
,
b
,
b
,
3
,
False
)))
).
add
(
scn
.
AddTable
())
).
add
(
scn
.
AddTable
())
else
:
#VGG style blocks
else
:
#VGG style blocks
m
.
add
(
scn
.
Sequential
()
m
.
add
(
scn
.
Sequential
()
.
add
(
scn
.
BatchNormReLU
(
a
))
.
add
(
scn
.
BatchNorm
Leaky
ReLU
(
a
,
leakiness
=
leakiness
))
.
add
(
scn
.
SubmanifoldConvolution
(
dimension
,
a
,
b
,
3
,
False
)))
.
add
(
scn
.
SubmanifoldConvolution
(
dimension
,
a
,
b
,
3
,
False
)))
def
U
(
nPlanes
):
#Recursive function
def
U
(
nPlanes
):
#Recursive function
m
=
scn
.
Sequential
()
m
=
scn
.
Sequential
()
...
@@ -245,11 +245,11 @@ def UNet(dimension, reps, nPlanes, residual_blocks=False, downsample=[2, 2]):
...
@@ -245,11 +245,11 @@ def UNet(dimension, reps, nPlanes, residual_blocks=False, downsample=[2, 2]):
scn
.
ConcatTable
().
add
(
scn
.
ConcatTable
().
add
(
scn
.
Identity
()).
add
(
scn
.
Identity
()).
add
(
scn
.
Sequential
().
add
(
scn
.
Sequential
().
add
(
scn
.
BatchNormReLU
(
nPlanes
[
0
])).
add
(
scn
.
BatchNorm
Leaky
ReLU
(
nPlanes
[
0
]
,
leakiness
=
leakiness
)).
add
(
scn
.
Convolution
(
dimension
,
nPlanes
[
0
],
nPlanes
[
1
],
scn
.
Convolution
(
dimension
,
nPlanes
[
0
],
nPlanes
[
1
],
downsample
[
0
],
downsample
[
1
],
False
)).
add
(
downsample
[
0
],
downsample
[
1
],
False
)).
add
(
U
(
nPlanes
[
1
:])).
add
(
U
(
nPlanes
[
1
:])).
add
(
scn
.
BatchNormReLU
(
nPlanes
[
1
])).
add
(
scn
.
BatchNorm
Leaky
ReLU
(
nPlanes
[
1
]
,
leakiness
=
leakiness
)).
add
(
scn
.
Deconvolution
(
dimension
,
nPlanes
[
1
],
nPlanes
[
0
],
scn
.
Deconvolution
(
dimension
,
nPlanes
[
1
],
nPlanes
[
0
],
downsample
[
0
],
downsample
[
1
],
False
))))
downsample
[
0
],
downsample
[
1
],
False
))))
m
.
add
(
scn
.
JoinTable
())
m
.
add
(
scn
.
JoinTable
())
...
...
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