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
chenpangpang
transformers
Commits
69850b40
Commit
69850b40
authored
Apr 21, 2019
by
lukovnikov
Browse files
python 2 compat
parent
bb7557d3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
+9
-2
pytorch_pretrained_bert/optimization.py
pytorch_pretrained_bert/optimization.py
+9
-2
No files found.
pytorch_pretrained_bert/optimization.py
View file @
69850b40
...
@@ -20,11 +20,18 @@ from torch.optim import Optimizer
...
@@ -20,11 +20,18 @@ from torch.optim import Optimizer
from
torch.optim.optimizer
import
required
from
torch.optim.optimizer
import
required
from
torch.nn.utils
import
clip_grad_norm_
from
torch.nn.utils
import
clip_grad_norm_
import
logging
import
logging
from
abc
import
ABC
,
abstractmethod
import
abc
import
sys
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
if
sys
.
version_info
>=
(
3
,
4
):
ABC
=
abc
.
ABC
else
:
ABC
=
abc
.
ABCMeta
(
'ABC'
,
(),
{})
class
_LRSchedule
(
ABC
):
class
_LRSchedule
(
ABC
):
""" Parent of all LRSchedules here. """
""" Parent of all LRSchedules here. """
warn_t_total
=
False
# is set to True for schedules where progressing beyond t_total steps doesn't make sense
warn_t_total
=
False
# is set to True for schedules where progressing beyond t_total steps doesn't make sense
...
@@ -62,7 +69,7 @@ class _LRSchedule(ABC):
...
@@ -62,7 +69,7 @@ class _LRSchedule(ABC):
# end warning
# end warning
return
ret
return
ret
@
abstractmethod
@
abc
.
abstractmethod
def
get_lr_
(
self
,
progress
):
def
get_lr_
(
self
,
progress
):
"""
"""
:param progress: value between 0 and 1 (unless going beyond t_total steps) specifying training progress
:param progress: value between 0 and 1 (unless going beyond t_total steps) specifying training progress
...
...
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