Spaces:
Sleeping
Sleeping
File size: 566 Bytes
85ba398 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from torch import nn
from fairseq.models import FairseqEncoder
class CTCDecoder(FairseqEncoder):
def __init__(self, dictionary, in_dim):
super().__init__(dictionary)
self.proj = nn.Linear(in_dim, len(dictionary))
def forward(self, src_tokens, src_lengths=None, **kwargs):
encoder_out = self.proj(src_tokens)
return {"encoder_out": encoder_out}
|