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
ModelZoo
ResNet50_tensorflow
Commits
e43d75f3
"vscode:/vscode.git/clone" did not exist on "0aba91fc9a49b2f42ebd9f1f82150000e6940401"
Commit
e43d75f3
authored
Oct 21, 2020
by
anivegesana
Browse files
Lint YOLO backbone and building block code
parent
5122a448
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
1117 additions
and
1085 deletions
+1117
-1085
official/vision/beta/projects/yolo/configs/backbones.py
official/vision/beta/projects/yolo/configs/backbones.py
+5
-3
official/vision/beta/projects/yolo/modeling/backbones/Darknet.py
...l/vision/beta/projects/yolo/modeling/backbones/Darknet.py
+267
-245
official/vision/beta/projects/yolo/modeling/building_blocks/_CSPConnect.py
...eta/projects/yolo/modeling/building_blocks/_CSPConnect.py
+63
-62
official/vision/beta/projects/yolo/modeling/building_blocks/_CSPDownSample.py
.../projects/yolo/modeling/building_blocks/_CSPDownSample.py
+73
-72
official/vision/beta/projects/yolo/modeling/building_blocks/_CSPTiny.py
...n/beta/projects/yolo/modeling/building_blocks/_CSPTiny.py
+138
-136
official/vision/beta/projects/yolo/modeling/building_blocks/_DarkConv.py
.../beta/projects/yolo/modeling/building_blocks/_DarkConv.py
+136
-137
official/vision/beta/projects/yolo/modeling/building_blocks/_DarkResidual.py
...a/projects/yolo/modeling/building_blocks/_DarkResidual.py
+118
-118
official/vision/beta/projects/yolo/modeling/building_blocks/_DarkTiny.py
.../beta/projects/yolo/modeling/building_blocks/_DarkTiny.py
+88
-86
official/vision/beta/projects/yolo/modeling/building_blocks/__init__.py
...n/beta/projects/yolo/modeling/building_blocks/__init__.py
+0
-1
official/vision/beta/projects/yolo/modeling/tests/test_CSPConnect.py
...sion/beta/projects/yolo/modeling/tests/test_CSPConnect.py
+43
-42
official/vision/beta/projects/yolo/modeling/tests/test_CSPDownSample.py
...n/beta/projects/yolo/modeling/tests/test_CSPDownSample.py
+42
-41
official/vision/beta/projects/yolo/modeling/tests/test_DarkConv.py
...vision/beta/projects/yolo/modeling/tests/test_DarkConv.py
+57
-56
official/vision/beta/projects/yolo/modeling/tests/test_DarkResidual.py
...on/beta/projects/yolo/modeling/tests/test_DarkResidual.py
+49
-48
official/vision/beta/projects/yolo/modeling/tests/test_DarkTiny.py
...vision/beta/projects/yolo/modeling/tests/test_DarkTiny.py
+38
-38
No files found.
official/vision/beta/projects/yolo/configs/backbones.py
View file @
e43d75f3
...
@@ -6,11 +6,13 @@ from official.modeling import hyperparams
...
@@ -6,11 +6,13 @@ from official.modeling import hyperparams
from
official.vision.beta.configs
import
backbones
from
official.vision.beta.configs
import
backbones
@
dataclasses
.
dataclass
@
dataclasses
.
dataclass
class
DarkNet
(
hyperparams
.
Config
):
class
DarkNet
(
hyperparams
.
Config
):
"""DarkNet config."""
"""DarkNet config."""
model_id
:
str
=
"darknet53"
model_id
:
str
=
"darknet53"
@
dataclasses
.
dataclass
@
dataclasses
.
dataclass
class
Backbone
(
backbones
.
Backbone
):
class
Backbone
(
backbones
.
Backbone
):
darknet
:
DarkNet
=
DarkNet
()
darknet
:
DarkNet
=
DarkNet
()
official/vision/beta/projects/yolo/modeling/backbones/Darknet.py
View file @
e43d75f3
...
@@ -5,8 +5,10 @@ import collections
...
@@ -5,8 +5,10 @@ import collections
from
official.vision.beta.modeling.backbones
import
factory
from
official.vision.beta.modeling.backbones
import
factory
from
official.vision.beta.projects.yolo.modeling
import
building_blocks
as
nn_blocks
from
official.vision.beta.projects.yolo.modeling
import
building_blocks
as
nn_blocks
# builder required classes
# builder required classes
class
BlockConfig
(
object
):
class
BlockConfig
(
object
):
def
__init__
(
self
,
layer
,
stack
,
reps
,
bottleneck
,
filters
,
kernel_size
,
def
__init__
(
self
,
layer
,
stack
,
reps
,
bottleneck
,
filters
,
kernel_size
,
strides
,
padding
,
activation
,
route
,
output_name
,
is_output
):
strides
,
padding
,
activation
,
route
,
output_name
,
is_output
):
'''
'''
...
@@ -34,40 +36,48 @@ class BlockConfig(object):
...
@@ -34,40 +36,48 @@ class BlockConfig(object):
self
.
is_output
=
is_output
self
.
is_output
=
is_output
return
return
def
build_block_specs
(
config
):
def
build_block_specs
(
config
):
specs
=
[]
specs
=
[]
for
layer
in
config
:
for
layer
in
config
:
specs
.
append
(
BlockConfig
(
*
layer
))
specs
.
append
(
BlockConfig
(
*
layer
))
return
specs
return
specs
def
darkconv_config_todict
(
config
,
kwargs
):
def
darkconv_config_todict
(
config
,
kwargs
):
dictvals
=
{
dictvals
=
{
"filters"
:
config
.
filters
,
"filters"
:
config
.
filters
,
"kernel_size"
:
config
.
kernel_size
,
"kernel_size"
:
config
.
kernel_size
,
"strides"
:
config
.
strides
,
"strides"
:
config
.
strides
,
"padding"
:
config
.
padding
"padding"
:
config
.
padding
}
}
dictvals
.
update
(
kwargs
)
dictvals
.
update
(
kwargs
)
return
dictvals
return
dictvals
def
darktiny_config_todict
(
config
,
kwargs
):
def
darktiny_config_todict
(
config
,
kwargs
):
dictvals
=
{
dictvals
=
{
"filters"
:
config
.
filters
,
"strides"
:
config
.
strides
}
"filters"
:
config
.
filters
,
"strides"
:
config
.
strides
}
dictvals
.
update
(
kwargs
)
dictvals
.
update
(
kwargs
)
return
dictvals
return
dictvals
def
maxpool_config_todict
(
config
,
kwargs
):
def
maxpool_config_todict
(
config
,
kwargs
):
return
{
"pool_size"
:
config
.
kernel_size
,
return
{
"pool_size"
:
config
.
kernel_size
,
"strides"
:
config
.
strides
,
"strides"
:
config
.
strides
,
"padding"
:
config
.
padding
,
"padding"
:
config
.
padding
,
"name"
:
kwargs
[
"name"
]}
"name"
:
kwargs
[
"name"
]
}
class
layer_registry
(
object
):
class
layer_registry
(
object
):
def
__init__
(
self
):
def
__init__
(
self
):
self
.
_layer_dict
=
{
"DarkTiny"
:
(
nn_blocks
.
DarkTiny
,
darktiny_config_todict
),
self
.
_layer_dict
=
{
"DarkTiny"
:
(
nn_blocks
.
DarkTiny
,
darktiny_config_todict
),
"DarkConv"
:
(
nn_blocks
.
DarkConv
,
darkconv_config_todict
),
"DarkConv"
:
(
nn_blocks
.
DarkConv
,
darkconv_config_todict
),
"MaxPool"
:
(
tf
.
keras
.
layers
.
MaxPool2D
,
maxpool_config_todict
)}
"MaxPool"
:
(
tf
.
keras
.
layers
.
MaxPool2D
,
maxpool_config_todict
)
}
return
return
def
_get_layer
(
self
,
key
):
def
_get_layer
(
self
,
key
):
...
@@ -78,8 +88,14 @@ class layer_registry(object):
...
@@ -78,8 +88,14 @@ class layer_registry(object):
param_dict
=
get_param_dict
(
config
,
kwargs
)
param_dict
=
get_param_dict
(
config
,
kwargs
)
return
layer
(
**
param_dict
)
return
layer
(
**
param_dict
)
# model configs
# model configs
LISTNAMES
=
[
"default_layer_name"
,
"level_type"
,
"number_of_layers_in_level"
,
"bottleneck"
,
"filters"
,
"kernal_size"
,
"strides"
,
"padding"
,
"default_activation"
,
"route"
,
"level/name"
,
"is_output"
]
LISTNAMES
=
[
"default_layer_name"
,
"level_type"
,
"number_of_layers_in_level"
,
"bottleneck"
,
"filters"
,
"kernal_size"
,
"strides"
,
"padding"
,
"default_activation"
,
"route"
,
"level/name"
,
"is_output"
]
CSPDARKNET53
=
{
CSPDARKNET53
=
{
"list_names"
:
LISTNAMES
,
"list_names"
:
LISTNAMES
,
"splits"
:
{
"backbone_split"
:
106
,
"splits"
:
{
"backbone_split"
:
106
,
...
@@ -134,25 +150,30 @@ DARKNETTINY = {
...
@@ -134,25 +150,30 @@ DARKNETTINY = {
]
]
}
}
BACKBONES
=
{
"darknettiny"
:
DARKNETTINY
,
BACKBONES
=
{
"darknettiny"
:
DARKNETTINY
,
"darknet53"
:
DARKNET53
,
"darknet53"
:
DARKNET53
,
"cspdarknet53"
:
CSPDARKNET53
,
"cspdarknet53"
:
CSPDARKNET53
,
"cspdarknettiny"
:
CSPDARKNETTINY
}
"cspdarknettiny"
:
CSPDARKNETTINY
}
@
ks
.
utils
.
register_keras_serializable
(
package
=
'yolo'
)
@
ks
.
utils
.
register_keras_serializable
(
package
=
'yolo'
)
class
Darknet
(
ks
.
Model
):
class
Darknet
(
ks
.
Model
):
def
__init__
(
self
,
def
__init__
(
self
,
model_id
=
"darknet53"
,
model_id
=
"darknet53"
,
input_shape
=
tf
.
keras
.
layers
.
InputSpec
(
shape
=
[
None
,
None
,
None
,
3
]),
input_shape
=
tf
.
keras
.
layers
.
InputSpec
(
shape
=
[
None
,
None
,
None
,
3
]),
min_size
=
None
,
min_size
=
None
,
max_size
=
5
,
max_size
=
5
,
activation
=
None
,
activation
=
None
,
use_sync_bn
=
False
,
use_sync_bn
=
False
,
norm_momentum
=
0.99
,
norm_momentum
=
0.99
,
norm_epsilon
=
0.001
,
norm_epsilon
=
0.001
,
kernel_initializer
=
'glorot_uniform'
,
kernel_initializer
=
'glorot_uniform'
,
kernel_regularizer
=
None
,
kernel_regularizer
=
None
,
bias_regularizer
=
None
,
bias_regularizer
=
None
,
config
=
None
,
config
=
None
,
**
kwargs
):
**
kwargs
):
...
@@ -175,14 +196,16 @@ class Darknet(ks.Model):
...
@@ -175,14 +196,16 @@ class Darknet(ks.Model):
self
.
_activation
=
activation
self
.
_activation
=
activation
self
.
_weight_decay
=
kernel_regularizer
self
.
_weight_decay
=
kernel_regularizer
self
.
_default_dict
=
{
"kernel_initializer"
:
self
.
_kernel_initializer
,
self
.
_default_dict
=
{
"kernel_initializer"
:
self
.
_kernel_initializer
,
"weight_decay"
:
self
.
_weight_decay
,
"weight_decay"
:
self
.
_weight_decay
,
"bias_regularizer"
:
self
.
_bias_regularizer
,
"bias_regularizer"
:
self
.
_bias_regularizer
,
"norm_momentum"
:
self
.
_norm_momentum
,
"norm_momentum"
:
self
.
_norm_momentum
,
"norm_epsilon"
:
self
.
_norm_epislon
,
"norm_epsilon"
:
self
.
_norm_epislon
,
"use_sync_bn"
:
self
.
_use_sync_bn
,
"use_sync_bn"
:
self
.
_use_sync_bn
,
"activation"
:
self
.
_activation
,
"activation"
:
self
.
_activation
,
"name"
:
None
}
"name"
:
None
}
inputs
=
ks
.
layers
.
Input
(
shape
=
self
.
_input_shape
.
shape
[
1
:])
inputs
=
ks
.
layers
.
Input
(
shape
=
self
.
_input_shape
.
shape
[
1
:])
output
=
self
.
_build_struct
(
layer_specs
,
inputs
)
output
=
self
.
_build_struct
(
layer_specs
,
inputs
)
...
@@ -225,7 +248,8 @@ class Darknet(ks.Model):
...
@@ -225,7 +248,8 @@ class Darknet(ks.Model):
config
,
config
,
name
=
f
"
{
config
.
layer
}
_
{
i
}
"
)
name
=
f
"
{
config
.
layer
}
_
{
i
}
"
)
stack_outputs
.
append
(
x_pass
)
stack_outputs
.
append
(
x_pass
)
if
(
config
.
is_output
and
self
.
_min_size
==
None
):
# or isinstance(config.output_name, str):
if
(
config
.
is_output
and
self
.
_min_size
==
None
):
# or isinstance(config.output_name, str):
endpoints
[
config
.
output_name
]
=
x
endpoints
[
config
.
output_name
]
=
x
elif
self
.
_min_size
!=
None
and
config
.
output_name
>=
self
.
_min_size
and
config
.
output_name
<=
self
.
_max_size
:
elif
self
.
_min_size
!=
None
and
config
.
output_name
>=
self
.
_min_size
and
config
.
output_name
<=
self
.
_max_size
:
endpoints
[
config
.
output_name
]
=
x
endpoints
[
config
.
output_name
]
=
x
...
@@ -250,13 +274,12 @@ class Darknet(ks.Model):
...
@@ -250,13 +274,12 @@ class Darknet(ks.Model):
scale_filters
=
2
scale_filters
=
2
self
.
_default_dict
[
"activation"
]
=
self
.
_get_activation
(
config
.
activation
)
self
.
_default_dict
[
"activation"
]
=
self
.
_get_activation
(
config
.
activation
)
self
.
_default_dict
[
"name"
]
=
f
"
{
name
}
_csp_down"
self
.
_default_dict
[
"name"
]
=
f
"
{
name
}
_csp_down"
x
,
x_route
=
nn_blocks
.
CSPDownSample
(
filters
=
config
.
filters
,
x
,
x_route
=
nn_blocks
.
CSPDownSample
(
filters
=
config
.
filters
,
filter_reduce
=
csp_filter_reduce
,
filter_reduce
=
csp_filter_reduce
,
**
self
.
_default_dict
)(
inputs
)
**
self
.
_default_dict
)(
inputs
)
for
i
in
range
(
config
.
repetitions
):
for
i
in
range
(
config
.
repetitions
):
self
.
_default_dict
[
"name"
]
=
f
"
{
name
}
_
{
i
}
"
self
.
_default_dict
[
"name"
]
=
f
"
{
name
}
_
{
i
}
"
x
=
nn_blocks
.
DarkResidual
(
x
=
nn_blocks
.
DarkResidual
(
filters
=
config
.
filters
//
scale_filters
,
filters
=
config
.
filters
//
scale_filters
,
filter_scale
=
residual_filter_reduce
,
filter_scale
=
residual_filter_reduce
,
**
self
.
_default_dict
)(
x
)
**
self
.
_default_dict
)(
x
)
...
@@ -280,14 +303,12 @@ class Darknet(ks.Model):
...
@@ -280,14 +303,12 @@ class Darknet(ks.Model):
def
_residual_stack
(
self
,
inputs
,
config
,
name
):
def
_residual_stack
(
self
,
inputs
,
config
,
name
):
self
.
_default_dict
[
"activation"
]
=
self
.
_get_activation
(
config
.
activation
)
self
.
_default_dict
[
"activation"
]
=
self
.
_get_activation
(
config
.
activation
)
self
.
_default_dict
[
"name"
]
=
f
"
{
name
}
_residual_down"
self
.
_default_dict
[
"name"
]
=
f
"
{
name
}
_residual_down"
x
=
nn_blocks
.
DarkResidual
(
x
=
nn_blocks
.
DarkResidual
(
filters
=
config
.
filters
,
filters
=
config
.
filters
,
downsample
=
True
,
downsample
=
True
,
**
self
.
_default_dict
)(
inputs
)
**
self
.
_default_dict
)(
inputs
)
for
i
in
range
(
config
.
repetitions
-
1
):
for
i
in
range
(
config
.
repetitions
-
1
):
self
.
_default_dict
[
"name"
]
=
f
"
{
name
}
_
{
i
}
"
self
.
_default_dict
[
"name"
]
=
f
"
{
name
}
_
{
i
}
"
x
=
nn_blocks
.
DarkResidual
(
x
=
nn_blocks
.
DarkResidual
(
filters
=
config
.
filters
,
filters
=
config
.
filters
,
**
self
.
_default_dict
)(
x
)
**
self
.
_default_dict
)(
x
)
self
.
_default_dict
[
"activation"
]
=
self
.
_activation
self
.
_default_dict
[
"activation"
]
=
self
.
_activation
self
.
_default_dict
[
"name"
]
=
None
self
.
_default_dict
[
"name"
]
=
None
...
@@ -313,6 +334,7 @@ class Darknet(ks.Model):
...
@@ -313,6 +334,7 @@ class Darknet(ks.Model):
splits
=
BACKBONES
[
name
][
"splits"
]
splits
=
BACKBONES
[
name
][
"splits"
]
return
build_block_specs
(
backbone
),
splits
return
build_block_specs
(
backbone
),
splits
@
factory
.
register_backbone_builder
(
'darknet'
)
@
factory
.
register_backbone_builder
(
'darknet'
)
def
build_darknet
(
def
build_darknet
(
input_specs
:
tf
.
keras
.
layers
.
InputSpec
,
input_specs
:
tf
.
keras
.
layers
.
InputSpec
,
...
...
official/vision/beta/projects/yolo/modeling/building_blocks/_CSPConnect.py
View file @
e43d75f3
...
@@ -5,6 +5,7 @@ from ._DarkConv import DarkConv
...
@@ -5,6 +5,7 @@ from ._DarkConv import DarkConv
@
ks
.
utils
.
register_keras_serializable
(
package
=
'yolo'
)
@
ks
.
utils
.
register_keras_serializable
(
package
=
'yolo'
)
class
CSPConnect
(
ks
.
layers
.
Layer
):
class
CSPConnect
(
ks
.
layers
.
Layer
):
def
__init__
(
def
__init__
(
self
,
self
,
filters
,
filters
,
...
...
official/vision/beta/projects/yolo/modeling/building_blocks/_CSPDownSample.py
View file @
e43d75f3
...
@@ -5,6 +5,7 @@ from ._DarkConv import DarkConv
...
@@ -5,6 +5,7 @@ from ._DarkConv import DarkConv
@
ks
.
utils
.
register_keras_serializable
(
package
=
'yolo'
)
@
ks
.
utils
.
register_keras_serializable
(
package
=
'yolo'
)
class
CSPDownSample
(
ks
.
layers
.
Layer
):
class
CSPDownSample
(
ks
.
layers
.
Layer
):
def
__init__
(
def
__init__
(
self
,
self
,
filters
,
filters
,
...
...
official/vision/beta/projects/yolo/modeling/building_blocks/_CSPTiny.py
View file @
e43d75f3
...
@@ -3,23 +3,26 @@ import tensorflow as tf
...
@@ -3,23 +3,26 @@ import tensorflow as tf
import
tensorflow.keras
as
ks
import
tensorflow.keras
as
ks
from
._DarkConv
import
DarkConv
from
._DarkConv
import
DarkConv
@
ks
.
utils
.
register_keras_serializable
(
package
=
'yolo'
)
@
ks
.
utils
.
register_keras_serializable
(
package
=
'yolo'
)
class
CSPTiny
(
ks
.
layers
.
Layer
):
class
CSPTiny
(
ks
.
layers
.
Layer
):
def
__init__
(
self
,
def
__init__
(
self
,
filters
=
1
,
filters
=
1
,
use_bias
=
True
,
use_bias
=
True
,
kernel_initializer
=
'glorot_uniform'
,
kernel_initializer
=
'glorot_uniform'
,
bias_initializer
=
'zeros'
,
bias_initializer
=
'zeros'
,
bias_regularizer
=
None
,
bias_regularizer
=
None
,
weight_decay
=
None
,
# default find where is it is stated
weight_decay
=
None
,
# default find where is it is stated
use_bn
=
True
,
use_bn
=
True
,
use_sync_bn
=
False
,
use_sync_bn
=
False
,
group_id
=
1
,
group_id
=
1
,
groups
=
2
,
groups
=
2
,
norm_momentum
=
0.99
,
norm_momentum
=
0.99
,
norm_epsilon
=
0.001
,
norm_epsilon
=
0.001
,
activation
=
'leaky'
,
activation
=
'leaky'
,
downsample
=
True
,
downsample
=
True
,
leaky_alpha
=
0.1
,
leaky_alpha
=
0.1
,
**
kwargs
):
**
kwargs
):
...
@@ -31,7 +34,7 @@ class CSPTiny(ks.layers.Layer):
...
@@ -31,7 +34,7 @@ class CSPTiny(ks.layers.Layer):
self
.
_bias_regularizer
=
bias_regularizer
self
.
_bias_regularizer
=
bias_regularizer
self
.
_use_bn
=
use_bn
self
.
_use_bn
=
use_bn
self
.
_use_sync_bn
=
use_sync_bn
self
.
_use_sync_bn
=
use_sync_bn
self
.
_weight_decay
=
weight_decay
self
.
_weight_decay
=
weight_decay
self
.
_groups
=
groups
self
.
_groups
=
groups
self
.
_group_id
=
group_id
self
.
_group_id
=
group_id
self
.
_downsample
=
downsample
self
.
_downsample
=
downsample
...
@@ -55,7 +58,7 @@ class CSPTiny(ks.layers.Layer):
...
@@ -55,7 +58,7 @@ class CSPTiny(ks.layers.Layer):
use_bias
=
self
.
_use_bias
,
use_bias
=
self
.
_use_bias
,
kernel_initializer
=
self
.
_kernel_initializer
,
kernel_initializer
=
self
.
_kernel_initializer
,
bias_initializer
=
self
.
_bias_initializer
,
bias_initializer
=
self
.
_bias_initializer
,
bias_regularizer
=
self
.
_bias_regularizer
,
bias_regularizer
=
self
.
_bias_regularizer
,
weight_decay
=
self
.
_weight_decay
,
weight_decay
=
self
.
_weight_decay
,
use_bn
=
self
.
_use_bn
,
use_bn
=
self
.
_use_bn
,
use_sync_bn
=
self
.
_use_sync_bn
,
use_sync_bn
=
self
.
_use_sync_bn
,
...
@@ -64,15 +67,14 @@ class CSPTiny(ks.layers.Layer):
...
@@ -64,15 +67,14 @@ class CSPTiny(ks.layers.Layer):
activation
=
self
.
_conv_activation
,
activation
=
self
.
_conv_activation
,
leaky_alpha
=
self
.
_leaky_alpha
)
leaky_alpha
=
self
.
_leaky_alpha
)
self
.
_convlayer2
=
DarkConv
(
filters
=
self
.
_filters
//
2
,
self
.
_convlayer2
=
DarkConv
(
filters
=
self
.
_filters
//
2
,
kernel_size
=
(
3
,
3
),
kernel_size
=
(
3
,
3
),
strides
=
(
1
,
1
),
strides
=
(
1
,
1
),
padding
=
'same'
,
padding
=
'same'
,
use_bias
=
self
.
_use_bias
,
use_bias
=
self
.
_use_bias
,
kernel_initializer
=
self
.
_kernel_initializer
,
kernel_initializer
=
self
.
_kernel_initializer
,
bias_initializer
=
self
.
_bias_initializer
,
bias_initializer
=
self
.
_bias_initializer
,
bias_regularizer
=
self
.
_bias_regularizer
,
bias_regularizer
=
self
.
_bias_regularizer
,
weight_decay
=
self
.
_weight_decay
,
weight_decay
=
self
.
_weight_decay
,
use_bn
=
self
.
_use_bn
,
use_bn
=
self
.
_use_bn
,
use_sync_bn
=
self
.
_use_sync_bn
,
use_sync_bn
=
self
.
_use_sync_bn
,
...
@@ -81,14 +83,14 @@ class CSPTiny(ks.layers.Layer):
...
@@ -81,14 +83,14 @@ class CSPTiny(ks.layers.Layer):
activation
=
self
.
_conv_activation
,
activation
=
self
.
_conv_activation
,
leaky_alpha
=
self
.
_leaky_alpha
)
leaky_alpha
=
self
.
_leaky_alpha
)
self
.
_convlayer3
=
DarkConv
(
filters
=
self
.
_filters
//
2
,
self
.
_convlayer3
=
DarkConv
(
filters
=
self
.
_filters
//
2
,
kernel_size
=
(
3
,
3
),
kernel_size
=
(
3
,
3
),
strides
=
(
1
,
1
),
strides
=
(
1
,
1
),
padding
=
'same'
,
padding
=
'same'
,
use_bias
=
self
.
_use_bias
,
use_bias
=
self
.
_use_bias
,
kernel_initializer
=
self
.
_kernel_initializer
,
kernel_initializer
=
self
.
_kernel_initializer
,
bias_initializer
=
self
.
_bias_initializer
,
bias_initializer
=
self
.
_bias_initializer
,
bias_regularizer
=
self
.
_bias_regularizer
,
bias_regularizer
=
self
.
_bias_regularizer
,
weight_decay
=
self
.
_weight_decay
,
weight_decay
=
self
.
_weight_decay
,
use_bn
=
self
.
_use_bn
,
use_bn
=
self
.
_use_bn
,
use_sync_bn
=
self
.
_use_sync_bn
,
use_sync_bn
=
self
.
_use_sync_bn
,
...
@@ -104,7 +106,7 @@ class CSPTiny(ks.layers.Layer):
...
@@ -104,7 +106,7 @@ class CSPTiny(ks.layers.Layer):
use_bias
=
self
.
_use_bias
,
use_bias
=
self
.
_use_bias
,
kernel_initializer
=
self
.
_kernel_initializer
,
kernel_initializer
=
self
.
_kernel_initializer
,
bias_initializer
=
self
.
_bias_initializer
,
bias_initializer
=
self
.
_bias_initializer
,
bias_regularizer
=
self
.
_bias_regularizer
,
bias_regularizer
=
self
.
_bias_regularizer
,
weight_decay
=
self
.
_weight_decay
,
weight_decay
=
self
.
_weight_decay
,
use_bn
=
self
.
_use_bn
,
use_bn
=
self
.
_use_bn
,
use_sync_bn
=
self
.
_use_sync_bn
,
use_sync_bn
=
self
.
_use_sync_bn
,
...
@@ -123,12 +125,12 @@ class CSPTiny(ks.layers.Layer):
...
@@ -123,12 +125,12 @@ class CSPTiny(ks.layers.Layer):
def
call
(
self
,
inputs
):
def
call
(
self
,
inputs
):
x1
=
self
.
_convlayer1
(
inputs
)
x1
=
self
.
_convlayer1
(
inputs
)
x2
=
tf
.
split
(
x1
,
self
.
_groups
,
axis
=
-
1
)
x2
=
tf
.
split
(
x1
,
self
.
_groups
,
axis
=
-
1
)
x3
=
self
.
_convlayer2
(
x2
[
self
.
_group_id
])
x3
=
self
.
_convlayer2
(
x2
[
self
.
_group_id
])
x4
=
self
.
_convlayer3
(
x3
)
x4
=
self
.
_convlayer3
(
x3
)
x5
=
tf
.
concat
([
x4
,
x3
],
axis
=
-
1
)
x5
=
tf
.
concat
([
x4
,
x3
],
axis
=
-
1
)
x6
=
self
.
_convlayer4
(
x5
)
x6
=
self
.
_convlayer4
(
x5
)
x
=
tf
.
concat
([
x1
,
x6
],
axis
=
-
1
)
x
=
tf
.
concat
([
x1
,
x6
],
axis
=-
1
)
if
self
.
_downsample
:
if
self
.
_downsample
:
x
=
self
.
_maxpool
(
x
)
x
=
self
.
_maxpool
(
x
)
return
x
,
x6
return
x
,
x6
...
...
official/vision/beta/projects/yolo/modeling/building_blocks/_DarkConv.py
View file @
e43d75f3
...
@@ -11,6 +11,7 @@ from yolo.modeling.functions.mish_activation import mish
...
@@ -11,6 +11,7 @@ from yolo.modeling.functions.mish_activation import mish
@
ks
.
utils
.
register_keras_serializable
(
package
=
'yolo'
)
@
ks
.
utils
.
register_keras_serializable
(
package
=
'yolo'
)
class
DarkConv
(
ks
.
layers
.
Layer
):
class
DarkConv
(
ks
.
layers
.
Layer
):
def
__init__
(
def
__init__
(
self
,
self
,
filters
=
1
,
filters
=
1
,
...
@@ -122,8 +123,7 @@ class DarkConv(ks.layers.Layer):
...
@@ -122,8 +123,7 @@ class DarkConv(ks.layers.Layer):
epsilon
=
self
.
_norm_epsilon
,
epsilon
=
self
.
_norm_epsilon
,
axis
=
self
.
_bn_axis
)
axis
=
self
.
_bn_axis
)
else
:
else
:
self
.
bn
=
ks
.
layers
.
BatchNormalization
(
self
.
bn
=
ks
.
layers
.
BatchNormalization
(
momentum
=
self
.
_norm_moment
,
momentum
=
self
.
_norm_moment
,
epsilon
=
self
.
_norm_epsilon
,
epsilon
=
self
.
_norm_epsilon
,
axis
=
self
.
_bn_axis
)
axis
=
self
.
_bn_axis
)
else
:
else
:
...
@@ -135,8 +135,7 @@ class DarkConv(ks.layers.Layer):
...
@@ -135,8 +135,7 @@ class DarkConv(ks.layers.Layer):
elif
self
.
_activation
==
'mish'
:
elif
self
.
_activation
==
'mish'
:
self
.
_activation_fn
=
mish
()
self
.
_activation_fn
=
mish
()
else
:
else
:
self
.
_activation_fn
=
ks
.
layers
.
Activation
(
self
.
_activation_fn
=
ks
.
layers
.
Activation
(
activation
=
self
.
_activation
)
activation
=
self
.
_activation
)
super
(
DarkConv
,
self
).
build
(
input_shape
)
super
(
DarkConv
,
self
).
build
(
input_shape
)
return
return
...
...
official/vision/beta/projects/yolo/modeling/building_blocks/_DarkResidual.py
View file @
e43d75f3
...
@@ -7,14 +7,15 @@ from ._Identity import Identity
...
@@ -7,14 +7,15 @@ from ._Identity import Identity
@
ks
.
utils
.
register_keras_serializable
(
package
=
'yolo'
)
@
ks
.
utils
.
register_keras_serializable
(
package
=
'yolo'
)
class
DarkResidual
(
ks
.
layers
.
Layer
):
class
DarkResidual
(
ks
.
layers
.
Layer
):
def
__init__
(
self
,
def
__init__
(
self
,
filters
=
1
,
filters
=
1
,
filter_scale
=
2
,
filter_scale
=
2
,
use_bias
=
True
,
use_bias
=
True
,
kernel_initializer
=
'glorot_uniform'
,
kernel_initializer
=
'glorot_uniform'
,
bias_initializer
=
'zeros'
,
bias_initializer
=
'zeros'
,
weight_decay
=
None
,
weight_decay
=
None
,
bias_regularizer
=
None
,
bias_regularizer
=
None
,
use_bn
=
True
,
use_bn
=
True
,
use_sync_bn
=
False
,
use_sync_bn
=
False
,
norm_momentum
=
0.99
,
norm_momentum
=
0.99
,
...
@@ -58,7 +59,7 @@ class DarkResidual(ks.layers.Layer):
...
@@ -58,7 +59,7 @@ class DarkResidual(ks.layers.Layer):
self
.
_bias_regularizer
=
bias_regularizer
self
.
_bias_regularizer
=
bias_regularizer
self
.
_use_bn
=
use_bn
self
.
_use_bn
=
use_bn
self
.
_use_sync_bn
=
use_sync_bn
self
.
_use_sync_bn
=
use_sync_bn
self
.
_weight_decay
=
weight_decay
self
.
_weight_decay
=
weight_decay
# normal params
# normal params
self
.
_norm_moment
=
norm_momentum
self
.
_norm_moment
=
norm_momentum
...
@@ -124,8 +125,7 @@ class DarkResidual(ks.layers.Layer):
...
@@ -124,8 +125,7 @@ class DarkResidual(ks.layers.Layer):
leaky_alpha
=
self
.
_leaky_alpha
)
leaky_alpha
=
self
.
_leaky_alpha
)
self
.
_shortcut
=
ks
.
layers
.
Add
()
self
.
_shortcut
=
ks
.
layers
.
Add
()
self
.
_activation_fn
=
ks
.
layers
.
Activation
(
self
.
_activation_fn
=
ks
.
layers
.
Activation
(
activation
=
self
.
_sc_activation
)
activation
=
self
.
_sc_activation
)
super
().
build
(
input_shape
)
super
().
build
(
input_shape
)
return
return
...
...
official/vision/beta/projects/yolo/modeling/building_blocks/_DarkTiny.py
View file @
e43d75f3
...
@@ -6,14 +6,16 @@ from ._DarkConv import DarkConv
...
@@ -6,14 +6,16 @@ from ._DarkConv import DarkConv
@
ks
.
utils
.
register_keras_serializable
(
package
=
'yolo'
)
@
ks
.
utils
.
register_keras_serializable
(
package
=
'yolo'
)
class
DarkTiny
(
ks
.
layers
.
Layer
):
class
DarkTiny
(
ks
.
layers
.
Layer
):
def
__init__
(
self
,
def
__init__
(
self
,
filters
=
1
,
filters
=
1
,
use_bias
=
True
,
use_bias
=
True
,
strides
=
2
,
strides
=
2
,
kernel_initializer
=
'glorot_uniform'
,
kernel_initializer
=
'glorot_uniform'
,
bias_initializer
=
'zeros'
,
bias_initializer
=
'zeros'
,
bias_regularizer
=
None
,
bias_regularizer
=
None
,
weight_decay
=
None
,
# default find where is it is stated
weight_decay
=
None
,
# default find where is it is stated
use_bn
=
True
,
use_bn
=
True
,
use_sync_bn
=
False
,
use_sync_bn
=
False
,
norm_momentum
=
0.99
,
norm_momentum
=
0.99
,
...
@@ -28,11 +30,11 @@ class DarkTiny(ks.layers.Layer):
...
@@ -28,11 +30,11 @@ class DarkTiny(ks.layers.Layer):
self
.
_use_bias
=
use_bias
self
.
_use_bias
=
use_bias
self
.
_kernel_initializer
=
kernel_initializer
self
.
_kernel_initializer
=
kernel_initializer
self
.
_bias_initializer
=
bias_initializer
self
.
_bias_initializer
=
bias_initializer
self
.
_bias_regularizer
=
bias_regularizer
self
.
_bias_regularizer
=
bias_regularizer
self
.
_use_bn
=
use_bn
self
.
_use_bn
=
use_bn
self
.
_use_sync_bn
=
use_sync_bn
self
.
_use_sync_bn
=
use_sync_bn
self
.
_strides
=
strides
self
.
_strides
=
strides
self
.
_weight_decay
=
weight_decay
self
.
_weight_decay
=
weight_decay
# normal params
# normal params
self
.
_norm_moment
=
norm_momentum
self
.
_norm_moment
=
norm_momentum
...
...
official/vision/beta/projects/yolo/modeling/building_blocks/__init__.py
View file @
e43d75f3
...
@@ -4,4 +4,3 @@ from ._DarkTiny import DarkTiny
...
@@ -4,4 +4,3 @@ from ._DarkTiny import DarkTiny
from
._CSPConnect
import
CSPConnect
from
._CSPConnect
import
CSPConnect
from
._CSPDownSample
import
CSPDownSample
from
._CSPDownSample
import
CSPDownSample
from
._CSPTiny
import
CSPTiny
from
._CSPTiny
import
CSPTiny
official/vision/beta/projects/yolo/modeling/tests/test_CSPConnect.py
View file @
e43d75f3
...
@@ -8,6 +8,7 @@ from official.vision.beta.projects.yolo.modeling.building_blocks import CSPConne
...
@@ -8,6 +8,7 @@ from official.vision.beta.projects.yolo.modeling.building_blocks import CSPConne
class
CSPConnect
(
tf
.
test
.
TestCase
,
parameterized
.
TestCase
):
class
CSPConnect
(
tf
.
test
.
TestCase
,
parameterized
.
TestCase
):
@
parameterized
.
named_parameters
((
"same"
,
224
,
224
,
64
,
1
),
@
parameterized
.
named_parameters
((
"same"
,
224
,
224
,
64
,
1
),
(
"downsample"
,
224
,
224
,
64
,
2
))
(
"downsample"
,
224
,
224
,
64
,
2
))
def
test_pass_through
(
self
,
width
,
height
,
filters
,
mod
):
def
test_pass_through
(
self
,
width
,
height
,
filters
,
mod
):
...
@@ -33,8 +34,8 @@ class CSPConnect(tf.test.TestCase, parameterized.TestCase):
...
@@ -33,8 +34,8 @@ class CSPConnect(tf.test.TestCase, parameterized.TestCase):
path_layer
=
layer_companion
(
filters
,
filter_reduce
=
mod
)
path_layer
=
layer_companion
(
filters
,
filter_reduce
=
mod
)
init
=
tf
.
random_normal_initializer
()
init
=
tf
.
random_normal_initializer
()
x
=
tf
.
Variable
(
initial_value
=
init
(
shape
=
(
1
,
width
,
height
,
filters
),
x
=
tf
.
Variable
(
dtype
=
tf
.
float32
))
initial_value
=
init
(
shape
=
(
1
,
width
,
height
,
filters
),
dtype
=
tf
.
float32
))
y
=
tf
.
Variable
(
initial_value
=
init
(
shape
=
(
1
,
int
(
np
.
ceil
(
width
//
2
)),
y
=
tf
.
Variable
(
initial_value
=
init
(
shape
=
(
1
,
int
(
np
.
ceil
(
width
//
2
)),
int
(
np
.
ceil
(
height
//
2
)),
int
(
np
.
ceil
(
height
//
2
)),
filters
),
filters
),
...
...
official/vision/beta/projects/yolo/modeling/tests/test_CSPDownSample.py
View file @
e43d75f3
...
@@ -6,7 +6,9 @@ from absl.testing import parameterized
...
@@ -6,7 +6,9 @@ from absl.testing import parameterized
from
official.vision.beta.projects.yolo.modeling.building_blocks
import
CSPDownSample
as
layer
from
official.vision.beta.projects.yolo.modeling.building_blocks
import
CSPDownSample
as
layer
from
official.vision.beta.projects.yolo.modeling.building_blocks
import
CSPConnect
as
layer_companion
from
official.vision.beta.projects.yolo.modeling.building_blocks
import
CSPConnect
as
layer_companion
class
CSPDownSample
(
tf
.
test
.
TestCase
,
parameterized
.
TestCase
):
class
CSPDownSample
(
tf
.
test
.
TestCase
,
parameterized
.
TestCase
):
@
parameterized
.
named_parameters
((
"same"
,
224
,
224
,
64
,
1
),
@
parameterized
.
named_parameters
((
"same"
,
224
,
224
,
64
,
1
),
(
"downsample"
,
224
,
224
,
64
,
2
))
(
"downsample"
,
224
,
224
,
64
,
2
))
def
test_pass_through
(
self
,
width
,
height
,
filters
,
mod
):
def
test_pass_through
(
self
,
width
,
height
,
filters
,
mod
):
...
@@ -17,8 +19,7 @@ class CSPDownSample(tf.test.TestCase, parameterized.TestCase):
...
@@ -17,8 +19,7 @@ class CSPDownSample(tf.test.TestCase, parameterized.TestCase):
print
(
outx
.
shape
.
as_list
())
print
(
outx
.
shape
.
as_list
())
self
.
assertAllEqual
(
self
.
assertAllEqual
(
outx
.
shape
.
as_list
(),
outx
.
shape
.
as_list
(),
[
None
,
[
None
,
np
.
ceil
(
width
//
2
),
np
.
ceil
(
width
//
2
),
np
.
ceil
(
height
//
2
),
(
filters
/
mod
)])
np
.
ceil
(
height
//
2
),
(
filters
/
mod
)])
return
return
...
@@ -31,8 +32,8 @@ class CSPDownSample(tf.test.TestCase, parameterized.TestCase):
...
@@ -31,8 +32,8 @@ class CSPDownSample(tf.test.TestCase, parameterized.TestCase):
path_layer
=
layer_companion
(
filters
,
filter_reduce
=
mod
)
path_layer
=
layer_companion
(
filters
,
filter_reduce
=
mod
)
init
=
tf
.
random_normal_initializer
()
init
=
tf
.
random_normal_initializer
()
x
=
tf
.
Variable
(
initial_value
=
init
(
shape
=
(
1
,
width
,
height
,
filters
),
x
=
tf
.
Variable
(
dtype
=
tf
.
float32
))
initial_value
=
init
(
shape
=
(
1
,
width
,
height
,
filters
),
dtype
=
tf
.
float32
))
y
=
tf
.
Variable
(
initial_value
=
init
(
shape
=
(
1
,
int
(
np
.
ceil
(
width
//
2
)),
y
=
tf
.
Variable
(
initial_value
=
init
(
shape
=
(
1
,
int
(
np
.
ceil
(
width
//
2
)),
int
(
np
.
ceil
(
height
//
2
)),
int
(
np
.
ceil
(
height
//
2
)),
filters
),
filters
),
...
...
official/vision/beta/projects/yolo/modeling/tests/test_DarkConv.py
View file @
e43d75f3
...
@@ -5,11 +5,12 @@ from absl.testing import parameterized
...
@@ -5,11 +5,12 @@ from absl.testing import parameterized
from
official.vision.beta.projects.yolo.modeling.building_blocks
import
DarkConv
from
official.vision.beta.projects.yolo.modeling.building_blocks
import
DarkConv
class
DarkConvTest
(
tf
.
test
.
TestCase
,
parameterized
.
TestCase
):
class
DarkConvTest
(
tf
.
test
.
TestCase
,
parameterized
.
TestCase
):
@
parameterized
.
named_parameters
((
"valid"
,
(
3
,
3
),
"valid"
,
(
1
,
1
)),
(
"same"
,
(
3
,
3
),
"same"
,
(
1
,
1
)),
@
parameterized
.
named_parameters
(
(
"down
sam
pl
e"
,
(
3
,
3
),
"same"
,
(
2
,
2
)),
(
"valid"
,
(
3
,
3
),
"valid"
,
(
1
,
1
)),
(
"
same"
,
(
3
,
3
),
"same"
,
(
1
,
1
)),
(
"test"
,
(
1
,
1
),
"valid"
,
(
1
,
1
)))
(
"downsample"
,
(
3
,
3
),
"same"
,
(
2
,
2
)),
(
"test"
,
(
1
,
1
),
"valid"
,
(
1
,
1
)))
def
test_pass_through
(
self
,
kernel_size
,
padding
,
strides
):
def
test_pass_through
(
self
,
kernel_size
,
padding
,
strides
):
if
padding
==
"same"
:
if
padding
==
"same"
:
pad_const
=
1
pad_const
=
1
...
@@ -40,8 +41,8 @@ class DarkConvTest(tf.test.TestCase, parameterized.TestCase):
...
@@ -40,8 +41,8 @@ class DarkConvTest(tf.test.TestCase, parameterized.TestCase):
test_layer
=
DarkConv
(
filters
,
kernel_size
=
(
3
,
3
),
padding
=
"same"
)
test_layer
=
DarkConv
(
filters
,
kernel_size
=
(
3
,
3
),
padding
=
"same"
)
init
=
tf
.
random_normal_initializer
()
init
=
tf
.
random_normal_initializer
()
x
=
tf
.
Variable
(
x
=
tf
.
Variable
(
initial_value
=
init
(
shape
=
(
1
,
224
,
224
,
initial_value
=
init
(
shape
=
(
1
,
224
,
224
,
3
),
dtype
=
tf
.
float32
))
3
),
dtype
=
tf
.
float32
))
y
=
tf
.
Variable
(
y
=
tf
.
Variable
(
initial_value
=
init
(
shape
=
(
1
,
224
,
224
,
filters
),
dtype
=
tf
.
float32
))
initial_value
=
init
(
shape
=
(
1
,
224
,
224
,
filters
),
dtype
=
tf
.
float32
))
...
...
official/vision/beta/projects/yolo/modeling/tests/test_DarkResidual.py
View file @
e43d75f3
...
@@ -7,6 +7,7 @@ from official.vision.beta.projects.yolo.modeling.building_blocks import DarkResi
...
@@ -7,6 +7,7 @@ from official.vision.beta.projects.yolo.modeling.building_blocks import DarkResi
class
DarkResidualTest
(
tf
.
test
.
TestCase
,
parameterized
.
TestCase
):
class
DarkResidualTest
(
tf
.
test
.
TestCase
,
parameterized
.
TestCase
):
@
parameterized
.
named_parameters
((
"same"
,
224
,
224
,
64
,
False
),
@
parameterized
.
named_parameters
((
"same"
,
224
,
224
,
64
,
False
),
(
"downsample"
,
223
,
223
,
32
,
True
),
(
"downsample"
,
223
,
223
,
32
,
True
),
(
"oddball"
,
223
,
223
,
32
,
False
))
(
"oddball"
,
223
,
223
,
32
,
False
))
...
@@ -39,8 +40,8 @@ class DarkResidualTest(tf.test.TestCase, parameterized.TestCase):
...
@@ -39,8 +40,8 @@ class DarkResidualTest(tf.test.TestCase, parameterized.TestCase):
mod
=
1
mod
=
1
init
=
tf
.
random_normal_initializer
()
init
=
tf
.
random_normal_initializer
()
x
=
tf
.
Variable
(
initial_value
=
init
(
shape
=
(
1
,
width
,
height
,
filters
),
x
=
tf
.
Variable
(
dtype
=
tf
.
float32
))
initial_value
=
init
(
shape
=
(
1
,
width
,
height
,
filters
),
dtype
=
tf
.
float32
))
y
=
tf
.
Variable
(
initial_value
=
init
(
shape
=
(
1
,
int
(
np
.
ceil
(
width
/
mod
)),
y
=
tf
.
Variable
(
initial_value
=
init
(
shape
=
(
1
,
int
(
np
.
ceil
(
width
/
mod
)),
int
(
np
.
ceil
(
height
/
mod
)),
int
(
np
.
ceil
(
height
/
mod
)),
filters
),
filters
),
...
...
official/vision/beta/projects/yolo/modeling/tests/test_DarkTiny.py
View file @
e43d75f3
...
@@ -7,6 +7,7 @@ from official.vision.beta.projects.yolo.modeling.building_blocks import DarkTiny
...
@@ -7,6 +7,7 @@ from official.vision.beta.projects.yolo.modeling.building_blocks import DarkTiny
class
DarkTinyTest
(
tf
.
test
.
TestCase
,
parameterized
.
TestCase
):
class
DarkTinyTest
(
tf
.
test
.
TestCase
,
parameterized
.
TestCase
):
@
parameterized
.
named_parameters
((
"middle"
,
224
,
224
,
64
,
2
),
@
parameterized
.
named_parameters
((
"middle"
,
224
,
224
,
64
,
2
),
(
"last"
,
224
,
224
,
1024
,
1
))
(
"last"
,
224
,
224
,
1024
,
1
))
def
test_pass_through
(
self
,
width
,
height
,
filters
,
strides
):
def
test_pass_through
(
self
,
width
,
height
,
filters
,
strides
):
...
@@ -17,8 +18,7 @@ class DarkTinyTest(tf.test.TestCase, parameterized.TestCase):
...
@@ -17,8 +18,7 @@ class DarkTinyTest(tf.test.TestCase, parameterized.TestCase):
print
(
outx
.
shape
.
as_list
())
print
(
outx
.
shape
.
as_list
())
self
.
assertEqual
(
width
%
strides
,
0
,
msg
=
"width % strides != 0"
)
self
.
assertEqual
(
width
%
strides
,
0
,
msg
=
"width % strides != 0"
)
self
.
assertEqual
(
height
%
strides
,
0
,
msg
=
"height % strides != 0"
)
self
.
assertEqual
(
height
%
strides
,
0
,
msg
=
"height % strides != 0"
)
self
.
assertAllEqual
(
self
.
assertAllEqual
(
outx
.
shape
.
as_list
(),
outx
.
shape
.
as_list
(),
[
None
,
width
//
strides
,
height
//
strides
,
filters
])
[
None
,
width
//
strides
,
height
//
strides
,
filters
])
return
return
...
@@ -30,8 +30,8 @@ class DarkTinyTest(tf.test.TestCase, parameterized.TestCase):
...
@@ -30,8 +30,8 @@ class DarkTinyTest(tf.test.TestCase, parameterized.TestCase):
test_layer
=
DarkTiny
(
filters
=
filters
,
strides
=
strides
)
test_layer
=
DarkTiny
(
filters
=
filters
,
strides
=
strides
)
init
=
tf
.
random_normal_initializer
()
init
=
tf
.
random_normal_initializer
()
x
=
tf
.
Variable
(
initial_value
=
init
(
shape
=
(
1
,
width
,
height
,
filters
),
x
=
tf
.
Variable
(
dtype
=
tf
.
float32
))
initial_value
=
init
(
shape
=
(
1
,
width
,
height
,
filters
),
dtype
=
tf
.
float32
))
y
=
tf
.
Variable
(
initial_value
=
init
(
shape
=
(
1
,
width
//
strides
,
y
=
tf
.
Variable
(
initial_value
=
init
(
shape
=
(
1
,
width
//
strides
,
height
//
strides
,
filters
),
height
//
strides
,
filters
),
dtype
=
tf
.
float32
))
dtype
=
tf
.
float32
))
...
...
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