python_code
stringlengths
0
992k
repo_name
stringlengths
8
46
file_path
stringlengths
5
162
from vlmo.datasets import WikibkDataset from .datamodule_base import BaseDataModule class WikibkDataModule(BaseDataModule): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @property def dataset_cls(self): return WikibkDataset @property def dataset_name(self...
EXA-1-master
exa/models/unilm-master/vlmo/vlmo/datamodules/wikibk_datamodule.py
from vlmo.datasets import CocoCaptionKarpathyDataset from .datamodule_base import BaseDataModule class CocoCaptionKarpathyDataModule(BaseDataModule): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @property def dataset_cls(self): return CocoCaptionKarpathyDataset ...
EXA-1-master
exa/models/unilm-master/vlmo/vlmo/datamodules/coco_caption_karpathy_datamodule.py
from vlmo.datasets import F30KCaptionKarpathyDataset from .datamodule_base import BaseDataModule class F30KCaptionKarpathyDataModule(BaseDataModule): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @property def dataset_cls(self): return F30KCaptionKarpathyDataset ...
EXA-1-master
exa/models/unilm-master/vlmo/vlmo/datamodules/f30k_caption_karpathy_datamodule.py
import json import pandas as pd import pyarrow as pa import os from tqdm import tqdm from collections import defaultdict def process(root, iden, row): texts = [r["sentence"] for r in row] labels = [r["label"] for r in row] split = iden.split("-")[0] if iden.startswith("train"): directory = ...
EXA-1-master
exa/models/unilm-master/vlmo/vlmo/utils/write_nlvr2.py
import json import pandas as pd import pyarrow as pa import gc import random import os from tqdm import tqdm from glob import glob def path2rest(line): return [ "None", [line], "wikibk", "train", ] def make_arrow(root, dataset_root): for index in range(0, 50): fi...
EXA-1-master
exa/models/unilm-master/vlmo/vlmo/utils/write_wikibk.py
import json import pandas as pd import pyarrow as pa import random import os from tqdm import tqdm from glob import glob from collections import defaultdict def path2rest(path, iid2captions): name = path.split("/")[-1] iid = int(name[:-4]) with open(path, "rb") as fp: binary = fp.read() cdi...
EXA-1-master
exa/models/unilm-master/vlmo/vlmo/utils/write_vg.py
import json import pandas as pd import pyarrow as pa import random import os from tqdm import tqdm from glob import glob from collections import defaultdict def path2rest(path, iid2captions, iid2split): name = path.split("/")[-1] with open(path, "rb") as fp: binary = fp.read() captions = iid2ca...
EXA-1-master
exa/models/unilm-master/vlmo/vlmo/utils/write_f30k_karpathy.py
import json import os import pandas as pd import pyarrow as pa import random from tqdm import tqdm from glob import glob from collections import defaultdict def path2rest(path, iid2captions, iid2split): name = path.split("/")[-1] with open(path, "rb") as fp: binary = fp.read() captions = iid2capt...
EXA-1-master
exa/models/unilm-master/vlmo/vlmo/utils/write_coco_karpathy.py
import json import pandas as pd import pyarrow as pa import gc import random import os from tqdm import tqdm from glob import glob def path2rest(path, iid2captions): split, _, name = path.split("/")[-3:] split = split.split("_")[-1] iid = name with open(path, "rb") as fp: binary = fp.read() ...
EXA-1-master
exa/models/unilm-master/vlmo/vlmo/utils/write_conceptual_caption.py
import json import pandas as pd import pyarrow as pa import random import os from tqdm import tqdm from glob import glob from collections import defaultdict, Counter from .glossary import normalize_word def get_score(occurences): if occurences == 0: return 0.0 elif occurences == 1: return 0.3...
EXA-1-master
exa/models/unilm-master/vlmo/vlmo/utils/write_vqa.py
import json import pandas as pd import pyarrow as pa import gc import random import os from tqdm import tqdm from glob import glob def path2rest(path, iid2captions): split, _, name = path.split("/")[-3:] split = split.split("_")[-1] iid = name with open(path, "rb") as fp: binary = fp.read() ...
EXA-1-master
exa/models/unilm-master/vlmo/vlmo/utils/write_sbu.py
import re contractions = { "aint": "ain't", "arent": "aren't", "cant": "can't", "couldve": "could've", "couldnt": "couldn't", "couldn'tve": "couldn't've", "couldnt've": "couldn't've", "didnt": "didn't", "doesnt": "doesn't", "dont": "don't", "hadnt": "hadn't", "hadnt've":...
EXA-1-master
exa/models/unilm-master/vlmo/vlmo/utils/glossary.py
from .utils import ( inception_normalize, MinMaxResize, ) from torchvision import transforms from .randaug import RandAugment def pixelbert_transform(size=800): longer = int((1333 / 800) * size) return transforms.Compose( [ MinMaxResize(shorter=size, longer=longer), tra...
EXA-1-master
exa/models/unilm-master/vlmo/vlmo/transforms/pixelbert.py
from .pixelbert import ( pixelbert_transform, pixelbert_transform_randaug, ) from .square_transform import ( square_transform, square_transform_randaug, ) _transforms = { "pixelbert": pixelbert_transform, "pixelbert_randaug": pixelbert_transform_randaug, "square_transform": square_transform...
EXA-1-master
exa/models/unilm-master/vlmo/vlmo/transforms/__init__.py
# code in this file is adpated from rpmcruz/autoaugment # https://github.com/rpmcruz/autoaugment/blob/master/transformations.py import random import PIL, PIL.ImageOps, PIL.ImageEnhance, PIL.ImageDraw import numpy as np import torch from PIL import Image def ShearX(img, v): # [-0.3, 0.3] assert -0.3 <= v <= 0.3 ...
EXA-1-master
exa/models/unilm-master/vlmo/vlmo/transforms/randaug.py
from torchvision import transforms from PIL import Image class MinMaxResize: def __init__(self, shorter=800, longer=1333): self.min = shorter self.max = longer def __call__(self, x): w, h = x.size scale = self.min / min(w, h) if h < w: newh, neww = self.min...
EXA-1-master
exa/models/unilm-master/vlmo/vlmo/transforms/utils.py
import cv2 import numpy as np ## aug functions def identity_func(img): return img def autocontrast_func(img, cutoff=0): ''' same output as PIL.ImageOps.autocontrast ''' n_bins = 256 def tune_channel(ch): n = ch.size cut = cutoff * n // 100 if cut == 0: ...
EXA-1-master
exa/models/unilm-master/vlmo/vlmo/transforms/randaugment.py
# code in this file is adpated from the ALBEF repo (https://github.com/salesforce/ALBEF) from .utils import ( inception_normalize, ) from torchvision import transforms from .randaugment import RandomAugment from PIL import Image def square_transform(size=224): return transforms.Compose( [ ...
EXA-1-master
exa/models/unilm-master/vlmo/vlmo/transforms/square_transform.py
from .vlmo_module import VLMo
EXA-1-master
exa/models/unilm-master/vlmo/vlmo/modules/__init__.py
import os import torch import torch.nn as nn import torch.nn.functional as F import pytorch_lightning as pl import numpy as np import vlmo.modules.multiway_transformer from transformers.models.bert.modeling_bert import BertConfig, BertEmbeddings from vlmo.modules import heads, objectives, vlmo_utils from pytorch_light...
EXA-1-master
exa/models/unilm-master/vlmo/vlmo/modules/vlmo_module.py
import torch import random import json from transformers.optimization import AdamW from transformers import ( get_polynomial_decay_schedule_with_warmup, get_cosine_schedule_with_warmup, ) from vlmo.modules.dist_utils import all_gather from vlmo.modules.objectives import compute_irtr_recall, compute_irtr_recall...
EXA-1-master
exa/models/unilm-master/vlmo/vlmo/modules/vlmo_utils.py
import torch import torch.nn as nn import torch.nn.functional as F import os import glob import json import tqdm import functools import torch.distributed as dist from torch.utils.data.distributed import DistributedSampler from einops import rearrange from pytorch_lightning.utilities.distributed import rank_zero_info ...
EXA-1-master
exa/models/unilm-master/vlmo/vlmo/modules/objectives.py
""" Vision Transformer (ViT) in PyTorch A PyTorch implement of Vision Transformers as described in 'An Image Is Worth 16 x 16 Words: Transformers for Image Recognition at Scale' - https://arxiv.org/abs/2010.11929 The official jax code is released and available at https://github.com/google-research/vision_transformer ...
EXA-1-master
exa/models/unilm-master/vlmo/vlmo/modules/multiway_transformer.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved """ This file contains primitives for multi-gpu communication. This is useful when doing distributed training. """ import functools import logging import numpy as np import pickle import torch import torch.distributed as dist import torch _LOCAL_...
EXA-1-master
exa/models/unilm-master/vlmo/vlmo/modules/dist_utils.py
import torch import torch.nn as nn import torch.nn.functional as F from transformers.models.bert.modeling_bert import BertPredictionHeadTransform class Pooler(nn.Module): def __init__(self, hidden_size): super().__init__() self.dense = nn.Linear(hidden_size, hidden_size) self.activation =...
EXA-1-master
exa/models/unilm-master/vlmo/vlmo/modules/heads.py
EXA-1-master
exa/models/unilm-master/vlmo/vlmo/gadgets/__init__.py
import torch from torchmetrics import Metric class Accuracy(Metric): def __init__(self, dist_sync_on_step=False): super().__init__(dist_sync_on_step=dist_sync_on_step) self.add_state("correct", default=torch.tensor(0.0), dist_reduce_fx="sum") self.add_state("total", default=torch.tensor(0....
EXA-1-master
exa/models/unilm-master/vlmo/vlmo/gadgets/my_metrics.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
EXA-1-master
exa/models/unilm-master/minilm/examples/run_xnli.py
# -------------------------------------------------------- # WavLM: Large-Scale Self-Supervised Pre-training for Full Stack Speech Processing (https://arxiv.org/abs/2110.13900.pdf) # Github source: https://github.com/microsoft/unilm/tree/master/wavlm # Copyright (c) 2021 Microsoft # Licensed under The MIT License [se...
EXA-1-master
exa/models/unilm-master/wavlm/modules.py
# -------------------------------------------------------- # WavLM: Large-Scale Self-Supervised Pre-training for Full Stack Speech Processing (https://arxiv.org/abs/2110.13900.pdf) # Github source: https://github.com/microsoft/unilm/tree/master/wavlm # Copyright (c) 2021 Microsoft # Licensed under The MIT License [se...
EXA-1-master
exa/models/unilm-master/wavlm/WavLM.py
import argparse import os import torch from fairseq.data import (FairseqDataset, PrependTokenDataset, TokenBlockDataset, TruncateDataset, data_utils, StripTokenDataset, ConcatDataset) from fairseq.data.indexed_dataset import make_builder from tqdm import tqdm from transformers import AutoToke...
EXA-1-master
exa/models/unilm-master/infoxlm/tools/para2bin.py
import argparse import os import torch from fairseq.data import (FairseqDataset, PrependTokenDataset, TokenBlockDataset, TruncateDataset, data_utils, StripTokenDataset, ConcatDataset, PrependTokenDataset, AppendTokenDataset) from fairseq.data.indexed_dataset import make_builder from tqdm impo...
EXA-1-master
exa/models/unilm-master/infoxlm/tools/para2bin4xlco.py
import argparse import os import torch from fairseq.data import (FairseqDataset, PrependTokenDataset, TokenBlockDataset, TruncateDataset, data_utils) from fairseq.data.indexed_dataset import make_builder from tqdm import tqdm from transformers import AutoTokenizer class IndexDataset(Fairseq...
EXA-1-master
exa/models/unilm-master/infoxlm/tools/txt2bin.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. """ from collections import Counter from iterto...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/preprocess.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. """ Translate pre-processed data with a trained model. """ import torch from fairseq import bleu, checkpoint_utils,...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/generate.py
#!/usr/bin/env python3 -u #!/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 torch from fairseq import checkpoint_utils, options, progress_bar, utils def mai...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/validate.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 from setuptools import setup, find_packages, Extension import sys if sys.version_info < (3, 5): sys.exi...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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. """ Translate raw text with a trained model. Batches data on-the-fly. """ from collections import namedtuple import ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/interactive.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. """ Train a new model on one or across multiple GPUs. """ import collections import math import random import numpy...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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 from fairseq.hub_utils import BPEHubInterface as bpe # noqa from fairseq.hub_utils import TokenizerHubInterface as tokenize...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/hubconf.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. """ Evaluate the perplexity of a trained language model. """ import numpy as np import torch from fairseq import c...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/eval_lm.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. """ BLEU scoring of generated translations against reference translations. """ import argparse import os import sys fr...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/score.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 import torch from fairseq.data import Dictionary class TestDictionary(unittest.TestCase): def test_fi...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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 from multiprocessing import Manager import random import unittest import torch import torch.nn as nn from fairseq import dis...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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): ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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): x...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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 torch import unittest from fairseq.modules.sparse_multihead_attention import SparseMultiheadAttention class TestSparseMultiheadAttent...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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 contextlib from io import StringIO import unittest from unittest.mock import MagicMock, patch import torch from fairseq import data, ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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 torch from fairseq.sequence_scorer import SequenceScorer import tests.utils as test_utils class Te...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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 torch import unittest from fairseq.modules.multihead_attention import MultiheadAttention class TestMultiheadAttention(unittest.TestCa...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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 collections import unittest import numpy as np from fairseq.data import ListDataset, ResamplingDataset class TestResamplingDataset(...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/tests/test_resampling_dataset.py
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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 torch from fairseq.data import ( BacktranslationDataset, LanguagePairDataset, TransformEosDataset, ) from...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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 from io import StringIO import os import random import sys import tempfile import unittest import torch from fairseq impor...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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 argparse import copy import unittest import torch from fairseq.criterions.cross_entropy import CrossEntropyCriterion from fairseq.cri...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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 torch from fairseq import utils from fairseq.data import Dictionary from fairseq.data.language_pair_dataset import col...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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 torch import unittest from fairseq.modules import ConvTBC import torch.nn as nn class TestConvTBC(unittest.TestCase): def test_c...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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 unittest import torch from fairseq.optim.adam import FairseqAdam from fairseq.optim.fp16_optimizer import MemoryEffic...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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 torch from fairseq.data import TokenBlockDataset import tests.utils as test_utils class TestTokenBlockDataset(unit...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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 unittest import torch from fairseq.sequence_generator import SequenceGenerator import tests.utils as test_utils cl...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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 contextlib from io import StringIO import json import os import tempfile import unittest from . import test_binaries class TestRepro...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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 torch import unittest from fairseq.data import Dictionary from fairseq.modules import CharacterTokenEmbedder class TestCharacterToke...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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 tempfile import unittest import shutil import numpy as np import torch from torch import nn from script...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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 unittest from collections import OrderedDict import numpy as np import torch from fairseq.data import LanguagePairDataset, TokenBlockD...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/tests/test_multi_corpus_sampled_dataset.py
#!/usr/bin/env python3 import argparse import os import unittest from inspect import currentframe, getframeinfo import numpy as np import torch from fairseq.data import data_utils as fairseq_data_utils from fairseq.data.dictionary import Dictionary from fairseq.models import ( BaseFairseqModel, FairseqDecoder...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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_test_base i...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/tests/speech_recognition/test_vggtransformer.py
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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 ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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 import torch import sys from fairseq import utils from fairseq.data.indexed_dataset import get_available_dataset_impl def ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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 torch from fairseq import utils DecoderOut = namedtuple('IterativeRefinementDecoderOut', [ '...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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 time class AverageMeter(object): """Computes and stores the average and current value""" def __init__(self): self.res...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/meters.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 REGISTRIES = {} def setup_registry( registry_name: str, base_class=None, default=None, ): assert registry_...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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. import ctypes import math import torch try: from fairseq import libbleu except ImportError as e: import sys sys.stderr.write('ERR...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/bleu.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. __all__ = ['pdb'] __version__ = '0.9.0' import fairseq.criterions # noqa import fairseq.models # noqa import fairseq.modules # noqa import...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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 import torch from fairseq import search, utils from fairseq.data import data_utils from fairseq.models import FairseqIncremental...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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: ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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()...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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 os import torch from torch import nn from fairseq import utils from fairseq.dat...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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 torch import sys from fairseq import utils class SequenceScorer(object): """Scores the target for a given source sentence.""" ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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. from collections import defaultdict import contextlib import copy import importlib.util import math import os import sys from typing import Ca...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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 collections import logging import os import re import shutil import traceback from collections import OrderedDict from typing import Un...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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 os import pickle import socket import subprocess import warnings import torch import torch.distributed as dist from fairseq import ut...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/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. """ Utilities for working with the local dataset cache. This file is adapted from `AllenNLP <https://github.com/allenai/allennlp>`_. and `hugg...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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. import math import torch class Search(object): def __init__(self, tgt_dict): self.pad = tgt_dict.pad() self.unk = tgt_...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/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. """ Wrapper around various loggers and progress bars (e.g., tqdm). """ from collections import OrderedDict import json from numbers import Nu...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/progress_bar.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. """ Train a network across multiple GPUs. """ import contextlib import math import os import sys from collections import OrderedDict from ite...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/trainer.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 Counter import os from fairseq.tokenizer import tokenize_line def safe_readline(f): pos = f.tell() while Tr...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/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 numpy as np import torch from fairseq import tokenizer from fairseq.data import ( data_utils, FairseqDataset, iterators, ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/tasks/fairseq_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. import os from fairseq.data import ( data_utils, Dictionary, AppendTokenDataset, DenoisingDataset, PrependTokenDataset, ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/tasks/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. from collections import OrderedDict import os import torch from fairseq import options, utils from fairseq.data import ( Dictionary, ...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/tasks/multilingual_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. import torch from fairseq.utils import new_arange from fairseq.tasks import register_task from fairseq.tasks.translation import TranslationTa...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/tasks/translation_lev.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 torch from fairseq import utils from fairseq.data import ( data_utils, Dictionary, MonolingualDataset, Toke...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/tasks/language_modeling.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 numpy as np import os from fairseq import tokenizer from fairseq.data import ( ConcatDataset, indexed_dataset...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/tasks/legacy_masked_lm.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 importlib import os from .fairseq_task import FairseqTask TASK_REGISTRY = {} TASK_CLASS_NAMES = set() def setup_tas...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/tasks/__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 os from fairseq.data import FileAudioDataset from . import FairseqTask, register_task @register_task('audio_pretraining') class Audi...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/tasks/audio_pretraining.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 os from fairseq import options, utils from fairseq.data import ( AppendTokenDataset, ConcatDataset, data_...
EXA-1-master
exa/models/unilm-master/infoxlm/fairseq/fairseq/tasks/translation.py