python_code stringlengths 0 4.04M | repo_name stringlengths 8 58 | file_path stringlengths 5 147 |
|---|---|---|
# 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 . import commonsense_qa_task # noqa
| data2vec_vision-main | infoxlm/fairseq/examples/roberta/commonsense_qa/__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 json
import os
import numpy as np
import torch
from fairseq.data import (
data_utils,
Dictionary,
encoders,
IdDataset... | data2vec_vision-main | infoxlm/fairseq/examples/roberta/commonsense_qa/commonsense_qa_task.py |
#!/usr/bin/env python
"""Helper script to compare two argparse.Namespace objects."""
from argparse import Namespace # noqa
def main():
ns1 = eval(input('Namespace 1: '))
ns2 = eval(input('Namespace 2: '))
def keys(ns):
ks = set()
for k in dir(ns):
if not k.startswith('_'):
... | data2vec_vision-main | infoxlm/fairseq/scripts/compare_namespaces.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.
"""
Split a large file into a train and valid set while respecting document
boundaries. Documents should be separated by... | data2vec_vision-main | infoxlm/fairseq/scripts/split_train_valid_docs.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.
"""
Helper script to pre-compute embeddings for a wav2letter++ dataset
"""
import argparse
import glob
import os
from ... | data2vec_vision-main | infoxlm/fairseq/scripts/wav2vec_featurize.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.
"""
Use this script in order to build symmetric alignments for your translation
dataset.
This script depends on fast_align and mosesdecoder too... | data2vec_vision-main | infoxlm/fairseq/scripts/build_sym_alignment.py |
#!/usr/bin/env python
# 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.
from __future__ import absolute_import, division, print_function, unicode_literals
import argparse
... | data2vec_vision-main | infoxlm/fairseq/scripts/spm_decode.py |
data2vec_vision-main | infoxlm/fairseq/scripts/__init__.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 os
import re
import shutil
import sys
pt_regexp = re.compile(r'checkpoint(\d+|_\d+_\d+|_[a-z]+... | data2vec_vision-main | infoxlm/fairseq/scripts/rm_pt.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.
"""
Count the number of documents and average number of lines and tokens per
document in a large file. Documents should ... | data2vec_vision-main | infoxlm/fairseq/scripts/count_docs.py |
#!/usr/bin/env python
# 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.
from __future__ import absolute_import, division, print_function, unicode_literals
import argparse
i... | data2vec_vision-main | infoxlm/fairseq/scripts/spm_encode.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.
"""
Split a large file into shards while respecting document boundaries. Documents
should be separated by a single empty... | data2vec_vision-main | infoxlm/fairseq/scripts/shard_docs.py |
#!/usr/bin/env python
# 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.
from __future__ import absolute_import, division, print_function, unicode_literals
import sys
impor... | data2vec_vision-main | infoxlm/fairseq/scripts/spm_train.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 torch
import os
import re
def average_checkpoints(inputs):
"""Loads che... | data2vec_vision-main | infoxlm/fairseq/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.
"""
Data pre-processing: build vocabularies and binarize training data.
"""
import argparse
import glob
import os
impor... | data2vec_vision-main | infoxlm/fairseq/scripts/wav2vec_manifest.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
from fairseq.data import data_utils, Dictionary, indexed_dataset
def get_parser():
parser = argp... | data2vec_vision-main | infoxlm/fairseq/scripts/read_binarized.py |
import setuptools
setuptools.setup(
name="infoxlm",
version="0.0.1",
author="Zewen",
author_email="chizewen@outlook.com",
description="infoxlm",
url="https://github.com/CZWin32768/XLM-Align",
packages=setuptools.find_packages(),
install_requires=[],
classifiers=(
"Programming Language :: Python :... | data2vec_vision-main | infoxlm/src-infoxlm/setup.py |
import infoxlm
from fairseq_cli.train import cli_main
if __name__ == "__main__":
cli_main() | data2vec_vision-main | infoxlm/src-infoxlm/train.py |
import infoxlm.tasks
import infoxlm.models
import infoxlm.criterions | data2vec_vision-main | infoxlm/src-infoxlm/infoxlm/__init__.py |
import torch
from fairseq import utils
@torch.no_grad()
def concat_all_gather(tensor):
"""
Performs all_gather operation on the provided tensors.
*** Warning ***: torch.distributed.all_gather has no gradient.
"""
if torch.cuda.device_count() > 1:
return varsize_tensor_all_gather(tensor)
else:
outp... | data2vec_vision-main | infoxlm/src-infoxlm/infoxlm/utils.py |
import os
from fairseq.tasks import register_task, FairseqTask
from fairseq.data.dictionary import Dictionary
from infoxlm.data import mlm_utils
from infoxlm.data.dict_dataset import DictDataset
from infoxlm.tasks.mlm import Mlm
@register_task("tlm")
class Tlm(Mlm):
@staticmethod
def add_args(parser):
Mlm.a... | data2vec_vision-main | infoxlm/src-infoxlm/infoxlm/tasks/tlm.py |
import os
from functools import lru_cache
import numpy as np
import torch
from fairseq import utils
from fairseq.data.data_utils import process_bpe_symbol
from fairseq.data.dictionary import Dictionary
from fairseq.tasks import FairseqTask, register_task
from infoxlm.data import mlm_utils
from infoxlm.data.dict_data... | data2vec_vision-main | infoxlm/src-infoxlm/infoxlm/tasks/xlm_align.py |
import os
from fairseq.tasks import register_task, FairseqTask
from fairseq.data.dictionary import Dictionary
from infoxlm.data import mlm_utils
@register_task("mlm")
class Mlm(FairseqTask):
@staticmethod
def add_args(parser):
mlm_utils.add_mlm_args(parser)
parser.add_argument('data', help='colon separa... | data2vec_vision-main | infoxlm/src-infoxlm/infoxlm/tasks/mlm.py |
import argparse
import importlib
import os
from fairseq.tasks import TASK_REGISTRY
# automatically import any Python files in the tasks/ directory
for file in os.listdir(os.path.dirname(__file__)):
if file.endswith('.py') and not file.startswith('_'):
task_name = file[:file.find('.py')]
importlib.import_m... | data2vec_vision-main | infoxlm/src-infoxlm/infoxlm/tasks/__init__.py |
import os
import torch
from functools import lru_cache
from fairseq.tasks import register_task, FairseqTask
from fairseq.data.dictionary import Dictionary
from fairseq.data import FairseqDataset
from fairseq import utils
from infoxlm.data import mlm_utils
from infoxlm.data.dict_dataset import DictDataset
from infoxlm... | data2vec_vision-main | infoxlm/src-infoxlm/infoxlm/tasks/infoxlm.py |
import logging
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq import checkpoint_utils
from fairseq import utils
from fairseq.models import (
BaseFairseqModel,
register_model,
register_model_architecture,
)
from fairseq.models.roberta import (
RobertaModel,
RobertaEncoder,
... | data2vec_vision-main | infoxlm/src-infoxlm/infoxlm/models/roberta.py |
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq import checkpoint_utils
from fairseq import utils
from fairseq.models import (
BaseFairseqModel,
register_model,
register_model_architecture,
)
from fairseq.models.roberta import (
RobertaModel,
roberta_base_architecture,
robe... | data2vec_vision-main | infoxlm/src-infoxlm/infoxlm/models/xlm_align.py |
import argparse
import importlib
import os
from fairseq.models import MODEL_REGISTRY, ARCH_MODEL_INV_REGISTRY
# automatically import any Python files in the models/ directory
models_dir = os.path.dirname(__file__)
for file in os.listdir(models_dir):
path = os.path.join(models_dir, file)
if not file.startswith('_... | data2vec_vision-main | infoxlm/src-infoxlm/infoxlm/models/__init__.py |
import logging
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq import checkpoint_utils
from fairseq import utils
from fairseq.models import (
BaseFairseqModel,
register_model,
register_model_architecture,
)
from fairseq.models.roberta import (
RobertaModel,
roberta_base_arch... | data2vec_vision-main | infoxlm/src-infoxlm/infoxlm/models/infoxlm.py |
import torch
from fairseq.data import FairseqDataset
class TLMDataset(FairseqDataset):
def __init__(self, src_dataset, tgt_dataset, bos, eos):
assert len(src_dataset) == len(tgt_dataset)
self.src_dataset = src_dataset
self.tgt_dataset = tgt_dataset
self.bos = bos
self.eos = eos
self._sizes... | data2vec_vision-main | infoxlm/src-infoxlm/infoxlm/data/tlm_dataset.py |
import torch
from fairseq.data import BaseWrapperDataset
from fairseq.data import (data_utils,
TokenBlockDataset, PrependTokenDataset, PadDataset, TruncateDataset,
NumelDataset, NumSamplesDataset, NestedDictionaryDataset,
MaskTokensDataset, AppendTokenDataset, )
from infoxlm.data.mlm_utils import get_mlm_datas... | data2vec_vision-main | infoxlm/src-infoxlm/infoxlm/data/offset_dataset.py |
import torch
from fairseq.data import (data_utils,
TokenBlockDataset, PrependTokenDataset, PadDataset, TruncateDataset,
NumelDataset, NumSamplesDataset, NestedDictionaryDataset,
MaskTokensDataset, AppendTokenDataset, )
from fairseq.data.encoders.utils import get_whole_word_mask
def get_mlm_dataset(args, datas... | data2vec_vision-main | infoxlm/src-infoxlm/infoxlm/data/mlm_utils.py |
import torch
from fairseq.data import (data_utils,
TokenBlockDataset, PrependTokenDataset, PadDataset, TruncateDataset,
NumelDataset, NumSamplesDataset, NestedDictionaryDataset,
MaskTokensDataset, AppendTokenDataset, )
from fairseq.data.encoders.utils import get_whole_word_mask
from infoxlm.data.mlm_utils impo... | data2vec_vision-main | infoxlm/src-infoxlm/infoxlm/data/xlm_align.py |
import numpy as np
import os
import torch
from threading import Thread
from fairseq.data import data_utils, FairseqDataset, FairseqIterableDataset
class DictIterDataset(FairseqIterableDataset):
def __init__(self, defn, sizes=None):
self.defn = defn
for v in self.defn.values():
if not isinstance(v, (F... | data2vec_vision-main | infoxlm/src-infoxlm/infoxlm/data/dict_dataset.py |
data2vec_vision-main | infoxlm/src-infoxlm/infoxlm/data/__init__.py | |
import numpy as np
import torch
from fairseq.data import data_utils, FairseqDataset, MaskTokensDataset, TruncateDataset, BaseWrapperDataset
from infoxlm.data.dict_dataset import DictDataset
def get_xlco_dataset(args, dataset_path, vocab, mask_idx, combine=False):
dataset = data_utils.load_indexed_dataset(
data... | data2vec_vision-main | infoxlm/src-infoxlm/infoxlm/data/xlco_dataset.py |
import collections
import logging
import math
import torch
import numpy as np
from torch import nn
from torch.nn import functional as F
from torch import distributed
from fairseq import utils
from fairseq.criterions import FairseqCriterion, register_criterion
from fairseq.data.data_utils import process_bpe_symbol
fr... | data2vec_vision-main | infoxlm/src-infoxlm/infoxlm/criterions/xlm_align.py |
import os
import importlib
# automatically import any Python files in the criterions/ directory
for file in os.listdir(os.path.dirname(__file__)):
if file.endswith('.py') and not file.startswith('_'):
module = file[:file.find('.py')]
importlib.import_module('infoxlm.criterions.' + module) | data2vec_vision-main | infoxlm/src-infoxlm/infoxlm/criterions/__init__.py |
import collections
import logging
import math
import torch
from torch import nn
from torch.nn import functional as F
from torch import distributed
from fairseq import utils
from fairseq.criterions import FairseqCriterion, register_criterion
logger = logging.getLogger(__name__)
@register_criterion('xlco')
class Xl... | data2vec_vision-main | infoxlm/src-infoxlm/infoxlm/criterions/xlco.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 os
import subprocess
import sys
from setuptools import setup, find_packages, Extension
from setuptools import E... | data2vec_vision-main | deltalm/src/setup.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.
"""
Legacy entry point. Use fairseq_cli/train.py or fairseq-train instead.
"""
from fairseq_cli.train import cli_mai... | data2vec_vision-main | deltalm/src/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 functools
import importlib
from fairseq.hub_utils import ( # noqa; noqa
BPEHubInterface as bpe,
TokenizerHubInterface as toke... | data2vec_vision-main | deltalm/src/hubconf.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 tempfile
import unittest
import torch
from fairseq.data import Dictionary
class TestDictionary(unittest.TestCase):
def... | data2vec_vision-main | deltalm/src/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 argparse
import random
import unittest
from multiprocessing import Manager
import torch
import torch.nn as nn
from fairseq import dist... | data2vec_vision-main | deltalm/src/tests/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 unittest
import torch
from fairseq import utils
class TestUtils(unittest.TestCase):
def test_convert_padding_direction(self):
... | data2vec_vision-main | deltalm/src/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
from fairseq.data import iterators
class TestIterators(unittest.TestCase):
def test_counting_iterator(self, ref=None, i... | data2vec_vision-main | deltalm/src/tests/test_iterators.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 tests.utils as test_utils
import torch
from fairseq import utils
from fairseq.data impor... | data2vec_vision-main | deltalm/src/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 argparse
import tempfile
import unittest
import torch
from fairseq.data.dictionary import Dictionary
from fairseq.models.lstm import L... | data2vec_vision-main | deltalm/src/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 unittest
import torch
from fairseq.modules.sparse_multihead_attention import SparseMultiheadAttention
class TestSparseMultiheadAtten... | data2vec_vision-main | deltalm/src/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 uuid
from fairseq import metrics
class TestMetrics(unittest.TestCase):
def test_nesting(self):
with metr... | data2vec_vision-main | deltalm/src/tests/test_metrics.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... | data2vec_vision-main | deltalm/src/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 argparse
import unittest
import tests.utils as test_utils
import torch
from fairseq.sequence_scorer import SequenceScorer
class Test... | data2vec_vision-main | deltalm/src/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 logging
import unittest
from fairseq.dataclass.utils import convert_namespace_to_omegaconf
from fairseq.models.transformer import Tran... | data2vec_vision-main | deltalm/src/tests/test_inference_dropout.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... | data2vec_vision-main | deltalm/src/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 contextlib
import logging
import os
import tempfile
import unittest
from io import StringIO
from fairseq import checkpoint_utils
from... | data2vec_vision-main | deltalm/src/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 collections
import unittest
import numpy as np
from fairseq.data import ListDataset, ResamplingDataset
class TestResamplingDataset(u... | data2vec_vision-main | deltalm/src/tests/test_resampling_dataset.py |
data2vec_vision-main | deltalm/src/tests/__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 unittest
import tests.utils as test_utils
import torch
from fairseq.data import (
BacktranslationDataset,
LanguagePairDataset,... | data2vec_vision-main | deltalm/src/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 contextlib
import logging
import os
import random
import sys
import tempfile
import unittest
from io import StringIO
import torch
from... | data2vec_vision-main | deltalm/src/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 sys
import unittest
import torch
from fairseq.token_generation_constraints import *
def tensorize(constraints: List[List[int]]) -> t... | data2vec_vision-main | deltalm/src/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 argparse
import copy
import unittest
import tests.utils as test_utils
import torch
from fairseq.criterions.cross_entropy import CrossE... | data2vec_vision-main | deltalm/src/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 os
import random
import sys
from io import StringIO
import torch
import torch.nn.functional as F
from fairseq import o... | data2vec_vision-main | deltalm/src/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 unittest
import torch
import torch.nn as nn
from fairseq.modules import ConvTBC
class TestConvTBC(unittest.TestCase):
def test_c... | data2vec_vision-main | deltalm/src/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 argparse
import copy
import logging
import unittest
import torch
from fairseq.optim.fp16_optimizer import FP16Optimizer, MemoryEfficie... | data2vec_vision-main | deltalm/src/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 argparse
import logging
import unittest
import torch
from fairseq.optim.adam import FairseqAdam
from fairseq.optim.fp16_optimizer impo... | data2vec_vision-main | deltalm/src/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 unittest
import tests.utils as test_utils
import torch
from fairseq.data import TokenBlockDataset
class TestTokenBlockDataset(unitte... | data2vec_vision-main | deltalm/src/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 argparse
import tempfile
import unittest
import tests.utils as test_utils
import torch
from fairseq import search
from fairseq.data.di... | data2vec_vision-main | deltalm/src/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 unittest
import torch
from fairseq.data import LanguagePairDataset, TokenBlockDataset
from fairseq.data.concat_dataset import ConcatDa... | data2vec_vision-main | deltalm/src/tests/test_concat_dataset.py |
# 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 shutil
import sys
import tempfile
import unittest
from typing import Optional
from unittest.mock import MagicMock
class TestFileIO(unittest.TestCase):
_tmpdir: Optional[st... | data2vec_vision-main | deltalm/src/tests/test_file_io.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 os
import tempfile
import unittest
from io import StringIO
import torch
from . import test_binaries
c... | data2vec_vision-main | deltalm/src/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 unittest
import torch
from fairseq.data import Dictionary
from fairseq.modules import CharacterTokenEmbedder
class TestCharacterToke... | data2vec_vision-main | deltalm/src/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 collections
import os
import shutil
import tempfile
import unittest
import numpy as np
import torch
from scripts.average_checkpoints i... | data2vec_vision-main | deltalm/src/tests/test_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 tempfile
import unittest
import torch
from fairseq.data.dictionary import Dictionary
from fairs... | data2vec_vision-main | deltalm/src/tests/test_export.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... | data2vec_vision-main | deltalm/src/tests/test_multi_corpus_sampled_dataset.py |
data2vec_vision-main | deltalm/src/tests/gpu/__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 contextlib
import logging
import os
import tempfile
import unittest
from io import StringIO
import torch
from fairseq import options
f... | data2vec_vision-main | deltalm/src/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 functools
import sys
import unittest
import torch
from fairseq import distributed_utils as dist_utils
from .utils import objects_are... | data2vec_vision-main | deltalm/src/tests/distributed/test_distributed_utils.py |
data2vec_vision-main | deltalm/src/tests/distributed/__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 functools
import tempfile
import torch
def spawn_and_init(fn, world_size, args=None):
if args is None:
args = ()
wit... | data2vec_vision-main | deltalm/src/tests/distributed/utils.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... | data2vec_vision-main | deltalm/src/tests/speech_recognition/asr_test_base.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... | data2vec_vision-main | deltalm/src/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.
from examples.speech_recognition.criterions.cross_entropy_acc import (
CrossEntropyWithAccCriterion,
)
from .asr_t... | data2vec_vision-main | deltalm/src/tests/speech_recognition/test_cross_entropy.py |
#!/usr/bin/env python3
# import models/encoder/decoder to be tested
from examples.speech_recognition.models.vggtransformer import (
TransformerDecoder,
VGGTransformerEncoder,
VGGTransformerModel,
vggtransformer_1,
vggtransformer_2,
vggtransformer_base,
)
# import base test class
from .asr_test... | data2vec_vision-main | deltalm/src/tests/speech_recognition/test_vggtransformer.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... | data2vec_vision-main | deltalm/src/tests/speech_recognition/test_data_utils.py |
data2vec_vision-main | deltalm/src/tests/speech_recognition/__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.
"""
A modified version of the legacy DistributedDataParallel module that uses c10d
communication primitives. This version is simpler than the ... | data2vec_vision-main | deltalm/src/fairseq/legacy_distributed_data_parallel.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 typing import Callable, List, Optional
import torch
from fairseq import utils
from fairseq.data.indexed_dataset import g... | data2vec_vision-main | deltalm/src/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.
from collections import namedtuple
import numpy as np
import torch
from fairseq import utils
DecoderOut = namedtuple(
"IterativeRefinem... | data2vec_vision-main | deltalm/src/fairseq/iterative_refinement_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 logging
import torch
logger = logging.getLogger(__name__)
class NanDetector:
"""
Detects the first NaN or Inf in forward a... | data2vec_vision-main | deltalm/src/fairseq/nan_detector.py |
__version__ = "1.0.0a0"
| data2vec_vision-main | deltalm/src/fairseq/version.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
from typing import Union
from fairseq.dataclass import FairseqDataclass
from fairseq.dataclass.utils import po... | data2vec_vision-main | deltalm/src/fairseq/registry.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.
"""isort:skip_file"""
import os
import sys
try:
from .version import __version__ # noqa
except ImportError:
version_txt = os.path.jo... | data2vec_vision-main | deltalm/src/fairseq/__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 math
from typing import Dict, List, Optional
import torch
import torch.nn as nn
from fairseq import search, utils
from fairseq.data im... | data2vec_vision-main | deltalm/src/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 multiprocessing
import os
import pdb
import sys
__all__ = ["set_trace"]
_stdin = [None]
_stdin_lock = multiprocessing.Lock()
try:
... | data2vec_vision-main | deltalm/src/fairseq/pdb.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 re
SPACE_NORMALIZER = re.compile(r"\s+")
def tokenize_line(line):
line = SPACE_NORMALIZER.sub(" ", line)
line = line.strip(... | data2vec_vision-main | deltalm/src/fairseq/tokenizer.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... | data2vec_vision-main | deltalm/src/fairseq/hub_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 sys
import torch
from fairseq import utils
class SequenceScorer(object):
"""Scores the target for a given source sentence."""
... | data2vec_vision-main | deltalm/src/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 uuid
from typing import Dict, Optional
from torch import Tensor
class FairseqIncrementalState(object):
def __init__(self, *args,... | data2vec_vision-main | deltalm/src/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 argparse
import contextlib
import copy
import importlib
import logging
import os
import sys
import tempfile
import warnings
from iterto... | data2vec_vision-main | deltalm/src/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 ast
import collections
import contextlib
import logging
import os
import re
import traceback
from collections import OrderedDict
from t... | data2vec_vision-main | deltalm/src/fairseq/checkpoint_utils.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.