remove useless code.

pull/2880/head
zxcd 3 years ago
parent af76e60bc4
commit 4fae249503

@ -147,14 +147,12 @@ wav2vec2_optim_conf:
lr: 0.0001 lr: 0.0001
weight_decay: 0.0 weight_decay: 0.0
model_scheduler: newbobscheduler
model_scheduler: newbobscheduler
model_scheduler_conf: model_scheduler_conf:
improvement_threshold: 0.0025 improvement_threshold: 0.0025
annealing_factor: 0.8 annealing_factor: 0.8
patient: 0 patient: 0
wav2vec2_scheduler: newbobscheduler wav2vec2_scheduler: newbobscheduler
wav2vec2_scheduler_conf: wav2vec2_scheduler_conf:
improvement_threshold: 0.0025 improvement_threshold: 0.0025
annealing_factor: 0.9 annealing_factor: 0.9

@ -54,30 +54,30 @@ for type in ctc_greedy_search; do
echo "decoding ${type} done." echo "decoding ${type} done."
done done
# for type in ctc_prefix_beam_search; do for type in ctc_prefix_beam_search; do
# echo "decoding ${type}" echo "decoding ${type}"
# batch_size=1 batch_size=1
# python3 -u ${BIN_DIR}/test.py \ python3 -u ${BIN_DIR}/test.py \
# --ngpu ${ngpu} \ --ngpu ${ngpu} \
# --config ${config_path} \ --config ${config_path} \
# --decode_cfg ${decode_config_path} \ --decode_cfg ${decode_config_path} \
# --result_file ${ckpt_prefix}.${type}.rsl \ --result_file ${ckpt_prefix}.${type}.rsl \
# --checkpoint_path ${ckpt_prefix} \ --checkpoint_path ${ckpt_prefix} \
# --opts decode.decoding_method ${type} \ --opts decode.decoding_method ${type} \
# --opts decode.decode_batch_size ${batch_size} --opts decode.decode_batch_size ${batch_size}
# if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
# echo "Failed in evaluation!" echo "Failed in evaluation!"
# exit 1 exit 1
# fi fi
# python3 utils/format_rsl.py \ python3 utils/format_rsl.py \
# --origin_hyp ${ckpt_prefix}.${type}.rsl \ --origin_hyp ${ckpt_prefix}.${type}.rsl \
# --trans_hyp ${ckpt_prefix}.${type}.rsl.text --trans_hyp ${ckpt_prefix}.${type}.rsl.text
# python3 utils/compute-wer.py --char=1 --v=1 \ python3 utils/compute-wer.py --char=1 --v=1 \
# data/manifest.test-clean.text ${ckpt_prefix}.${type}.rsl.text > ${ckpt_prefix}.${type}.error data/manifest.test-clean.text ${ckpt_prefix}.${type}.rsl.text > ${ckpt_prefix}.${type}.error
# echo "decoding ${type} done." echo "decoding ${type} done."
# done done
echo "Finished" echo "Finished"

@ -11,7 +11,7 @@ conf_path=conf/wav2vec2ASR.yaml
ips= #xx.xx.xx.xx,xx.xx.xx.xx ips= #xx.xx.xx.xx,xx.xx.xx.xx
decode_conf_path=conf/tuning/decode.yaml decode_conf_path=conf/tuning/decode.yaml
avg_num=1 avg_num=1
resume=20 # xx e.g. 30 resume= # xx e.g. 30
export FLAGS_cudnn_deterministic=1 export FLAGS_cudnn_deterministic=1
. ${MAIN_ROOT}/utils/parse_options.sh || exit 1; . ${MAIN_ROOT}/utils/parse_options.sh || exit 1;
@ -38,11 +38,11 @@ fi
if [ ${stage} -le 3 ] && [ ${stop_stage} -ge 3 ]; then if [ ${stage} -le 3 ] && [ ${stop_stage} -ge 3 ]; then
# greedy search decoder # greedy search decoder
CUDA_VISIBLE_DEVICES=4 ./local/test.sh ${conf_path} ${decode_conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} || exit -1 CUDA_VISIBLE_DEVICES=0 ./local/test.sh ${conf_path} ${decode_conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} || exit -1
fi fi
if [ ${stage} -le 4 ] && [ ${stop_stage} -ge 4 ]; then if [ ${stage} -le 4 ] && [ ${stop_stage} -ge 4 ]; then
# test a single .wav file # test a single .wav file
CUDA_VISIBLE_DEVICES=${gpus} ./local/test_wav.sh ${conf_path} ${decode_conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} ${audio_file} || exit -1 CUDA_VISIBLE_DEVICES=0 ./local/test_wav.sh ${conf_path} ${decode_conf_path} exp/${ckpt}/checkpoints/${avg_ckpt} ${audio_file} || exit -1
fi fi

