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
59aad7fc
Commit
59aad7fc
authored
Jun 30, 2021
by
A. Unique TensorFlower
Browse files
Add placeholder for Adafactor optimizer.
PiperOrigin-RevId: 382396878
parent
37392bef
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
2 deletions
+44
-2
official/modeling/optimization/adafactor_optimizer.py
official/modeling/optimization/adafactor_optimizer.py
+20
-0
official/modeling/optimization/configs/optimization_config.py
...cial/modeling/optimization/configs/optimization_config.py
+1
-0
official/modeling/optimization/configs/optimizer_config.py
official/modeling/optimization/configs/optimizer_config.py
+19
-0
official/modeling/optimization/optimizer_factory.py
official/modeling/optimization/optimizer_factory.py
+3
-1
official/modeling/optimization/optimizer_factory_test.py
official/modeling/optimization/optimizer_factory_test.py
+1
-1
No files found.
official/modeling/optimization/adafactor_optimizer.py
0 → 100644
View file @
59aad7fc
# Copyright 2021 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Adafactor optimizer.
A new optimizer that will be open sourced soon.
"""
# pylint: disable=invalid-name, represents an unimplemented class definition.
Adafactor
=
"Unimplemented"
official/modeling/optimization/configs/optimization_config.py
View file @
59aad7fc
...
...
@@ -52,6 +52,7 @@ class OptimizerConfig(oneof.OneOfConfig):
lars
:
opt_cfg
.
LARSConfig
=
opt_cfg
.
LARSConfig
()
adagrad
:
opt_cfg
.
AdagradConfig
=
opt_cfg
.
AdagradConfig
()
slide
:
opt_cfg
.
SLIDEConfig
=
opt_cfg
.
SLIDEConfig
()
adafactor
:
opt_cfg
.
AdafactorConfig
=
opt_cfg
.
AdafactorConfig
()
@
dataclasses
.
dataclass
...
...
official/modeling/optimization/configs/optimizer_config.py
View file @
59aad7fc
...
...
@@ -247,3 +247,22 @@ class SLIDEConfig(BaseOptimizerConfig):
do_gradient_rescaling
:
bool
=
True
norm_type
:
str
=
"layer"
ratio_clip_norm
:
float
=
1e5
@
dataclasses
.
dataclass
class
AdafactorConfig
(
BaseOptimizerConfig
):
"""Configuration for Adafactor optimizer.
The attributes for this class matches the arguments of the Adafactor
implementation.
"""
name
:
str
=
"Adafactor"
factored
:
bool
=
True
multiply_by_parameter_scale
:
bool
=
True
beta1
:
Optional
[
float
]
=
None
decay_rate
:
float
=
0.8
step_offset
:
int
=
0
clipping_threshold
:
float
=
1.0
min_dim_size_to_factor
:
int
=
128
epsilon1
:
float
=
1e-30
epsilon2
:
float
=
1e-3
official/modeling/optimization/optimizer_factory.py
View file @
59aad7fc
...
...
@@ -20,6 +20,7 @@ import tensorflow as tf
import
tensorflow_addons.optimizers
as
tfa_optimizers
from
official.modeling.optimization
import
slide_optimizer
from
official.modeling.optimization
import
adafactor_optimizer
from
official.modeling.optimization
import
ema_optimizer
from
official.modeling.optimization
import
lars_optimizer
from
official.modeling.optimization
import
lr_schedule
...
...
@@ -34,7 +35,8 @@ OPTIMIZERS_CLS = {
'rmsprop'
:
tf
.
keras
.
optimizers
.
RMSprop
,
'lars'
:
lars_optimizer
.
LARS
,
'adagrad'
:
tf
.
keras
.
optimizers
.
Adagrad
,
'slide'
:
slide_optimizer
.
SLIDE
'slide'
:
slide_optimizer
.
SLIDE
,
'adafactor'
:
adafactor_optimizer
.
Adafactor
,
}
LR_CLS
=
{
...
...
official/modeling/optimization/optimizer_factory_test.py
View file @
59aad7fc
...
...
@@ -24,7 +24,7 @@ from official.modeling.optimization.configs import optimization_config
class
OptimizerFactoryTest
(
tf
.
test
.
TestCase
,
parameterized
.
TestCase
):
@
parameterized
.
parameters
((
'sgd'
),
(
'rmsprop'
),
(
'adam'
),
(
'adamw'
),
(
'lamb'
),
(
'lars'
),
(
'adagrad'
))
(
'lars'
),
(
'adagrad'
)
,
(
'adafactor'
)
)
def
test_optimizers
(
self
,
optimizer_type
):
params
=
{
'optimizer'
:
{
...
...
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