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 |
|---|---|---|---|---|---|---|
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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,731 | 35.114053 | 96 | py |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-main/examples/speech_text_joint_to_text/criterions/multi_modality_cross_entropy.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 import utils
from fairseq.criterions import register_criterion
from fairseq.criterions.label_smoothed_cross_entropy ... | 4,105 | 39.254902 | 86 | py |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-main/examples/speech_text_joint_to_text/models/joint_speech_text_pretrain_transformer.py | #!/usr/bin/env python3
import logging
from collections import OrderedDict, namedtuple
from typing import Dict, Optional
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch import Tensor
from fairseq import checkpoint_utils, utils
from fairseq.file_io import PathManager
from fairseq.models i... | 28,546 | 39.839771 | 114 | py |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-main/examples/speech_text_joint_to_text/models/s2t_dualinputwavtransformer.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 OrderedDict, namedtuple
import torch.nn as nn
from fairseq import checkpoint_utils, utils
from fairse... | 21,145 | 39.125237 | 148 | py |
rej-summ | rej-summ-main/examples/speech_text_joint_to_text/scripts/convert_model.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 re
from collections import OrderedDict
import torch
from fairseq.file_io import PathManager
... | 1,866 | 24.930556 | 83 | py |
rej-summ | rej-summ-main/examples/speech_text_joint_to_text/data/pair_denoising_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 copy
import math
import re
import torch
from fairseq.data import data_utils
from fairseq.data.language_pair_dataset import LanguagePa... | 11,447 | 34.887147 | 239 | py |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-main/examples/speech_text_joint_to_text/tasks/pair_denoising.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 itertools
import logging
import os
import re
import numpy as np
import torch
from examples.speech_text_joint_to_text.data.pair_denois... | 15,550 | 33.712054 | 118 | py |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-main/scripts/check_installation.py | from pathlib import Path
import os
cwd = Path(".").resolve()
print("running 'check_installation.py' from:", cwd)
# Old versions of numpy/torch can prevent loading the .so files
import torch
print("torch:", torch.__version__)
import numpy
print("numpy:", numpy.__version__)
import fairseq
print("Fairseq installed a... | 877 | 22.72973 | 71 | py |
rej-summ | rej-summ-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 ave... | 6,763 | 37.214689 | 131 | py |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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,681 | 35.578125 | 88 | py |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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
from unittest.mock import patch
impor... | 8,833 | 31.007246 | 109 | py |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 random
import unittest
import pytest
import torch
from fairseq.modules.multihead_attention import MultiheadAttention, _mask_for_xform... | 15,789 | 31.356557 | 88 | py |
rej-summ | rej-summ-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... | 24,142 | 29.254386 | 86 | py |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-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 |
rej-summ | rej-summ-main/tests/test_label_smoothing.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 copy
import unittest
import tests.utils as test_utils
import torch
from fairseq.criterions.cross_entropy import CrossE... | 4,629 | 36.33871 | 88 | py |
rej-summ | rej-summ-main/tests/test_convtbc.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 import ConvTBC
class TestConvTBC(unittest.TestCase):
def test_c... | 1,745 | 30.745455 | 82 | py |
rej-summ | rej-summ-main/tests/test_lm_context_window.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 MonolingualDataset
from fairseq.tasks.language_modeling import LanguageModelingConfig,... | 1,865 | 32.927273 | 88 | py |
rej-summ | rej-summ-main/tests/test_amp_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 argparse
import copy
import unittest
import torch
from torch.cuda.amp import GradScaler, autocast
from fairseq.optim import build_opt... | 2,411 | 30.736842 | 87 | py |
rej-summ | rej-summ-main/tests/test_token_block_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 TokenBlockDataset
class TestTokenBlockDataset(unitte... | 3,629 | 38.032258 | 103 | py |
rej-summ | rej-summ-main/tests/test_transformer.py | import argparse
import unittest
from typing import Any, Dict, Sequence
import torch
from fairseq.models import transformer
from tests.test_roberta import FakeTask
def mk_sample(tok: Sequence[int] = None, batch_size: int = 2) -> Dict[str, Any]:
if not tok:
tok = [10, 11, 12, 13, 14, 15, 2]
batch = t... | 1,942 | 28.439394 | 80 | py |
rej-summ | rej-summ-main/tests/test_multi_corpus_sampled_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 numpy as np
import torch
from fairseq.data import LanguagePairDataset, TokenBlockD... | 3,109 | 31.395833 | 79 | py |
rej-summ | rej-summ-main/tests/test_dictionary.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
import string
import tempfile
import unittest
import torch
from fairseq import tokenizer
from fairseq.data import Diction... | 4,545 | 30.136986 | 87 | py |
rej-summ | rej-summ-main/tests/test_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 unittest
import torch
from fairseq import utils
class TestUtils(unittest.TestCase):
def test_convert_padding_direction(self):
... | 3,295 | 27.66087 | 78 | py |
rej-summ | rej-summ-main/tests/test_character_token_embedder.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 Dictionary
from fairseq.modules import CharacterTokenEmbedder
class TestCharacterToke... | 1,678 | 33.265306 | 81 | py |
rej-summ | rej-summ-main/tests/gpu/test_ema_gpu.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,825 | 30.601852 | 109 | py |
rej-summ | rej-summ-main/tests/gpu/test_binaries_gpu.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 tempfile
import unittest
from io import StringIO
import torch
from fairseq imp... | 20,506 | 33.698816 | 104 | py |
rej-summ | rej-summ-main/tests/distributed/test_distributed_timeout_wrapper.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 signal
import time
import unittest
import torch
from torch import nn
from fairseq.distributed import DistributedTimeou... | 1,349 | 24.471698 | 84 | py |
rej-summ | rej-summ-main/tests/distributed/test_module_proxy_wrapper.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 torch import nn
from fairseq.distributed import ModuleProxyWrapper
from .utils import objects_are_equal
... | 2,085 | 26.813333 | 82 | py |
rej-summ | rej-summ-main/tests/distributed/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 functools
import tempfile
import torch
def spawn_and_init(fn, world_size, args=None):
if args is None:
args = ()
wit... | 1,765 | 25.757576 | 65 | py |
rej-summ | rej-summ-main/tests/distributed/test_bmuf.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 functools
import random
import unittest
from multiprocessing import Manager
import torch
import torch.nn as nn
from om... | 7,027 | 33.282927 | 88 | py |
rej-summ | rej-summ-main/tests/distributed/test_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 functools
import sys
import unittest
import torch
from fairseq.distributed import utils as dist_utils
from .utils import objects_are... | 3,656 | 28.256 | 82 | py |
rej-summ | rej-summ-main/tests/speech_recognition/test_data_utils.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
from examples.speech_recognition.data import data_utils
class DataUtilsTest(unittest.Tes... | 1,736 | 26.571429 | 65 | py |
rej-summ | rej-summ-main/tests/speech_recognition/asr_test_base.py | #!/usr/bin/env python3
import argparse
import os
import unittest
from inspect import currentframe, getframeinfo
import numpy as np
import torch
from examples.speech_recognition.data.data_utils import lengths_to_encoder_padding_mask
from fairseq.data import data_utils as fairseq_data_utils
from fairseq.data.dictionary... | 19,469 | 33.892473 | 87 | py |
rej-summ | rej-summ-main/tests/speech_recognition/test_collaters.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 numpy as np
import torch
from examples.speech_recognition.data.collaters import Seq2SeqCollater... | 2,048 | 33.728814 | 87 | py |
rej-summ | rej-summ-main/tests/speech/test_tts_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.
import unittest
import torch
from tqdm import tqdm
from fairseq import utils
from fairseq.tasks.text_to_speech import batch_mel_cepstral_dis... | 1,831 | 32.925926 | 85 | py |
rej-summ | rej-summ-main/tests/speech/test_wav2vec2.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 tests.speech import TestFairseqSpeech
from fairseq.data.data_utils import post_process
from fairseq import u... | 2,914 | 31.032967 | 86 | py |
rej-summ | rej-summ-main/tests/speech/test_dual_input_wav_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.
import unittest
from collections import namedtuple
from pathlib import Path
import torch
from tqdm import tqdm
import fairseq
from fairseq i... | 2,393 | 30.090909 | 105 | py |
rej-summ | rej-summ-main/tests/speech/test_dualinput_s2t_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.
import unittest
from argparse import Namespace
from collections import namedtuple
from pathlib import Path
import torch
from tqdm import tqdm... | 3,977 | 34.837838 | 87 | py |
rej-summ | rej-summ-main/tests/speech/__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.
from argparse import Namespace
import os
import re
import unittest
from pathlib import Path
from tqdm import tqdm
from typing import List, Dic... | 7,147 | 32.876777 | 84 | py |
rej-summ | rej-summ-main/tests/speech/test_fastspeech2.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 tqdm import tqdm
from fairseq import utils
from fairseq.tasks.text_to_speech import batch_mel_cepstral_dis... | 1,825 | 32.814815 | 86 | py |
rej-summ | rej-summ-main/fairseq/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 ast
import collections
import contextlib
import inspect
import logging
import os
import re
import time
import traceback
from collection... | 35,084 | 37.725166 | 114 | py |
rej-summ | rej-summ-main/fairseq/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 collections
import contextlib
import copy
import importlib
import logging
import os
import sys
import warnings
from ite... | 31,966 | 32.578782 | 132 | py |
rej-summ | rej-summ-main/fairseq/hub_utils.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.
import argparse
import copy
import logging
import os
from typing import Any, Dict, Iterator, List
import torch
from... | 11,747 | 34.926606 | 88 | py |
rej-summ | rej-summ-main/fairseq/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 sys
import torch
from fairseq import utils
class SequenceScorer(object):
"""Scores the target for a given source sentence."""
... | 5,450 | 34.396104 | 101 | py |
rej-summ | rej-summ-main/fairseq/binarizer.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
import typing as tp
from abc import ABC, abstractmethod
from collections import Counter
from dataclasses import datac... | 11,397 | 28.837696 | 99 | py |
rej-summ | rej-summ-main/fairseq/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 math
import sys
from typing import Dict, List, Optional
import torch
import torch.nn as nn
from torch import Tensor
from fairseq impo... | 40,842 | 38.885742 | 110 | py |
rej-summ | rej-summ-main/fairseq/ngram_repeat_block.py | # Originally from Microsoft Corporation.
# Licensed under the MIT License.
""" Wrapper for ngram_repeat_block cuda extension """
import math
import warnings
from typing import List
import torch
from torch import nn
try:
from fairseq import ngram_repeat_block_cuda
EXTENSION_BUILT = True
except ImportError:
... | 4,106 | 32.942149 | 102 | py |
rej-summ | rej-summ-main/fairseq/options.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 pathlib import Path
from typing import Callable, List, Optional, Union
import torch
from fairseq import utils
from fairs... | 15,440 | 36.297101 | 88 | py |
rej-summ | rej-summ-main/fairseq/token_generation_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.
"""Implements tracking of constraints for a beam item.
A list of constraints is given as a list of one or more token
sequences, each of lengt... | 16,555 | 31.654832 | 96 | py |
rej-summ | rej-summ-main/fairseq/file_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.
"""
Utilities for working with the local dataset cache.
This file is adapted from `AllenNLP <https://github.com/allenai/allennlp>`_.
and `hugg... | 11,718 | 30.587601 | 92 | py |
rej-summ | rej-summ-main/fairseq/incremental_decoding_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 uuid
from typing import Dict, Optional
from torch import Tensor
class FairseqIncrementalState(object):
def __init__(self, *args,... | 1,773 | 33.115385 | 76 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.