雾聪
2024-03-14 3549c0106e5a35ef2ddffdfd7381e613ed5310bd
funasr/models/transducer/rnn_decoder.py
@@ -1,14 +1,18 @@
import random
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
# Copyright FunASR (https://github.com/alibaba-damo-academy/FunASR). All Rights Reserved.
#  MIT License  (https://opensource.org/licenses/MIT)
import numpy as np
import torch
import random
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
from funasr.register import tables
from funasr.models.transformer.utils.nets_utils import make_pad_mask
from funasr.models.transformer.utils.nets_utils import to_device
from funasr.models.language_model.rnn.attentions import initial_att
from funasr.models.decoder.abs_decoder import AbsDecoder
from funasr.utils.get_default_kwargs import get_default_kwargs
def build_attention_list(
@@ -79,8 +83,8 @@
        )
    return att_list
class RNNDecoder(AbsDecoder):
@tables.register("decoder_classes", "rnn_decoder")
class RNNDecoder(nn.Module):
    def __init__(
        self,
        vocab_size: int,
@@ -93,7 +97,7 @@
        context_residual: bool = False,
        replace_sos: bool = False,
        num_encs: int = 1,
        att_conf: dict = get_default_kwargs(build_attention_list),
        att_conf: dict = None,
    ):
        # FIXME(kamo): The parts of num_spk should be refactored more more more
        if rnn_type not in {"lstm", "gru"}: