repo
stringlengths
1
99
file
stringlengths
13
215
code
stringlengths
12
59.2M
file_length
int64
12
59.2M
avg_line_length
float64
3.82
1.48M
max_line_length
int64
12
2.51M
extension_type
stringclasses
1 value
sign-topic
sign-topic-main/examples/speech_recognition/new/decoders/viterbi_decoder.py
#!/usr/bin/env python3 # 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. import torch from typing import List, Dict from .base_decoder import BaseDecoder class ViterbiDecoder(BaseDecoder)...
641
24.68
73
py
sign-topic
sign-topic-main/examples/speech_recognition/new/decoders/flashlight_decoder.py
#!/usr/bin/env python3 # 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. import gc import os.path as osp import warnings from collections import deque, namedtuple from typing import Any, Dict...
14,746
33.136574
88
py
sign-topic
sign-topic-main/examples/speech_recognition/kaldi/kaldi_decoder.py
#!/usr/bin/env python3 # 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 concurrent.futures import ThreadPoolExecutor import logging from omegaconf import MISSING import os import torch ...
8,265
32.738776
116
py
sign-topic
sign-topic-main/examples/speech_recognition/data/collaters.py
# 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. """ This module contains collection of classes which implement collate functionalities for various tasks. Collaters should know wh...
4,796
35.340909
84
py
sign-topic
sign-topic-main/examples/speech_recognition/data/data_utils.py
# 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. import torch def calc_mean_invstddev(feature): if len(feature.size()) != 2: raise ValueError("We expect the input feature to be ...
3,429
32.960396
84
py
sign-topic
sign-topic-main/examples/speech_recognition/data/asr_dataset.py
# 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. import os import numpy as np from fairseq.data import FairseqDataset from . import data_utils from .collaters import Seq2SeqCollater class...
3,955
31.162602
82
py
sign-topic
sign-topic-main/examples/speech_recognition/tasks/speech_recognition.py
# 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. import json import os import re import sys import torch from examples.speech_recognition.data import AsrDataset from examples.speech_recognit...
5,397
33.164557
87
py
sign-topic
sign-topic-main/examples/speech_synthesis/generate_waveform.py
# 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. import ast import logging import matplotlib.pyplot as plt import numpy as np from pathlib import Path import soundfile as sf import sys import...
7,339
37.031088
80
py
sign-topic
sign-topic-main/examples/speech_synthesis/utils.py
# 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. import numpy as np import torch from scipy.interpolate import interp1d import torchaudio from fairseq.tasks.text_to_speech import ( batch...
3,357
31.921569
78
py
sign-topic
sign-topic-main/examples/speech_synthesis/data_utils.py
# 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. import io import os from pathlib import Path from typing import Optional, List, Dict import zipfile import tempfile from dataclasses import da...
11,364
31.942029
87
py
sign-topic
sign-topic-main/examples/speech_synthesis/evaluation/eval_sp.py
# 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. """ Signal processing-based evaluation using waveforms """ import csv import numpy as np import os.path as op import torch import tqdm from...
4,149
30.439394
75
py
sign-topic
sign-topic-main/examples/speech_synthesis/evaluation/eval_f0.py
# 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. """ Signal processing-based evaluation using waveforms """ import numpy as np import os.path as op import torchaudio import tqdm from tabulat...
8,333
30.213483
80
py
sign-topic
sign-topic-main/examples/speech_synthesis/preprocessing/get_feature_manifest.py
# 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. import argparse import logging from pathlib import Path import shutil from tempfile import NamedTemporaryFile from collections import Counter,...
11,171
41.479087
80
py
sign-topic
sign-topic-main/examples/speech_synthesis/preprocessing/get_common_voice_audio_manifest.py
# 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. import argparse import logging from pathlib import Path from collections import defaultdict from typing import List, Dict, Tuple import panda...
5,277
36.432624
80
py
sign-topic
sign-topic-main/examples/speech_synthesis/preprocessing/denoise_and_vad_audio.py
# 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. import argparse import logging import os import csv import tempfile from collections import defaultdict from pathlib import Path import torch...
7,655
36.346341
80
py
sign-topic
sign-topic-main/examples/speech_synthesis/preprocessing/get_ljspeech_audio_manifest.py
# 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. import argparse import logging from pathlib import Path from collections import defaultdict import pandas as pd from torchaudio.datasets impo...
2,288
31.239437
80
py
sign-topic
sign-topic-main/examples/speech_synthesis/preprocessing/get_vctk_audio_manifest.py
# 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. import argparse import logging import numpy as np import re from pathlib import Path from collections import defaultdict import pandas as pd ...
2,685
32.575
80
py
sign-topic
sign-topic-main/examples/speech_synthesis/preprocessing/get_speaker_embedding.py
# 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. import argparse from collections import defaultdict from itertools import chain from pathlib import Path import numpy as np import torchaudi...
3,116
33.633333
81
py
sign-topic
sign-topic-main/examples/speech_synthesis/preprocessing/denoiser/resample.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # author: adefossez import math import torch as th from torch.nn import functional as F def sinc(t): """sinc. :...
2,226
26.8375
89
py
sign-topic
sign-topic-main/examples/speech_synthesis/preprocessing/denoiser/demucs.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # author: adefossez import math import time import torch as th from torch import nn from torch.nn import functional as F ...
16,989
34.843882
83
py
sign-topic
sign-topic-main/examples/speech_synthesis/preprocessing/denoiser/utils.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # author: adefossez import functools import logging from contextlib import contextmanager import inspect import time logge...
4,770
25.954802
85
py
sign-topic
sign-topic-main/examples/speech_synthesis/preprocessing/denoiser/pretrained.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # author: adefossez import logging import torch.hub from .demucs import Demucs from .utils import deserialize_model logg...
2,384
28.085366
84
py
sign-topic
sign-topic-main/examples/speech_synthesis/preprocessing/speaker_embedder/__init__.py
# 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. import librosa import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.data import torchaudio EMBEDDER_PARAMS...
4,103
29.176471
78
py
sign-topic
sign-topic-main/examples/byte_level_bpe/gru_transformer.py
# 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. # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the r...
5,027
45.555556
87
py
sign-topic
sign-topic-main/examples/simultaneous_translation/modules/monotonic_multihead_attention.py
# 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. import math import torch from torch import Tensor import torch.nn as nn from examples.simultaneous_translation.utils.p_choose_strategy impor...
16,858
31.421154
142
py
sign-topic
sign-topic-main/examples/simultaneous_translation/modules/monotonic_transformer_layer.py
# 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 fairseq.modules import TransformerDecoderLayer, TransformerEncoderLayer from . import build_monotonic_attention from typing import Dict...
7,265
38.704918
88
py
sign-topic
sign-topic-main/examples/simultaneous_translation/modules/fixed_pre_decision.py
from functools import partial import torch from torch import Tensor import math import torch.nn.functional as F from . import register_monotonic_attention from .monotonic_multihead_attention import ( MonotonicAttention, MonotonicInfiniteLookbackAttention, WaitKAttention ) from typing import Dict, Optional...
7,370
37.591623
91
py
sign-topic
sign-topic-main/examples/simultaneous_translation/eval/agents/simul_t2t_enja.py
# 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. import os from fairseq import checkpoint_utils, tasks import sentencepiece as spm import torch try: from simuleval import READ_ACTION, W...
7,099
30.277533
85
py
sign-topic
sign-topic-main/examples/simultaneous_translation/models/transformer_monotonic_attention.py
# 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 typing import Dict, List, NamedTuple, Optional import torch import torch.nn as nn from examples.simultaneous_translation.modules.monoton...
10,185
32.617162
108
py
sign-topic
sign-topic-main/examples/simultaneous_translation/models/convtransformer_simul_trans.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. from fairseq import checkpoint_uti...
7,162
33.941463
123
py
sign-topic
sign-topic-main/examples/simultaneous_translation/tests/test_text_models.py
import argparse import unittest from typing import Any, Dict import torch from examples.simultaneous_translation.models import ( transformer_monotonic_attention ) from tests.test_roberta import FakeTask DEFAULT_CONFIG = { "attention_eps": 1e-6, "mass_preservation": True, "noise_type": "flat", "...
13,524
32.14951
108
py
sign-topic
sign-topic-main/examples/simultaneous_translation/tests/test_alignment_train.py
import unittest import numpy as np import torch import hypothesis.strategies as st from hypothesis import assume, given, settings from torch.testing._internal.common_utils import TestCase from examples.simultaneous_translation.utils.functions import exclusive_cumprod TEST_CUDA = torch.cuda.is_available() class Al...
2,989
32.595506
148
py
sign-topic
sign-topic-main/examples/simultaneous_translation/utils/monotonic_attention.py
from typing import Optional import torch from torch import Tensor from examples.simultaneous_translation.utils.functions import ( exclusive_cumprod, prob_check, moving_sum, ) def expected_alignment_from_p_choose( p_choose: Tensor, padding_mask: Optional[Tensor] = None, eps: float = 1e-6 ): ...
4,975
26.491713
88
py
sign-topic
sign-topic-main/examples/simultaneous_translation/utils/p_choose_strategy.py
from typing import Optional, Dict from torch import Tensor import torch def waitk_p_choose( tgt_len: int, src_len: int, bsz: int, waitk_lagging: int, key_padding_mask: Optional[Tensor] = None, incremental_state: Optional[Dict[str, Dict[str, Optional[Tensor]]]] = None ): max_src_len = src_...
3,445
26.133858
78
py
sign-topic
sign-topic-main/examples/simultaneous_translation/utils/functions.py
# 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. import torch def prob_check(tensor, eps=1e-10): assert not torch.isnan(tensor).any(), ( "Nan in a probability tensor." ) ...
3,535
27.063492
84
py
sign-topic
sign-topic-main/examples/SL_topic_detection/analysis_outputs.py
# Script for analizing outputs produced by the models. import math from typing import Tuple from typing import Union from typing import List from copy import deepcopy import argparse import ast import pandas as pd from sympy import ShapeError import numpy as np from sklearn import manifold from sklearn.metrics impor...
27,538
35.235526
167
py
sign-topic
sign-topic-main/examples/SL_topic_detection/infer.py
import ast import os import sys from dataclasses import dataclass, field, is_dataclass import logging from pathlib import Path from typing import Any, Dict, List, Optional, Tuple, Union, Callable from operator import attrgetter import torch import torch.distributed as dist import hydra from hydra.core.config_store im...
17,569
37.030303
148
py
sign-topic
sign-topic-main/examples/SL_topic_detection/prep_how2sign.py
#!/usr/bin/env python3 import errno import os import json import h5py import argparse import logging import pandas as pd from typing import Tuple from typing import List from pathlib import Path from tempfile import NamedTemporaryFile import cv2 import torchvision import torch from torch.utils.data import Dataset fro...
8,850
35.57438
163
py
sign-topic
sign-topic-main/examples/sign2vec/prep_how2sign.py
#!/usr/bin/env python3 # This code is based on the speech_to_text implementation (commit: d974c70) # # 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. import h5py import argparse import loggi...
5,013
34.062937
101
py
sign-topic
sign-topic-main/examples/fast_noisy_channel/noisy_channel_translation.py
# 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 fairseq.tasks.translation import TranslationTask from fairseq.tasks.language_modeling import LanguageModelingTask from fairseq import che...
6,709
51.421875
160
py
sign-topic
sign-topic-main/examples/fast_noisy_channel/noisy_channel_beam_search.py
# 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. import torch from fairseq.search import Search class NoisyChannelBeamSearch(Search): def __init__(self, tgt_dict): super().__in...
2,895
39.222222
104
py
sign-topic
sign-topic-main/examples/fast_noisy_channel/noisy_channel_sequence_generator.py
# 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 typing import Dict, List, Optional import math import numpy as np import torch import torch.nn.functional as F from torch import Tensor...
41,200
47.874259
187
py
sign-topic
sign-topic-main/examples/textless_nlp/gslm/ulm/sample.py
#!/usr/bin/env python3 -u # 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. """ Sample from a trained LM; hacked fairseq-interactive """ from collections import namedtuple import os import ast ...
5,623
31.137143
103
py
sign-topic
sign-topic-main/examples/textless_nlp/gslm/tools/resynthesize_speech.py
# 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. import argparse import gc import logging import os import joblib import soundfile as sf import torch from examples.textless_nlp.gslm.speech2u...
4,183
30.458647
86
py
sign-topic
sign-topic-main/examples/textless_nlp/gslm/unit2speech/tts_data.py
# 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. import torch import numpy as np from examples.textless_nlp.gslm.unit2speech.tacotron2.text import ( EOS_TOK, SOS_TOK, code_to_seq...
1,733
30.527273
77
py
sign-topic
sign-topic-main/examples/textless_nlp/gslm/unit2speech/multiproc.py
import os import time import torch import sys import subprocess argslist = list(sys.argv)[1:] log_dir = argslist[-1] num_gpus = torch.cuda.device_count() argslist.append('--n_gpus={}'.format(num_gpus)) workers = [] job_id = time.strftime("%Y_%m_%d-%H%M%S") argslist.append("--group_name=group_{}".format(job_id)) print...
772
26.607143
84
py
sign-topic
sign-topic-main/examples/textless_nlp/gslm/unit2speech/utils.py
# 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. import torch from examples.textless_nlp.gslm.unit2speech.tacotron2.model import Tacotron2 from examples.textless_nlp.gslm.unit2speech.tacotro...
1,904
33.017857
80
py
sign-topic
sign-topic-main/examples/textless_nlp/gslm/unit2speech/glow.py
# ***************************************************************************** # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions...
12,653
39.557692
105
py
sign-topic
sign-topic-main/examples/textless_nlp/gslm/unit2speech/tacotron2/stft.py
""" BSD 3-Clause License Copyright (c) 2017, Prem Seetharaman All rights reserved. * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of...
5,893
40.507042
97
py
sign-topic
sign-topic-main/examples/textless_nlp/gslm/unit2speech/tacotron2/utils.py
# 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. import collections import io import json import librosa import numpy as np import soundfile as sf import time import torch from scipy.io.wavfi...
4,918
27.598837
79
py
sign-topic
sign-topic-main/examples/textless_nlp/gslm/unit2speech/tacotron2/model.py
from math import sqrt import torch import torch.distributions as distr from torch.autograd import Variable from torch import nn from torch.nn import functional as F from .layers import ConvNorm, LinearNorm, GlobalAvgPool from .utils import to_gpu, get_mask_from_lengths class LocationLayer(nn.Module): def __init__...
25,989
37.791045
82
py
sign-topic
sign-topic-main/examples/textless_nlp/gslm/unit2speech/tacotron2/layers.py
import torch from librosa.filters import mel as librosa_mel_fn from .audio_processing import dynamic_range_compression from .audio_processing import dynamic_range_decompression from .stft import STFT from .utils import get_mask_from_lengths class LinearNorm(torch.nn.Module): def __init__(self, in_dim, out_dim, bi...
3,859
36.115385
81
py
sign-topic
sign-topic-main/examples/textless_nlp/gslm/unit2speech/tacotron2/waveglow_denoiser.py
# import sys # sys.path.append('tacotron2') import torch from .layers import STFT class Denoiser(torch.nn.Module): """ Removes model bias from audio produced with waveglow """ def __init__(self, waveglow, filter_length=1024, n_overlap=4, win_length=1024, mode='zeros'): super(Denoiser...
1,610
38.292683
77
py
sign-topic
sign-topic-main/examples/textless_nlp/gslm/unit2speech/tacotron2/audio_processing.py
import torch import numpy as np from scipy.signal import get_window import librosa.util as librosa_util def window_sumsquare(window, n_frames, hop_length=200, win_length=800, n_fft=800, dtype=np.float32, norm=None): """ # from librosa 0.6 Compute the sum-square envelope of a window fu...
2,610
26.776596
83
py
sign-topic
sign-topic-main/examples/textless_nlp/gslm/metrics/asr_metrics/ppx.py
# 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. import torch import numpy as np import warnings def get_target_sequences(manifest, ground_truth, to_take=1000): import json import ...
3,692
29.02439
90
py
sign-topic
sign-topic-main/examples/textless_nlp/gslm/metrics/asr_metrics/misc/cut_as.py
# 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. import torchaudio import argparse import json import pathlib def get_args(): parser = argparse.ArgumentParser( "Assuring genera...
1,832
25.185714
78
py
sign-topic
sign-topic-main/examples/textless_nlp/gslm/speech2unit/pretrained/hubert_feature_reader.py
# 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. import torch import fairseq import soundfile as sf import torch.nn.functional as F class HubertFeatureReader: """ Wrapper class to r...
1,912
30.883333
66
py
sign-topic
sign-topic-main/examples/textless_nlp/gslm/speech2unit/pretrained/w2v2_feature_reader.py
# 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. import torch import fairseq import soundfile as sf class Wav2VecFeatureReader: """ Wrapper class to run inference on Wav2Vec 2.0 mod...
1,424
29.319149
79
py
sign-topic
sign-topic-main/examples/textless_nlp/gslm/speech2unit/pretrained/utils.py
# 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. import gc import os import random import shutil import numpy as np import torch import tqdm from examples.textless_nlp.gslm.speech2unit.pretr...
3,407
25.834646
85
py
sign-topic
sign-topic-main/examples/textless_nlp/gslm/speech2unit/pretrained/logmel_feature_reader.py
# 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. import soundfile as sf import torch import torchaudio.compliance.kaldi as kaldi class LogMelFeatureReader: """ Wrapper class to run ...
905
28.225806
65
py
sign-topic
sign-topic-main/examples/textless_nlp/gslm/speech2unit/pretrained/cpc_feature_reader.py
import soundfile as sf import torch import torch.nn as nn import torch.nn.functional as F class CpcFeatureReader: """ Wrapper class to run inference on CPC model. Helps extract features for a given audio file. """ def __init__( self, checkpoint_path, layer, use_enc...
6,525
32.813472
82
py
sign-topic
sign-topic-main/examples/discriminative_reranking_nmt/drnmt_rerank.py
#!/usr/bin/env python3 -u # 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. """ Score raw text with a trained model. """ from collections import namedtuple import logging from multiprocessing ...
11,312
29.994521
144
py
sign-topic
sign-topic-main/examples/discriminative_reranking_nmt/criterions/discriminative_reranking_criterion.py
# 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. import math from dataclasses import dataclass, field import torch import torch.nn.functional as F from fairseq import metrics, utils from fa...
4,997
34.956835
157
py
sign-topic
sign-topic-main/examples/discriminative_reranking_nmt/models/discriminative_reranking_model.py
from dataclasses import dataclass, field import os import torch import torch.nn as nn from fairseq import utils from fairseq.dataclass import ChoiceEnum, FairseqDataclass from fairseq.models import ( BaseFairseqModel, register_model, ) from fairseq.models.roberta.model import RobertaClassificationHead from ...
13,714
36.472678
112
py
sign-topic
sign-topic-main/examples/discriminative_reranking_nmt/tasks/discriminative_reranking_task.py
# 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 dataclasses import dataclass, field import itertools import logging import os import numpy as np import torch from fairseq import metr...
17,491
35.747899
96
py
sign-topic
sign-topic-main/examples/pointer_generator/pointer_generator_src/transformer_pg.py
# 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. import logging from typing import Any, Dict, Optional, List, Tuple import torch import torch.nn as nn from fairseq import utils from fairseq....
23,439
44.163776
102
py
sign-topic
sign-topic-main/examples/speech_text_joint_to_text/criterions/text_guide_cross_entropy_acc.py
# 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. import math import torch import torch.nn.functional as F from fairseq.criterions import FairseqCriterion, register_criterion from fairseq.crit...
11,004
48.129464
139
py
sign-topic
sign-topic-main/examples/speech_text_joint_to_text/models/s2t_dualinputtransformer.py
# 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. import logging from collections import namedtuple import torch import torch.nn as nn from fairseq import checkpoint_utils from fairseq import...
45,047
40.177331
128
py
sign-topic
sign-topic-main/examples/speech_text_joint_to_text/models/s2t_dualinputxmtransformer.py
# 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. import copy import torch.nn as nn from fairseq import checkpoint_utils from fairseq import utils from fairseq.data.data_utils import lengths_...
21,461
35.687179
88
py
sign-topic
sign-topic-main/examples/speech_text_joint_to_text/tasks/speech_text_joint.py
# 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. import logging import os from argparse import Namespace from pathlib import Path import torch from fairseq.data import ( encoders, Dic...
13,654
35.124339
88
py
sign-topic
sign-topic-main/examples/rxf/rxf_src/label_smoothed_cross_entropy_r3f.py
# 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. import math import torch import torch.nn.functional as F from fairseq import metrics, utils from fairseq.criterions import FairseqCriterion, ...
6,109
37.670886
91
py
sign-topic
sign-topic-main/examples/rxf/rxf_src/sentence_prediction_r3f.py
# 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. import math import torch import torch.nn.functional as F from fairseq import utils from fairseq.criterions import FairseqCriterion, register_...
6,587
37.302326
96
py
sign-topic
sign-topic-main/scripts/average_checkpoints.py
#!/usr/bin/env python3 # 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. import argparse import collections import os import re import torch from fairseq.file_io import PathManager def aver...
6,075
36.73913
126
py
sign-topic
sign-topic-main/tests/test_rotary_positional_embedding.py
import torch import numpy as np import unittest from fairseq.modules.rotary_positional_embedding import apply_rotary_pos_emb from fairseq.modules import RotaryPositionalEmbedding class TestRotaryPositionalEmbedding(unittest.TestCase): def setUp(self) -> None: self.T = 3 self.B = 1 self.C =...
2,045
30.476923
82
py
sign-topic
sign-topic-main/tests/test_train.py
# 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. import contextlib import logging import unittest from io import StringIO from unittest.mock import MagicMock, patch import torch from fairseq...
9,292
36.471774
101
py
sign-topic
sign-topic-main/tests/test_positional_encoding.py
import unittest import torch from fairseq.modules import RelPositionalEncoding import numpy as np class TestRelPositionalEncoding(unittest.TestCase): def setUp(self) -> None: self.T = 3 self.B = 1 self.C = 2 torch.manual_seed(0) self.sample = torch.randn(self.T, self.B, se...
1,714
25.796875
75
py
sign-topic
sign-topic-main/tests/test_checkpoint_utils.py
# 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. import contextlib import logging import os import tempfile import unittest from io import StringIO from unittest.mock import patch from omega...
4,744
35.221374
88
py
sign-topic
sign-topic-main/tests/test_average_checkpoints.py
# 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. import collections import os import shutil import tempfile import unittest import numpy as np import torch from scripts.average_checkpoints i...
4,385
31.488889
88
py
sign-topic
sign-topic-main/tests/test_reproducibility.py
# 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. import json import os import tempfile import unittest import torch from . import test_binaries class TestReproducibility(unittest.TestCase...
4,864
31.651007
88
py
sign-topic
sign-topic-main/tests/test_sequence_scorer.py
# 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. import argparse import unittest import tests.utils as test_utils import torch from fairseq.sequence_scorer import SequenceScorer class Test...
4,150
33.305785
76
py
sign-topic
sign-topic-main/tests/test_multi_corpus_dataset.py
# 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. import unittest from collections import OrderedDict import torch from fairseq.data import LanguagePairDataset, TokenBlockDataset from fairse...
2,587
30.180723
79
py
sign-topic
sign-topic-main/tests/test_espnet_multihead_attention.py
import torch import numpy as np import unittest from fairseq.modules import ( ESPNETMultiHeadedAttention, RelPositionMultiHeadedAttention, RotaryPositionMultiHeadedAttention, ) torch.use_deterministic_algorithms(True) class TestESPNETMultiHeadedAttention(unittest.TestCase): def setUp(self) -> None: ...
5,548
30.350282
84
py
sign-topic
sign-topic-main/tests/test_memory_efficient_fp16.py
# 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. import argparse import logging import unittest import torch from fairseq.optim.adam import FairseqAdam from fairseq.optim.fp16_optimizer impo...
2,452
30.050633
70
py
sign-topic
sign-topic-main/tests/test_hf_hub.py
#!/usr/bin/env python3 # 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. import unittest import torch try: import huggingface_hub except ImportError: huggingface_hub = None from fai...
796
25.566667
81
py
sign-topic
sign-topic-main/tests/test_ema.py
# 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. import unittest from copy import deepcopy from dataclasses import dataclass from typing import Optional import torch from fairseq.models.ema...
6,676
30.200935
109
py
sign-topic
sign-topic-main/tests/test_lstm_jitable.py
# 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. import argparse import tempfile import unittest import torch from fairseq.data.dictionary import Dictionary from fairseq.models.lstm import L...
4,041
33.844828
85
py
sign-topic
sign-topic-main/tests/test_multihead_attention.py
# 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. import unittest import torch from fairseq.modules.multihead_attention import MultiheadAttention class TestMultiheadAttention(unittest.TestC...
2,943
33.232558
93
py
sign-topic
sign-topic-main/tests/utils.py
# 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. import argparse import json import os import random import shutil import string import sys import typing as tp from io import StringIO import...
23,931
29.332066
86
py
sign-topic
sign-topic-main/tests/test_binaries.py
# 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. import contextlib import json import logging import os import random import sys import tempfile import unittest from io import StringIO from t...
73,338
37.417496
93
py
sign-topic
sign-topic-main/tests/test_concat_dataset.py
# 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. import unittest import torch from fairseq.data import LanguagePairDataset, TokenBlockDataset from fairseq.data.concat_dataset import ConcatDa...
1,866
30.644068
81
py
sign-topic
sign-topic-main/tests/test_activation_checkpointing.py
# 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. import unittest import torch import torch.nn as nn from fairseq.modules.checkpoint_activations import checkpoint_wrapper from torch.utils.che...
2,904
35.3125
86
py
sign-topic
sign-topic-main/tests/test_noising.py
# 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. import unittest from typing import Dict, List import torch import tests.utils as test_utils from fairseq import utils from fairseq.data impo...
19,814
36.246241
87
py
sign-topic
sign-topic-main/tests/test_constraints.py
# 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. import unittest from typing import List import torch from fairseq.token_generation_constraints import ( ConstraintNode, OrderedConst...
10,612
37.452899
155
py
sign-topic
sign-topic-main/tests/test_sparse_multihead_attention.py
# 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. import unittest import torch from fairseq.modules.sparse_multihead_attention import SparseMultiheadAttention class TestSparseMultiheadAtten...
3,738
31.513043
84
py
sign-topic
sign-topic-main/tests/test_export.py
#!/usr/bin/env python3 # 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. import argparse import tempfile import unittest import torch from fairseq.data.dictionary import Dictionary from fair...
4,002
32.082645
86
py
sign-topic
sign-topic-main/tests/test_roberta.py
# 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. import functools import unittest from typing import Any, Dict, Sequence import fairseq import fairseq.options import fairseq.tasks import tor...
11,291
31.730435
93
py
sign-topic
sign-topic-main/tests/test_online_backtranslation.py
# 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. import tempfile import unittest from pathlib import Path from typing import Any, Dict, Sequence import fairseq.data.indexed_dataset as indexe...
7,650
35.961353
86
py
sign-topic
sign-topic-main/tests/test_backtranslation_dataset.py
# 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. import unittest import tests.utils as test_utils import torch from fairseq.data import ( BacktranslationDataset, LanguagePairDataset,...
4,140
32.395161
85
py
sign-topic
sign-topic-main/tests/test_fp16_optimizer.py
# 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. import copy import logging import unittest import torch from fairseq.optim.fp16_optimizer import FP16Optimizer, MemoryEfficientFP16Optimizer ...
3,571
30.892857
87
py
sign-topic
sign-topic-main/tests/test_sequence_generator.py
# 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. import argparse import math import tempfile import unittest import numpy as np import torch import tests.utils as test_utils from fairseq im...
27,810
36.330201
92
py