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
2199608c
Unverified
Commit
2199608c
authored
Apr 05, 2021
by
Sylvain Gugger
Committed by
GitHub
Apr 05, 2021
Browse files
Make a base init in FeatureExtractionMixin (#11074)
parent
04ceee7d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
7 deletions
+11
-7
src/transformers/feature_extraction_sequence_utils.py
src/transformers/feature_extraction_sequence_utils.py
+1
-7
src/transformers/feature_extraction_utils.py
src/transformers/feature_extraction_utils.py
+10
-0
No files found.
src/transformers/feature_extraction_sequence_utils.py
View file @
2199608c
...
...
@@ -56,13 +56,7 @@ class SequenceFeatureExtractor(FeatureExtractionMixin):
self
.
padding_side
=
kwargs
.
pop
(
"padding_side"
,
"right"
)
self
.
return_attention_mask
=
kwargs
.
pop
(
"return_attention_mask"
,
True
)
# Additional attributes without default values
for
key
,
value
in
kwargs
.
items
():
try
:
setattr
(
self
,
key
,
value
)
except
AttributeError
as
err
:
logger
.
error
(
f
"Can't set
{
key
}
with value
{
value
}
for
{
self
}
"
)
raise
err
super
().
__init__
(
**
kwargs
)
def
pad
(
self
,
...
...
src/transformers/feature_extraction_utils.py
View file @
2199608c
...
...
@@ -197,6 +197,16 @@ class FeatureExtractionMixin:
extractors.
"""
def
__init__
(
self
,
**
kwargs
):
"""Set elements of `kwargs` as attributes."""
# Additional attributes without default values
for
key
,
value
in
kwargs
.
items
():
try
:
setattr
(
self
,
key
,
value
)
except
AttributeError
as
err
:
logger
.
error
(
f
"Can't set
{
key
}
with value
{
value
}
for
{
self
}
"
)
raise
err
@
classmethod
def
from_pretrained
(
cls
,
pretrained_model_name_or_path
:
Union
[
str
,
os
.
PathLike
],
**
kwargs
...
...
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