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
bf4c3894
You need to sign in or sign up before continuing.
Commit
bf4c3894
authored
Sep 28, 2020
by
Shixin Luo
Browse files
add mobilenet experiment setup template
parent
b0ccdb11
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
134 additions
and
5 deletions
+134
-5
official/vision/beta/configs/experiments/image_classification/imagenet_mobilenetv2_1.0_gpu.yaml
...ts/image_classification/imagenet_mobilenetv2_1.0_gpu.yaml
+56
-0
official/vision/beta/configs/image_classification.py
official/vision/beta/configs/image_classification.py
+75
-4
official/vision/beta/configs/image_classification_test.py
official/vision/beta/configs/image_classification_test.py
+2
-1
official/vision/beta/modeling/backbones/mobilenet.py
official/vision/beta/modeling/backbones/mobilenet.py
+1
-0
No files found.
official/vision/beta/configs/experiments/image_classification/imagenet_mobilenetv2_1.0_gpu.yaml
0 → 100644
View file @
bf4c3894
runtime
:
distribution_strategy
:
'
mirrored'
mixed_precision_dtype
:
'
float32'
loss_scale
:
'
dynamic'
task
:
model
:
num_classes
:
1001
input_size
:
[
224
,
224
,
3
]
backbone
:
type
:
'
mobilenet'
mobilenet
:
model_id
:
'
MobileNetV2'
width_multiplier
:
1.0
dropout_rate
:
0.2
losses
:
l2_weight_decay
:
0.0001
one_hot
:
True
label_smoothing
:
0.1
train_data
:
input_path
:
'
imagenet-2012-tfrecord/train*'
is_training
:
True
global_batch_size
:
96
dtype
:
'
float32'
validation_data
:
input_path
:
'
imagenet-2012-tfrecord/valid*'
is_training
:
False
global_batch_size
:
96
dtype
:
'
float32'
drop_remainder
:
False
trainer
:
train_steps
:
1201050
# 90 * steps_per_epoch
validation_steps
:
520
validation_interval
:
13345
steps_per_loop
:
13345
# NUM_EXAMPLES (1281167) // global_batch_size
summary_interval
:
13345
checkpoint_interval
:
13345
optimizer_config
:
optimizer
:
type
:
'
rmsprop'
rmsprop
:
decay
:
0.9,
momentum
:
0.9,
epsilon
:
0.002,
learning_rate
:
type
:
'
exponential'
exponential
:
initial_learning_rate
:
0.045,
decay_steps
:
33362,
# 2.5 * steps_per_epoch
decay_rate
:
0.97,
staircase
:
True
warmup
:
type
:
'
linear'
linear
:
warmup_steps
:
66725
# 5 * steps_per_epoch
ema
:
average_decay
:
0.9999
\ No newline at end of file
official/vision/beta/configs/image_classification.py
View file @
bf4c3894
...
@@ -126,10 +126,10 @@ def image_classification_imagenet() -> cfg.ExperimentConfig:
...
@@ -126,10 +126,10 @@ def image_classification_imagenet() -> cfg.ExperimentConfig:
80
*
steps_per_epoch
80
*
steps_per_epoch
],
],
'values'
:
[
'values'
:
[
0.1
*
train_batch_size
/
256
,
0.1
*
train_batch_size
/
256
,
0.01
*
train_batch_size
/
256
,
0.01
*
train_batch_size
/
256
,
0.001
*
train_batch_size
/
256
,
0.001
*
train_batch_size
/
256
,
0.0001
*
train_batch_size
/
256
,
0.0001
*
train_batch_size
/
256
,
]
]
}
}
},
},
...
@@ -213,3 +213,74 @@ def image_classification_imagenet_revnet() -> cfg.ExperimentConfig:
...
@@ -213,3 +213,74 @@ def image_classification_imagenet_revnet() -> cfg.ExperimentConfig:
])
])
return
config
return
config
@
exp_factory
.
register_config_factory
(
'mobilenet_imagenet'
)
def
image_classification_imagenet_mobilenet
()
->
cfg
.
ExperimentConfig
:
"""Image classification on imagenet with mobilenet."""
train_batch_size
=
192
eval_batch_size
=
192
steps_per_epoch
=
IMAGENET_TRAIN_EXAMPLES
//
train_batch_size
config
=
cfg
.
ExperimentConfig
(
task
=
ImageClassificationTask
(
model
=
ImageClassificationModel
(
num_classes
=
1001
,
dropout_rate
=
0.2
,
input_size
=
[
224
,
224
,
3
],
backbone
=
backbones
.
Backbone
(
type
=
'mobilenet'
,
mobilenet
=
backbones
.
MobileNet
(
model_id
=
'MobileNetV2'
,
width_multiplier
=
1.0
)),
norm_activation
=
common
.
NormActivation
(
norm_momentum
=
0.9997
,
norm_epsilon
=
1e-3
)),
losses
=
Losses
(
l2_weight_decay
=
1e-4
,
label_smoothing
=
0.1
),
train_data
=
DataConfig
(
input_path
=
os
.
path
.
join
(
IMAGENET_INPUT_PATH_BASE
,
'train*'
),
is_training
=
True
,
global_batch_size
=
train_batch_size
),
validation_data
=
DataConfig
(
input_path
=
os
.
path
.
join
(
IMAGENET_INPUT_PATH_BASE
,
'valid*'
),
is_training
=
False
,
global_batch_size
=
eval_batch_size
)),
trainer
=
cfg
.
TrainerConfig
(
steps_per_loop
=
steps_per_epoch
,
summary_interval
=
steps_per_epoch
,
checkpoint_interval
=
steps_per_epoch
,
train_steps
=
90
*
steps_per_epoch
,
validation_steps
=
IMAGENET_VAL_EXAMPLES
//
eval_batch_size
,
validation_interval
=
steps_per_epoch
,
optimizer_config
=
optimization
.
OptimizationConfig
({
'optimizer'
:
{
'type'
:
'rmsprop'
,
'rmsprop'
:
{
'decay'
:
0.9
,
'momentum'
:
0.9
,
'epsilon'
:
0.002
,
}
},
'learning_rate'
:
{
'type'
:
'exponential'
,
'exponential'
:
{
'initial_learning_rate'
:
0.045
,
'decay_steps'
:
int
(
2.4
*
steps_per_epoch
),
'decay_rate'
:
0.97
,
'staircase'
:
True
}
},
'warmup'
:
{
'type'
:
'linear'
,
'linear'
:
{
'warmup_steps'
:
5
*
steps_per_epoch
,
'warmup_learning_rate'
:
0
}
},
'ema'
:
{
'average_decay'
:
0.9999
}
})),
restrictions
=
[
'task.train_data.is_training != None'
,
'task.validation_data.is_training != None'
])
return
config
official/vision/beta/configs/image_classification_test.py
View file @
bf4c3894
...
@@ -28,7 +28,8 @@ from official.vision.beta.configs import image_classification as exp_cfg
...
@@ -28,7 +28,8 @@ from official.vision.beta.configs import image_classification as exp_cfg
class
ImageClassificationConfigTest
(
tf
.
test
.
TestCase
,
parameterized
.
TestCase
):
class
ImageClassificationConfigTest
(
tf
.
test
.
TestCase
,
parameterized
.
TestCase
):
@
parameterized
.
parameters
((
'resnet_imagenet'
,),
@
parameterized
.
parameters
((
'resnet_imagenet'
,),
(
'revnet_imagenet'
,))
(
'revnet_imagenet'
,),
(
'mobilenet_imagenet'
),)
def
test_image_classification_configs
(
self
,
config_name
):
def
test_image_classification_configs
(
self
,
config_name
):
config
=
exp_factory
.
get_exp_config
(
config_name
)
config
=
exp_factory
.
get_exp_config
(
config_name
)
self
.
assertIsInstance
(
config
,
cfg
.
ExperimentConfig
)
self
.
assertIsInstance
(
config
,
cfg
.
ExperimentConfig
)
...
...
official/vision/beta/modeling/backbones/mobilenet.py
View file @
bf4c3894
...
@@ -593,6 +593,7 @@ class MobileNet(tf.keras.Model):
...
@@ -593,6 +593,7 @@ class MobileNet(tf.keras.Model):
"""A dict of {level: TensorShape} pairs for the model output."""
"""A dict of {level: TensorShape} pairs for the model output."""
return
self
.
_output_specs
return
self
.
_output_specs
@
factory
.
register_backbone_builder
(
'mobilenet'
)
@
factory
.
register_backbone_builder
(
'mobilenet'
)
def
build_mobilenet
(
def
build_mobilenet
(
input_specs
:
tf
.
keras
.
layers
.
InputSpec
,
input_specs
:
tf
.
keras
.
layers
.
InputSpec
,
...
...
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