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
e3139ad3
Unverified
Commit
e3139ad3
authored
Jul 04, 2022
by
Sreyan Ghosh
Committed by
GitHub
Jul 04, 2022
Browse files
fixed calculation of ctc loss in TFWav2Vec2ForCTC (#18014)
Co-authored-by:
Sreyan-G@NVIDIA
<
sreyang@nvidia.com
>
parent
96d833b2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
1 deletion
+10
-1
src/transformers/models/wav2vec2/modeling_tf_wav2vec2.py
src/transformers/models/wav2vec2/modeling_tf_wav2vec2.py
+10
-1
No files found.
src/transformers/models/wav2vec2/modeling_tf_wav2vec2.py
View file @
e3139ad3
...
...
@@ -25,7 +25,13 @@ import tensorflow as tf
from
...activations_tf
import
get_tf_activation
from
...modeling_tf_outputs
import
TFBaseModelOutput
,
TFCausalLMOutput
from
...modeling_tf_utils
import
TFPreTrainedModel
,
booleans_processing
,
get_initializer
,
keras_serializable
from
...modeling_tf_utils
import
(
TFPreTrainedModel
,
booleans_processing
,
get_initializer
,
keras_serializable
,
unpack_inputs
,
)
from
...tf_utils
import
shape_list
,
stable_softmax
from
...utils
import
(
ModelOutput
,
...
...
@@ -1580,6 +1586,7 @@ class TFWav2Vec2ForCTC(TFWav2Vec2PreTrainedModel):
"""
self
.
wav2vec2
.
feature_extractor
.
trainable
=
False
@
unpack_inputs
@
add_start_docstrings_to_model_forward
(
WAV_2_VEC_2_INPUTS_DOCSTRING
)
@
replace_return_docstrings
(
output_type
=
TFCausalLMOutput
,
config_class
=
_CONFIG_FOR_DOC
)
def
call
(
...
...
@@ -1702,6 +1709,8 @@ class TFWav2Vec2ForCTC(TFWav2Vec2PreTrainedModel):
loss
=
tf
.
reduce_sum
(
loss
)
if
self
.
config
.
ctc_loss_reduction
==
"mean"
:
loss
=
tf
.
reduce_mean
(
loss
)
loss
=
tf
.
reshape
(
loss
,
(
1
,))
else
:
loss
=
None
...
...
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