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
2f32dfd3
Commit
2f32dfd3
authored
Jan 11, 2020
by
Julien Chaumond
Browse files
Convention: name mixins mixins
parent
055e80cf
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
5 deletions
+4
-5
src/transformers/modeling_tf_utils.py
src/transformers/modeling_tf_utils.py
+2
-2
src/transformers/modeling_utils.py
src/transformers/modeling_utils.py
+2
-2
tests/test_modeling_common.py
tests/test_modeling_common.py
+0
-1
No files found.
src/transformers/modeling_tf_utils.py
View file @
2f32dfd3
...
...
@@ -32,7 +32,7 @@ from .modeling_tf_pytorch_utils import load_pytorch_checkpoint_in_tf2_model
logger
=
logging
.
getLogger
(
__name__
)
class
TFModelUtils
:
class
TFModelUtils
Mixin
:
"""
A few utilities for `tf.keras.Model`s, to be used as a mixin.
"""
...
...
@@ -47,7 +47,7 @@ class TFModelUtils:
return
self
.
count_params
()
class
TFPreTrainedModel
(
tf
.
keras
.
Model
,
TFModelUtils
):
class
TFPreTrainedModel
(
tf
.
keras
.
Model
,
TFModelUtils
Mixin
):
r
""" Base class for all TF models.
:class:`~transformers.TFPreTrainedModel` takes care of storing the configuration of the models and handles methods for loading/downloading/saving models
...
...
src/transformers/modeling_utils.py
View file @
2f32dfd3
...
...
@@ -53,7 +53,7 @@ except ImportError:
return
input
class
ModuleUtils
:
class
ModuleUtils
Mixin
:
"""
A few utilities for torch.nn.Modules, to be used as a mixin.
"""
...
...
@@ -66,7 +66,7 @@ class ModuleUtils:
return
sum
(
p
.
numel
()
for
p
in
params
)
class
PreTrainedModel
(
nn
.
Module
,
ModuleUtils
):
class
PreTrainedModel
(
nn
.
Module
,
ModuleUtils
Mixin
):
r
""" Base class for all models.
:class:`~transformers.PreTrainedModel` takes care of storing the configuration of the models and handles methods for loading/downloading/saving models
...
...
tests/test_modeling_common.py
View file @
2f32dfd3
...
...
@@ -592,7 +592,6 @@ class ModelTesterMixin:
model
(
**
inputs_dict
)
global_rng
=
random
.
Random
()
...
...
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