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
a7b62fec
"...git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "f5f1e52f6cf13cdf63ff25c311d33e2f2a842911"
Unverified
Commit
a7b62fec
authored
Jan 20, 2021
by
Sylvain Gugger
Committed by
GitHub
Jan 20, 2021
Browse files
Fix Funnel Transformer conversion script (#9683)
parent
8940c766
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
+9
-4
src/transformers/models/funnel/convert_funnel_original_tf_checkpoint_to_pytorch.py
...unnel/convert_funnel_original_tf_checkpoint_to_pytorch.py
+9
-4
No files found.
src/transformers/models/funnel/convert_funnel_original_tf_checkpoint_to_pytorch.py
View file @
a7b62fec
...
...
@@ -19,18 +19,18 @@ import argparse
import
torch
from
transformers
import
Funnel
Config
,
FunnelForPreTraining
,
load_tf_weights_in_funnel
from
transformers
import
Funnel
BaseModel
,
FunnelConfig
,
FunnelModel
,
load_tf_weights_in_funnel
from
transformers.utils
import
logging
logging
.
set_verbosity_info
()
def
convert_tf_checkpoint_to_pytorch
(
tf_checkpoint_path
,
config_file
,
pytorch_dump_path
):
def
convert_tf_checkpoint_to_pytorch
(
tf_checkpoint_path
,
config_file
,
pytorch_dump_path
,
base_model
):
# Initialise PyTorch model
config
=
FunnelConfig
.
from_json_file
(
config_file
)
print
(
"Building PyTorch model from configuration: {}"
.
format
(
str
(
config
)))
model
=
Funnel
ForPreTraining
(
config
)
model
=
Funnel
BaseModel
(
config
)
if
base_model
else
FunnelModel
(
config
)
# Load weights from tf checkpoint
load_tf_weights_in_funnel
(
model
,
config
,
tf_checkpoint_path
)
...
...
@@ -57,5 +57,10 @@ if __name__ == "__main__":
parser
.
add_argument
(
"--pytorch_dump_path"
,
default
=
None
,
type
=
str
,
required
=
True
,
help
=
"Path to the output PyTorch model."
)
parser
.
add_argument
(
"--base_model"
,
action
=
"store_true"
,
help
=
"Whether you want just the base model (no decoder) or not."
)
args
=
parser
.
parse_args
()
convert_tf_checkpoint_to_pytorch
(
args
.
tf_checkpoint_path
,
args
.
config_file
,
args
.
pytorch_dump_path
)
convert_tf_checkpoint_to_pytorch
(
args
.
tf_checkpoint_path
,
args
.
config_file
,
args
.
pytorch_dump_path
,
args
.
base_model
)
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