Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
04cddaf4
Unverified
Commit
04cddaf4
authored
Dec 30, 2021
by
Jake Tae
Committed by
GitHub
Dec 29, 2021
Browse files
refactor: replace `assert` with `ValueError` (#14970)
parent
600496fa
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
7 deletions
+2
-7
src/transformers/models/bert_generation/modeling_bert_generation.py
...ormers/models/bert_generation/modeling_bert_generation.py
+2
-7
No files found.
src/transformers/models/bert_generation/modeling_bert_generation.py
View file @
04cddaf4
...
@@ -114,13 +114,8 @@ def load_tf_weights_in_bert_generation(
...
@@ -114,13 +114,8 @@ def load_tf_weights_in_bert_generation(
else
:
else
:
model_pointer
=
model_pointer
.
weight
model_pointer
=
model_pointer
.
weight
try
:
if
model_pointer
.
shape
!=
array
.
shape
:
assert
(
raise
ValueError
(
f
"Pointer shape
{
model_pointer
.
shape
}
and array shape
{
array
.
shape
}
mismatched"
)
model_pointer
.
shape
==
array
.
shape
),
f
"Pointer shape
{
model_pointer
.
shape
}
and array shape
{
array
.
shape
}
mismatched"
except
AssertionError
as
e
:
e
.
args
+=
(
model_pointer
.
shape
,
array
.
shape
)
raise
logger
.
info
(
f
"Initialize PyTorch weight
{
key
}
"
)
logger
.
info
(
f
"Initialize PyTorch weight
{
key
}
"
)
model_pointer
.
data
=
torch
.
from_numpy
(
array
.
astype
(
np
.
float32
))
model_pointer
.
data
=
torch
.
from_numpy
(
array
.
astype
(
np
.
float32
))
...
...
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