@ -1,4 +1,4 @@
# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved. # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@ -17,14 +17,12 @@ import math
import os import os
import re import re
import time import time
from collections import defaultdict
from collections import OrderedDict from collections import OrderedDict
from contextlib import nullcontext from contextlib import nullcontext
import jsonlines import jsonlines
import numpy as np import numpy as np
import paddle import paddle
import tqdm
import transformers import transformers
from hyperpyyaml import load_hyperpyyaml from hyperpyyaml import load_hyperpyyaml
from paddle import distributed as dist from paddle import distributed as dist
@ -142,7 +140,6 @@ class Wav2Vec2ASRTrainer(Trainer):
self.avg_train_loss = 0.0 self.avg_train_loss = 0.0
self.flag = False self.flag = False
self.use_sb = True self.use_sb = True
self.epoch = 1
def update_average(self, batch_index, loss): def update_average(self, batch_index, loss):
"""Update running average of the loss. """Update running average of the loss.

@ -110,29 +110,6 @@ class GeneratorDynamicItem(DynamicItem):
The main benefit is to be able to define the pipeline in a clear function, The main benefit is to be able to define the pipeline in a clear function,
even if parts of the pipeline depend on others for their initialization. even if parts of the pipeline depend on others for their initialization.
Example
-------
>>> lab2ind = {}
>>> def text_pipeline(text):
... text = text.lower().strip()
... text = "".join(c for c in text if c.isalpha() or c == " ")
... words = text.split()
... yield words
... encoded = [lab2ind[word] for word in words]
... yield encoded
>>> item = GeneratorDynamicItem(
... func=text_pipeline,
... takes=["text"],
... provides=["words", "words_encoded"])
>>> # First create the integer-encoding:
>>> ind = 1
>>> for token in item("Is this it? - This is it."):
... if token not in lab2ind:
... lab2ind[token] = ind
... ind += 1
>>> # Now the integers can be encoded!
>>> item()
[1, 2, 3, 2, 1, 3]
""" """
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):

@ -112,8 +112,6 @@ class ReproducibleWeightedRandomSampler(WeightedRandomSampler):
to use a value which has a good mix of 0 and 1 bits. to use a value which has a good mix of 0 and 1 bits.
epoch : int epoch : int
The epoch to start at. The epoch to start at.
""" """
def __init__( def __init__(

@ -83,7 +83,6 @@ class SpeedPerturb(nn.Layer):
"new_freq": self.orig_freq * speed // 100, "new_freq": self.orig_freq * speed // 100,
} }
self.resamplers.append(Resample(**config)) self.resamplers.append(Resample(**config))
paddle.seed(2)
def forward(self, waveform): def forward(self, waveform):
""" """
@ -465,8 +464,6 @@ class DropFreq(nn.Layer):
low=self.drop_count_low, low=self.drop_count_low,
high=self.drop_count_high + 1, high=self.drop_count_high + 1,
shape=(1, ), ) shape=(1, ), )
##对齐固定drop_count
# drop_count = paddle.to_tensor([2])
# Filter parameters # Filter parameters
filter_length = 101 filter_length = 101
@ -481,8 +478,6 @@ class DropFreq(nn.Layer):
drop_range = self.drop_freq_high - self.drop_freq_low drop_range = self.drop_freq_high - self.drop_freq_low
drop_frequency = ( drop_frequency = (
paddle.rand(drop_count) * drop_range + self.drop_freq_low) paddle.rand(drop_count) * drop_range + self.drop_freq_low)
#对齐固定drop_frequency
# drop_frequency = torch.tensor([0.8102, 0.7742])
# Subtract each frequency # Subtract each frequency
for frequency in drop_frequency: for frequency in drop_frequency:
notch_kernel = notch_filter( notch_kernel = notch_filter(
@ -752,8 +747,7 @@ class SpecAugment(paddle.nn.Layer):
# compute center and corresponding window # compute center and corresponding window
c = paddle.randint(window, time - window, (1, ))[0] c = paddle.randint(window, time - window, (1, ))[0]
w = paddle.randint(c - window, c + window, (1, ))[0] + 1 w = paddle.randint(c - window, c + window, (1, ))[0] + 1
# c = 5
# w = 10
left = paddle.nn.functional.interpolate( left = paddle.nn.functional.interpolate(
x[:, :, :c], x[:, :, :c],
(w, x.shape[3]), (w, x.shape[3]),

@ -88,7 +88,7 @@ class Wav2vec2ASR(nn.Layer):
if decoding_method == 'ctc_prefix_beam_search' and batch_size > 1: if decoding_method == 'ctc_prefix_beam_search' and batch_size > 1:
logger.error( logger.error(
f'decoding mode {decoding_method} must be running with batch_size == 1' f"decoding mode {decoding_method} must be running with batch_size == 1"
) )
logger.error(f"current batch_size is {batch_size}") logger.error(f"current batch_size is {batch_size}")
@ -311,4 +311,4 @@ class Wav2vec2Base(nn.Layer):
def forward(self, wav): def forward(self, wav):
out = self.wav2vec2(wav) out = self.wav2vec2(wav)
return return out

Loading…
Cancel
Save