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
404ff8fc
Unverified
Commit
404ff8fc
authored
Sep 05, 2023
by
Susnato Dhar
Committed by
GitHub
Sep 05, 2023
Browse files
Fix typo (#25966)
* Update feature_extraction_clap.py * changed all lenght to length
parent
d8e13b3e
Changes
20
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
35 additions
and
35 deletions
+35
-35
examples/legacy/seq2seq/seq2seq_training_args.py
examples/legacy/seq2seq/seq2seq_training_args.py
+1
-1
examples/pytorch/speech-recognition/run_speech_recognition_ctc.py
.../pytorch/speech-recognition/run_speech_recognition_ctc.py
+1
-1
examples/pytorch/speech-recognition/run_speech_recognition_ctc_adapter.py
.../speech-recognition/run_speech_recognition_ctc_adapter.py
+1
-1
examples/research_projects/robust-speech-event/run_speech_recognition_ctc_bnb.py
...cts/robust-speech-event/run_speech_recognition_ctc_bnb.py
+1
-1
examples/research_projects/robust-speech-event/run_speech_recognition_ctc_streaming.py
...bust-speech-event/run_speech_recognition_ctc_streaming.py
+1
-1
examples/research_projects/wav2vec2/run_asr.py
examples/research_projects/wav2vec2/run_asr.py
+1
-1
examples/research_projects/wav2vec2/run_common_voice.py
examples/research_projects/wav2vec2/run_common_voice.py
+1
-1
examples/research_projects/xtreme-s/run_xtreme_s.py
examples/research_projects/xtreme-s/run_xtreme_s.py
+1
-1
src/transformers/models/clap/feature_extraction_clap.py
src/transformers/models/clap/feature_extraction_clap.py
+1
-1
tests/models/data2vec/test_modeling_data2vec_audio.py
tests/models/data2vec/test_modeling_data2vec_audio.py
+2
-2
tests/models/hubert/test_modeling_hubert.py
tests/models/hubert/test_modeling_hubert.py
+2
-2
tests/models/sew/test_modeling_sew.py
tests/models/sew/test_modeling_sew.py
+2
-2
tests/models/sew_d/test_modeling_sew_d.py
tests/models/sew_d/test_modeling_sew_d.py
+2
-2
tests/models/speecht5/test_feature_extraction_speecht5.py
tests/models/speecht5/test_feature_extraction_speecht5.py
+4
-4
tests/models/unispeech/test_modeling_unispeech.py
tests/models/unispeech/test_modeling_unispeech.py
+2
-2
tests/models/unispeech_sat/test_modeling_unispeech_sat.py
tests/models/unispeech_sat/test_modeling_unispeech_sat.py
+2
-2
tests/models/wav2vec2/test_modeling_wav2vec2.py
tests/models/wav2vec2/test_modeling_wav2vec2.py
+2
-2
tests/models/wav2vec2_conformer/test_modeling_wav2vec2_conformer.py
...ls/wav2vec2_conformer/test_modeling_wav2vec2_conformer.py
+2
-2
tests/models/wavlm/test_modeling_wavlm.py
tests/models/wavlm/test_modeling_wavlm.py
+2
-2
tests/test_sequence_feature_extraction_common.py
tests/test_sequence_feature_extraction_common.py
+4
-4
No files found.
examples/legacy/seq2seq/seq2seq_training_args.py
View file @
404ff8fc
...
...
@@ -31,7 +31,7 @@ class Seq2SeqTrainingArguments(TrainingArguments):
label_smoothing (:obj:`float`, `optional`, defaults to 0):
The label smoothing epsilon to apply (if not zero).
sortish_sampler (:obj:`bool`, `optional`, defaults to :obj:`False`):
Whether to SortishSamler or not. It sorts the inputs according to leng
h
ts in-order to minimizing the padding size.
Whether to SortishSamler or not. It sorts the inputs according to lengt
h
s in-order to minimizing the padding size.
predict_with_generate (:obj:`bool`, `optional`, defaults to :obj:`False`):
Whether to use generate to calculate generative metrics (ROUGE, BLEU).
"""
...
...
examples/pytorch/speech-recognition/run_speech_recognition_ctc.py
View file @
404ff8fc
...
...
@@ -311,7 +311,7 @@ class DataCollatorCTCWithPadding:
pad_to_multiple_of_labels
:
Optional
[
int
]
=
None
def
__call__
(
self
,
features
:
List
[
Dict
[
str
,
Union
[
List
[
int
],
torch
.
Tensor
]]])
->
Dict
[
str
,
torch
.
Tensor
]:
# split inputs and labels since they have to be of different leng
h
ts and need
# split inputs and labels since they have to be of different lengt
h
s and need
# different padding methods
input_features
=
[{
"input_values"
:
feature
[
"input_values"
]}
for
feature
in
features
]
label_features
=
[{
"input_ids"
:
feature
[
"labels"
]}
for
feature
in
features
]
...
...
examples/pytorch/speech-recognition/run_speech_recognition_ctc_adapter.py
View file @
404ff8fc
...
...
@@ -307,7 +307,7 @@ class DataCollatorCTCWithPadding:
pad_to_multiple_of_labels
:
Optional
[
int
]
=
None
def
__call__
(
self
,
features
:
List
[
Dict
[
str
,
Union
[
List
[
int
],
torch
.
Tensor
]]])
->
Dict
[
str
,
torch
.
Tensor
]:
# split inputs and labels since they have to be of different leng
h
ts and need
# split inputs and labels since they have to be of different lengt
h
s and need
# different padding methods
input_features
=
[{
"input_values"
:
feature
[
"input_values"
]}
for
feature
in
features
]
label_features
=
[{
"input_ids"
:
feature
[
"labels"
]}
for
feature
in
features
]
...
...
examples/research_projects/robust-speech-event/run_speech_recognition_ctc_bnb.py
View file @
404ff8fc
...
...
@@ -292,7 +292,7 @@ class DataCollatorCTCWithPadding:
pad_to_multiple_of_labels
:
Optional
[
int
]
=
None
def
__call__
(
self
,
features
:
List
[
Dict
[
str
,
Union
[
List
[
int
],
torch
.
Tensor
]]])
->
Dict
[
str
,
torch
.
Tensor
]:
# split inputs and labels since they have to be of different leng
h
ts and need
# split inputs and labels since they have to be of different lengt
h
s and need
# different padding methods
input_features
=
[{
"input_values"
:
feature
[
"input_values"
]}
for
feature
in
features
]
label_features
=
[{
"input_ids"
:
feature
[
"labels"
]}
for
feature
in
features
]
...
...
examples/research_projects/robust-speech-event/run_speech_recognition_ctc_streaming.py
View file @
404ff8fc
...
...
@@ -284,7 +284,7 @@ class DataCollatorCTCWithPadding:
pad_to_multiple_of_labels
:
Optional
[
int
]
=
None
def
__call__
(
self
,
features
:
List
[
Dict
[
str
,
Union
[
List
[
int
],
torch
.
Tensor
]]])
->
Dict
[
str
,
torch
.
Tensor
]:
# split inputs and labels since they have to be of different leng
h
ts and need
# split inputs and labels since they have to be of different lengt
h
s and need
# different padding methods
input_features
=
[]
label_features
=
[]
...
...
examples/research_projects/wav2vec2/run_asr.py
View file @
404ff8fc
...
...
@@ -254,7 +254,7 @@ class DataCollatorCTCWithPadding:
pad_to_multiple_of_labels
:
Optional
[
int
]
=
None
def
__call__
(
self
,
features
:
List
[
Dict
[
str
,
Union
[
List
[
int
],
torch
.
Tensor
]]])
->
Dict
[
str
,
torch
.
Tensor
]:
# split inputs and labels since they have to be of different leng
h
ts and need
# split inputs and labels since they have to be of different lengt
h
s and need
# different padding methods
input_features
=
[{
"input_values"
:
feature
[
"input_values"
]}
for
feature
in
features
]
label_features
=
[{
"input_ids"
:
feature
[
"labels"
]}
for
feature
in
features
]
...
...
examples/research_projects/wav2vec2/run_common_voice.py
View file @
404ff8fc
...
...
@@ -173,7 +173,7 @@ class DataCollatorCTCWithPadding:
pad_to_multiple_of_labels
:
Optional
[
int
]
=
None
def
__call__
(
self
,
features
:
List
[
Dict
[
str
,
Union
[
List
[
int
],
torch
.
Tensor
]]])
->
Dict
[
str
,
torch
.
Tensor
]:
# split inputs and labels since they have to be of different leng
h
ts and need
# split inputs and labels since they have to be of different lengt
h
s and need
# different padding methods
input_features
=
[{
"input_values"
:
feature
[
"input_values"
]}
for
feature
in
features
]
label_features
=
[{
"input_ids"
:
feature
[
"labels"
]}
for
feature
in
features
]
...
...
examples/research_projects/xtreme-s/run_xtreme_s.py
View file @
404ff8fc
...
...
@@ -335,7 +335,7 @@ class SpeechDataCollatorWithPadding:
pad_to_multiple_of_labels
:
Optional
[
int
]
=
None
def
__call__
(
self
,
features
:
List
[
Dict
[
str
,
Union
[
List
[
int
],
torch
.
Tensor
]]])
->
Dict
[
str
,
torch
.
Tensor
]:
# split inputs and labels since they have to be of different leng
h
ts and need
# split inputs and labels since they have to be of different lengt
h
s and need
# different padding methods
input_features
=
[{
"input_values"
:
feature
[
"input_values"
]}
for
feature
in
features
]
...
...
src/transformers/models/clap/feature_extraction_clap.py
View file @
404ff8fc
...
...
@@ -51,7 +51,7 @@ class ClapFeatureExtractor(SequenceFeatureExtractor):
Length of the overlaping windows for the STFT used to obtain the Mel Spectrogram. The audio will be split
in smaller `frames` with a step of `hop_length` between each frame.
max_length_s (`int`, defaults to 10):
The maximum input leng
h
t of the model in seconds. This is used to pad the audio.
The maximum input lengt
h
of the model in seconds. This is used to pad the audio.
fft_window_size (`int`, defaults to 1024):
Size of the window (in samples) on which the Fourier transform is applied. This controls the frequency
resolution of the spectrogram. 400 means that the fourrier transform is computed on windows of 400 samples.
...
...
tests/models/data2vec/test_modeling_data2vec_audio.py
View file @
404ff8fc
...
...
@@ -283,8 +283,8 @@ class Data2VecAudioModelTester:
input_values
[
i
,
input_lengths
[
i
]
:]
=
0.0
if
max_length_labels
[
i
]
<
labels
.
shape
[
-
1
]:
# it's important that we make sure that target leng
h
ts are at least
# one shorter than logit leng
h
ts to prevent -inf
# it's important that we make sure that target lengt
h
s are at least
# one shorter than logit lengt
h
s to prevent -inf
labels
[
i
,
max_length_labels
[
i
]
-
1
:]
=
-
100
loss
=
model
(
input_values
,
labels
=
labels
).
loss
...
...
tests/models/hubert/test_modeling_hubert.py
View file @
404ff8fc
...
...
@@ -252,8 +252,8 @@ class HubertModelTester:
input_values
[
i
,
input_lengths
[
i
]
:]
=
0.0
if
max_length_labels
[
i
]
<
labels
.
shape
[
-
1
]:
# it's important that we make sure that target leng
h
ts are at least
# one shorter than logit leng
h
ts to prevent -inf
# it's important that we make sure that target lengt
h
s are at least
# one shorter than logit lengt
h
s to prevent -inf
labels
[
i
,
max_length_labels
[
i
]
-
1
:]
=
-
100
loss
=
model
(
input_values
,
labels
=
labels
).
loss
...
...
tests/models/sew/test_modeling_sew.py
View file @
404ff8fc
...
...
@@ -222,8 +222,8 @@ class SEWModelTester:
input_values
[
i
,
input_lengths
[
i
]
:]
=
0.0
if
max_length_labels
[
i
]
<
labels
.
shape
[
-
1
]:
# it's important that we make sure that target leng
h
ts are at least
# one shorter than logit leng
h
ts to prevent -inf
# it's important that we make sure that target lengt
h
s are at least
# one shorter than logit lengt
h
s to prevent -inf
labels
[
i
,
max_length_labels
[
i
]
-
1
:]
=
-
100
loss
=
model
(
input_values
,
labels
=
labels
).
loss
...
...
tests/models/sew_d/test_modeling_sew_d.py
View file @
404ff8fc
...
...
@@ -243,8 +243,8 @@ class SEWDModelTester:
input_values
[
i
,
input_lengths
[
i
]
:]
=
0.0
if
max_length_labels
[
i
]
<
labels
.
shape
[
-
1
]:
# it's important that we make sure that target leng
h
ts are at least
# one shorter than logit leng
h
ts to prevent -inf
# it's important that we make sure that target lengt
h
s are at least
# one shorter than logit lengt
h
s to prevent -inf
labels
[
i
,
max_length_labels
[
i
]
-
1
:]
=
-
100
loss
=
model
(
input_values
,
labels
=
labels
).
loss
...
...
tests/models/speecht5/test_feature_extraction_speecht5.py
View file @
404ff8fc
...
...
@@ -340,7 +340,7 @@ class SpeechT5FeatureExtractionTest(SequenceFeatureExtractionTestMixin, unittest
feat_dict
[
"return_attention_mask"
]
=
True
feat_extract
=
self
.
feature_extraction_class
(
**
feat_dict
)
speech_inputs
=
self
.
feat_extract_tester
.
prepare_inputs_for_target
()
input_leng
h
ts
=
[
len
(
x
)
for
x
in
speech_inputs
]
input_lengt
h
s
=
[
len
(
x
)
for
x
in
speech_inputs
]
input_name
=
feat_extract
.
model_input_names
[
0
]
processed
=
BatchFeature
({
input_name
:
speech_inputs
})
...
...
@@ -350,18 +350,18 @@ class SpeechT5FeatureExtractionTest(SequenceFeatureExtractionTestMixin, unittest
processed
=
feat_extract
.
pad
(
processed
,
padding
=
"longest"
,
return_tensors
=
"np"
)
self
.
assertIn
(
"attention_mask"
,
processed
)
self
.
assertListEqual
(
list
(
processed
.
attention_mask
.
shape
),
list
(
processed
[
input_name
].
shape
[:
2
]))
self
.
assertListEqual
(
processed
.
attention_mask
.
sum
(
-
1
).
tolist
(),
input_leng
h
ts
)
self
.
assertListEqual
(
processed
.
attention_mask
.
sum
(
-
1
).
tolist
(),
input_lengt
h
s
)
def
test_attention_mask_with_truncation_target
(
self
):
feat_dict
=
self
.
feat_extract_dict
feat_dict
[
"return_attention_mask"
]
=
True
feat_extract
=
self
.
feature_extraction_class
(
**
feat_dict
)
speech_inputs
=
self
.
feat_extract_tester
.
prepare_inputs_for_target
()
input_leng
h
ts
=
[
len
(
x
)
for
x
in
speech_inputs
]
input_lengt
h
s
=
[
len
(
x
)
for
x
in
speech_inputs
]
input_name
=
feat_extract
.
model_input_names
[
0
]
processed
=
BatchFeature
({
input_name
:
speech_inputs
})
max_length
=
min
(
input_leng
h
ts
)
max_length
=
min
(
input_lengt
h
s
)
feat_extract
.
feature_size
=
feat_extract
.
num_mel_bins
# hack!
...
...
tests/models/unispeech/test_modeling_unispeech.py
View file @
404ff8fc
...
...
@@ -245,8 +245,8 @@ class UniSpeechModelTester:
input_values
[
i
,
input_lengths
[
i
]
:]
=
0.0
if
max_length_labels
[
i
]
<
labels
.
shape
[
-
1
]:
# it's important that we make sure that target leng
h
ts are at least
# one shorter than logit leng
h
ts to prevent -inf
# it's important that we make sure that target lengt
h
s are at least
# one shorter than logit lengt
h
s to prevent -inf
labels
[
i
,
max_length_labels
[
i
]
-
1
:]
=
-
100
loss
=
model
(
input_values
,
labels
=
labels
).
loss
...
...
tests/models/unispeech_sat/test_modeling_unispeech_sat.py
View file @
404ff8fc
...
...
@@ -265,8 +265,8 @@ class UniSpeechSatModelTester:
input_values
[
i
,
input_lengths
[
i
]
:]
=
0.0
if
max_length_labels
[
i
]
<
labels
.
shape
[
-
1
]:
# it's important that we make sure that target leng
h
ts are at least
# one shorter than logit leng
h
ts to prevent -inf
# it's important that we make sure that target lengt
h
s are at least
# one shorter than logit lengt
h
s to prevent -inf
labels
[
i
,
max_length_labels
[
i
]
-
1
:]
=
-
100
loss
=
model
(
input_values
,
labels
=
labels
).
loss
...
...
tests/models/wav2vec2/test_modeling_wav2vec2.py
View file @
404ff8fc
...
...
@@ -404,8 +404,8 @@ class Wav2Vec2ModelTester:
input_values
[
i
,
input_lengths
[
i
]
:]
=
0.0
if
max_length_labels
[
i
]
<
labels
.
shape
[
-
1
]:
# it's important that we make sure that target leng
h
ts are at least
# one shorter than logit leng
h
ts to prevent -inf
# it's important that we make sure that target lengt
h
s are at least
# one shorter than logit lengt
h
s to prevent -inf
labels
[
i
,
max_length_labels
[
i
]
-
1
:]
=
-
100
loss
=
model
(
input_values
,
labels
=
labels
).
loss
...
...
tests/models/wav2vec2_conformer/test_modeling_wav2vec2_conformer.py
View file @
404ff8fc
...
...
@@ -314,8 +314,8 @@ class Wav2Vec2ConformerModelTester:
input_values
[
i
,
input_lengths
[
i
]
:]
=
0.0
if
max_length_labels
[
i
]
<
labels
.
shape
[
-
1
]:
# it's important that we make sure that target leng
h
ts are at least
# one shorter than logit leng
h
ts to prevent -inf
# it's important that we make sure that target lengt
h
s are at least
# one shorter than logit lengt
h
s to prevent -inf
labels
[
i
,
max_length_labels
[
i
]
-
1
:]
=
-
100
loss
=
model
(
input_values
,
labels
=
labels
).
loss
...
...
tests/models/wavlm/test_modeling_wavlm.py
View file @
404ff8fc
...
...
@@ -256,8 +256,8 @@ class WavLMModelTester:
input_values
[
i
,
input_lengths
[
i
]
:]
=
0.0
if
max_length_labels
[
i
]
<
labels
.
shape
[
-
1
]:
# it's important that we make sure that target leng
h
ts are at least
# one shorter than logit leng
h
ts to prevent -inf
# it's important that we make sure that target lengt
h
s are at least
# one shorter than logit lengt
h
s to prevent -inf
labels
[
i
,
max_length_labels
[
i
]
-
1
:]
=
-
100
loss
=
model
(
input_values
,
labels
=
labels
).
loss
...
...
tests/test_sequence_feature_extraction_common.py
View file @
404ff8fc
...
...
@@ -391,7 +391,7 @@ class SequenceFeatureExtractionTestMixin(FeatureExtractionSavingTestMixin):
feat_dict
[
"return_attention_mask"
]
=
True
feat_extract
=
self
.
feature_extraction_class
(
**
feat_dict
)
speech_inputs
=
self
.
feat_extract_tester
.
prepare_inputs_for_common
()
input_leng
h
ts
=
[
len
(
x
)
for
x
in
speech_inputs
]
input_lengt
h
s
=
[
len
(
x
)
for
x
in
speech_inputs
]
input_name
=
feat_extract
.
model_input_names
[
0
]
processed
=
BatchFeature
({
input_name
:
speech_inputs
})
...
...
@@ -399,18 +399,18 @@ class SequenceFeatureExtractionTestMixin(FeatureExtractionSavingTestMixin):
processed
=
feat_extract
.
pad
(
processed
,
padding
=
"longest"
,
return_tensors
=
"np"
)
self
.
assertIn
(
"attention_mask"
,
processed
)
self
.
assertListEqual
(
list
(
processed
.
attention_mask
.
shape
),
list
(
processed
[
input_name
].
shape
[:
2
]))
self
.
assertListEqual
(
processed
.
attention_mask
.
sum
(
-
1
).
tolist
(),
input_leng
h
ts
)
self
.
assertListEqual
(
processed
.
attention_mask
.
sum
(
-
1
).
tolist
(),
input_lengt
h
s
)
def
test_attention_mask_with_truncation
(
self
):
feat_dict
=
self
.
feat_extract_dict
feat_dict
[
"return_attention_mask"
]
=
True
feat_extract
=
self
.
feature_extraction_class
(
**
feat_dict
)
speech_inputs
=
self
.
feat_extract_tester
.
prepare_inputs_for_common
()
input_leng
h
ts
=
[
len
(
x
)
for
x
in
speech_inputs
]
input_lengt
h
s
=
[
len
(
x
)
for
x
in
speech_inputs
]
input_name
=
feat_extract
.
model_input_names
[
0
]
processed
=
BatchFeature
({
input_name
:
speech_inputs
})
max_length
=
min
(
input_leng
h
ts
)
max_length
=
min
(
input_lengt
h
s
)
processed_pad
=
feat_extract
.
pad
(
processed
,
padding
=
"max_length"
,
max_length
=
max_length
,
truncation
=
True
,
return_tensors
=
"np"
...
...
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