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.
import torch
from . import FairseqDataset
class ConcatSentencesDataset(FairseqDataset):
def __init__(self, *datasets):
super()... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/concat_sentences_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.
from functools import lru_cache
import numpy as np
import torch
from fairseq.data import data_utils, Dictionary
from . import BaseWrapperDa... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/mask_tokens_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.
from functools import lru_cache
from . import BaseWrapperDataset
class LRUCacheDataset(BaseWrapperDataset):
def __init__(self, dataset... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/lru_cache_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 numpy as np
import torch
import math
from . import data_utils, FairseqDataset
def collate(
samples,
pad_idx,
eos_idx,
... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/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.
from . import BaseWrapperDataset
class StripTokenDataset(BaseWrapperDataset):
def __init__(self, dataset, id_to_strip):
super()... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/strip_token_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.
try:
from collections.abc import Iterable
except ImportError:
from collections import Iterable
import contextlib
import itertools
impo... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/data_utils.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import itertools
import os
import random
from . import BaseWrapperDataset
from fairseq.data import data_utils
class ShardedDataset(BaseWrap... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/sharded_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 numpy as np
import torch
from . import BaseWrapperDataset
class PrependTokenDataset(BaseWrapperDataset):
def __init__(self, dat... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/prepend_token_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 torch
from . import FairseqDataset
class TransformEosDataset(FairseqDataset):
"""A :class:`~fairseq.data.FairseqDataset` wrapper... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/transform_eos_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 torch
from . import BaseWrapperDataset
class ColorizeDataset(BaseWrapperDataset):
""" Adds 'colors' property to net input that i... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/colorize_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 torch
from . import FairseqDataset
class RawLabelDataset(FairseqDataset):
def __init__(self, labels):
super().__init__(... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/raw_label_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.
from . import BaseWrapperDataset
class ListDataset(BaseWrapperDataset):
def __init__(self, dataset, sizes=None):
super().__init... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/list_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.
from collections import OrderedDict
import numpy as np
from . import FairseqDataset
class RoundRobinZipDatasets(FairseqDataset):
"""Zi... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/round_robin_zip_datasets.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 math
import os
import numpy as np
import torch
from . import data_utils
class CountingIterator(object):
"""Wra... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/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 subprocess
import tempfile
class PlasmaArray(object):
"""
Wrapper around numpy arrays that automatically moves the data to sh... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/plasma_utils.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import numpy as np
from . import BaseWrapperDataset, plasma_utils
class ResamplingDataset(BaseWrapperDataset):
"""Randomly samples from... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/resampling_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 numpy as np
import torch
from . import data_utils, FairseqDataset
def collate(
samples, pad_idx, eos_idx, left_pad_source=True, ... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/language_pair_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 numpy as np
import torch
from . import BaseWrapperDataset
class AppendTokenDataset(BaseWrapperDataset):
def __init__(self, data... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/append_token_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.
from fairseq.data import data_utils
from . import BaseWrapperDataset
class PadDataset(BaseWrapperDataset):
def __init__(self, dataset,... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/pad_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.
from functools import lru_cache
import os
import shutil
import struct
import numpy as np
import torch
from . import FairseqDataset
def __b... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/indexed_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 torch
from . import BaseWrapperDataset
class RollDataset(BaseWrapperDataset):
def __init__(self, dataset, shifts):
supe... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/roll_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.
from collections import Counter
from multiprocessing import Pool
import os
import torch
from fairseq.tokenizer import tokenize_line
from fai... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/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 numpy as np
import torch.utils.data
class EpochListening:
"""Mixin for receiving updates whenever the epoch increments."""
de... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/fairseq_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 numpy as np
import torch
from fairseq.data.monolingual_dataset import MonolingualDataset
from . import FairseqDataset
class LMConte... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/lm_context_window_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 numpy as np
import torch
from fairseq.data import FairseqDataset, plasma_utils
class TokenBlockDataset(FairseqDataset):
"""Break... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/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.
from . import FairseqDataset
from typing import Optional
class TransformEosLangPairDataset(FairseqDataset):
"""A :class:`~fairseq.data.... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/transform_eos_lang_pair_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.
from fairseq.data import Dictionary
class MaskedLMDictionary(Dictionary):
"""
Dictionary for Masked Language Modelling tasks. This e... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/legacy/masked_lm_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 math
import numpy as np
import torch
from fairseq.data import FairseqDataset
class BlockPairDataset(FairseqDataset):
"""Break a... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/legacy/block_pair_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.
from .masked_lm_dictionary import BertDictionary, MaskedLMDictionary
from .block_pair_dataset import BlockPairDataset
from .masked_lm_dataset ... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/legacy/__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 numpy as np
import torch
from typing import Dict, List, Tuple
from fairseq.data import FairseqDataset, data_utils
from ... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/legacy/masked_lm_dataset.py |
data2vec_vision-main | infoxlm/fairseq/fairseq/data/audio/__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
import numpy as np
import sys
import torch
import torch.nn.functional as F
from .. import FairseqDataset
class RawAudioDataset(... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/audio/raw_audio_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.
from fairseq import file_utils
from fairseq.data.encoders import register_bpe
@register_bpe('sentencepiece')
class SentencepieceBPE(object):... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/encoders/sentencepiece_bpe.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from fairseq import file_utils
from fairseq.data.encoders import register_bpe
@register_bpe('fastbpe')
class fastBPE(object):
@staticme... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/encoders/fastbpe.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from fairseq.data.encoders import register_tokenizer
@register_tokenizer('nltk')
class NLTKTokenizer(object):
def __init__(self, source... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/encoders/nltk_tokenizer.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from fairseq import file_utils
from fairseq.data.encoders import register_bpe
from .gpt2_bpe_utils import get_encoder
DEFAULT_ENCODER_JSON ... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/encoders/gpt2_bpe.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from fairseq import file_utils
from fairseq.data.encoders import register_bpe
@register_bpe('subword_nmt')
class SubwordNMTBPE(object):
... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/encoders/subword_nmt_bpe.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 importlib
import os
from fairseq import registry
build_tokenizer, register_tokenizer, TOKENIZER_REGISTRY = registry.setup_registry(... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/encoders/__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 fairseq.data.encoders import register_bpe
@register_bpe('bert')
class BertBPE(object):
@staticmethod
def add_args(parser):
... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/encoders/hf_bert_bpe.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.data import encoders
def get_whole_word_mask(args, dictionary):
bpe = encoders.build_bpe(args)
if bpe is n... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/encoders/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 re
from fairseq.data.encoders import register_tokenizer
@register_tokenizer('space')
class SpaceTokenizer(object):
def __init__... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/encoders/space_tokenizer.py |
"""
Byte pair encoding utilities from GPT-2.
Original source: https://github.com/openai/gpt-2/blob/master/src/encoder.py
Original license: MIT
"""
from functools import lru_cache
import json
@lru_cache()
def bytes_to_unicode():
"""
Returns list of utf-8 byte and a corresponding list of unicode strings.
... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/encoders/gpt2_bpe_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.
from fairseq.data.encoders import register_tokenizer
@register_tokenizer('moses')
class MosesTokenizer(object):
@staticmethod
def a... | data2vec_vision-main | infoxlm/fairseq/fairseq/data/encoders/moses_tokenizer.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 torch.nn.modules.loss import _Loss
class FairseqCriterion(_Loss):
def __init__(self, args, task):
super().__init__()
... | data2vec_vision-main | infoxlm/fairseq/fairseq/criterions/fairseq_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
import torch.nn.functional as F
from fairseq import utils
from . import FairseqCriterion, register_criterion
@register_criteri... | data2vec_vision-main | infoxlm/fairseq/fairseq/criterions/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 math
import torch.nn.functional as F
from fairseq import utils
from . import FairseqCriterion, register_criterion
@register_criteri... | data2vec_vision-main | infoxlm/fairseq/fairseq/criterions/adaptive_loss.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 . import FairseqCriterion, register_criterion
def ... | data2vec_vision-main | infoxlm/fairseq/fairseq/criterions/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 math
import torch.nn.functional as F
from fairseq import utils
import torch
from torch import Tensor
from . import FairseqCriterion, ... | data2vec_vision-main | infoxlm/fairseq/fairseq/criterions/nat_loss.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 importlib
import os
from fairseq import registry
from fairseq.criterions.fairseq_criterion import FairseqCriterion
build_criterion, ... | data2vec_vision-main | infoxlm/fairseq/fairseq/criterions/__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 fairseq import utils
from . import FairseqCriterion, register_criterion
def label_smoothed_nll_loss(lprobs, target, epsil... | data2vec_vision-main | infoxlm/fairseq/fairseq/criterions/label_smoothed_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.
from torch import nn
from fairseq import utils
from . import FairseqCriterion, register_criterion
@register_criterion('composite_loss')
cla... | data2vec_vision-main | infoxlm/fairseq/fairseq/criterions/composite_loss.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 . import FairseqCriterion, register_criterion
@reg... | data2vec_vision-main | infoxlm/fairseq/fairseq/criterions/binary_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 math
import torch
import torch.nn.functional as F
from fairseq import utils
from . import FairseqCriterion, register_criterion
@re... | data2vec_vision-main | infoxlm/fairseq/fairseq/criterions/sentence_prediction.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 fairseq import utils
from .label_smoothed_cross_entropy import LabelSmoothedCrossEntropyCriterion
from . import register_cr... | data2vec_vision-main | infoxlm/fairseq/fairseq/criterions/label_smoothed_cross_entropy_with_alignment.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 . import FairseqCriterion, register_criterion
@re... | data2vec_vision-main | infoxlm/fairseq/fairseq/criterions/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 math
import torch
import torch.nn.functional as F
from fairseq import utils
from . import FairseqCriterion, register_criterion
@re... | data2vec_vision-main | infoxlm/fairseq/fairseq/criterions/sentence_ranking.py |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# fairseq documentation build configuration file, created by
# sphinx-quickstart on Fri Aug 17 21:45:30 2018.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# au... | data2vec_vision-main | infoxlm/fairseq/docs/conf.py |
../preprocess.py | data2vec_vision-main | infoxlm/fairseq/fairseq_cli/preprocess.py |
../generate.py | data2vec_vision-main | infoxlm/fairseq/fairseq_cli/generate.py |
data2vec_vision-main | infoxlm/fairseq/fairseq_cli/__init__.py | |
../setup.py | data2vec_vision-main | infoxlm/fairseq/fairseq_cli/setup.py |
../interactive.py | data2vec_vision-main | infoxlm/fairseq/fairseq_cli/interactive.py |
../train.py | data2vec_vision-main | infoxlm/fairseq/fairseq_cli/train.py |
../eval_lm.py | data2vec_vision-main | infoxlm/fairseq/fairseq_cli/eval_lm.py |
../score.py | data2vec_vision-main | infoxlm/fairseq/fairseq_cli/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.
__version__ = '0.9.0'
import examples.noisychannel # noqa
| data2vec_vision-main | infoxlm/fairseq/examples/__init__.py |
import rerank_utils
import rerank_generate
import rerank_score_bw
import rerank_score_lm
from fairseq import bleu, options
from fairseq.data import dictionary
from examples.noisychannel import rerank_options
from multiprocessing import Pool
import math
import numpy as np
def score_target_hypo(args, a, b, c, lenpen, ... | data2vec_vision-main | infoxlm/fairseq/examples/noisychannel/rerank.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from fairseq import options
def get_reranking_parser(default_task='translation'):
parser = options.get_parser('Generation and reranking'... | data2vec_vision-main | infoxlm/fairseq/examples/noisychannel/rerank_options.py |
import rerank
import argparse
import numpy as np
import random
from examples.noisychannel import rerank_options
from fairseq import options
def random_search(args):
param_values = []
tuneable_parameters = ['lenpen', 'weight1', 'weight2', 'weight3']
initial_params = [args.lenpen, args.weight1, args.weight2... | data2vec_vision-main | infoxlm/fairseq/examples/noisychannel/rerank_tune.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 .rerank_options import * # noqa
| data2vec_vision-main | infoxlm/fairseq/examples/noisychannel/__init__.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.
"""
Generate n-best translations using a trained model.
"""
from contextlib import redirect_stdout
import os
import... | data2vec_vision-main | infoxlm/fairseq/examples/noisychannel/rerank_generate.py |
import subprocess
import os
import re
from fairseq import options
import eval_lm
import preprocess
from contextlib import redirect_stdout
import math
def reprocess(fle):
# takes in a file of generate.py translation generate_output
# returns a source dict and hypothesis dict, where keys are the ID num (as a st... | data2vec_vision-main | infoxlm/fairseq/examples/noisychannel/rerank_utils.py |
import rerank_utils
import os
from fairseq import options
from examples.noisychannel import rerank_options
def score_lm(args):
using_nbest = args.nbest_list is not None
pre_gen, left_to_right_preprocessed_dir, right_to_left_preprocessed_dir, \
backwards_preprocessed_dir, lm_preprocessed_dir = \
... | data2vec_vision-main | infoxlm/fairseq/examples/noisychannel/rerank_score_lm.py |
import rerank_utils
import os
from fairseq import options
from examples.noisychannel import rerank_options
from contextlib import redirect_stdout
import generate
def score_bw(args):
if args.backwards1:
scorer1_src = args.target_lang
scorer1_tgt = args.source_lang
else:
... | data2vec_vision-main | infoxlm/fairseq/examples/noisychannel/rerank_score_bw.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.
"""
Scoring script for computing pairwise BLEU and multi-ref BLEU over a set of
candidate hypotheses.
See `"Mixture Mod... | data2vec_vision-main | infoxlm/fairseq/examples/translation_moe/score.py |
from . import tasks, criterions, models # noqa
| data2vec_vision-main | infoxlm/fairseq/examples/speech_recognition/__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.
"""
Wav2letter decoders.
"""
import math
import itertools as it
import torch
from fairseq import utils
from examples.s... | data2vec_vision-main | infoxlm/fairseq/examples/speech_recognition/w2l_decoder.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.
"""
Run inference for pre-processed data with a trained model.
"""
import logging
import math
import os
import sen... | data2vec_vision-main | infoxlm/fairseq/examples/speech_recognition/infer.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import json
import os
import re
import torch
from fairseq.data import Dictionary
from fairseq.tasks import FairseqTask, register_task
from ex... | data2vec_vision-main | infoxlm/fairseq/examples/speech_recognition/tasks/speech_recognition.py |
import importlib
import os
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_module('examples.speech_recognition.tasks.' + task_name)
| data2vec_vision-main | infoxlm/fairseq/examples/speech_recognition/tasks/__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.
from __future__ import absolute_import, division, print_function, unicode_literals
from collections import namedtuple
... | data2vec_vision-main | infoxlm/fairseq/examples/speech_recognition/datasets/asr_prep_json.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 __future__ import absolute_import, division, print_function, unicode_literals
import re
from collections import ... | data2vec_vision-main | infoxlm/fairseq/examples/speech_recognition/utils/wer_utils.py |
import importlib
import os
for file in os.listdir(os.path.dirname(__file__)):
if file.endswith('.py') and not file.startswith('_'):
model_name = file[:file.find('.py')]
importlib.import_module('examples.speech_recognition.models.' + model_name)
| data2vec_vision-main | infoxlm/fairseq/examples/speech_recognition/models/__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 argparse
import math
from collections.abc import Iterable
import torch
import torch.nn as nn
from fairseq import utils
from fairseq.mo... | data2vec_vision-main | infoxlm/fairseq/examples/speech_recognition/models/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 math
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq.models import (
Fairs... | data2vec_vision-main | infoxlm/fairseq/examples/speech_recognition/models/w2l_conv_glu_enc.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.
"""
Replabel transforms for use with wav2letter's ASG criterion.
"""
def replabel_symbol(i):
"""
Replabel sy... | data2vec_vision-main | infoxlm/fairseq/examples/speech_recognition/data/replabels.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 .asr_dataset import AsrDataset
__all__ = [
'AsrDataset',
]
| data2vec_vision-main | infoxlm/fairseq/examples/speech_recognition/data/__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.
"""
This module contains collection of classes which implement
collate functionalities for various tasks.
Collaters should know wh... | data2vec_vision-main | infoxlm/fairseq/examples/speech_recognition/data/collaters.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
def calc_mean_invstddev(feature):
if len(feature.size()) != 2:
raise ValueError("We expect the input feature to be ... | data2vec_vision-main | infoxlm/fairseq/examples/speech_recognition/data/data_utils.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import os
import numpy as np
from fairseq.data import FairseqDataset
from . import data_utils
from .collaters import Seq2SeqCollater
class ... | data2vec_vision-main | infoxlm/fairseq/examples/speech_recognition/data/asr_dataset.py |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import absolute_import, division, print_function, unicode_literals
import logging
import math
import torch
import torch.nn.f... | data2vec_vision-main | infoxlm/fairseq/examples/speech_recognition/criterions/cross_entropy_acc.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 math
import numpy as np
import torch
from fairseq import utils
from fairseq.criterions import FairseqCriterion... | data2vec_vision-main | infoxlm/fairseq/examples/speech_recognition/criterions/ASG_loss.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 logging
import math
from itertools import groupby
import torch
import torch.nn.functional as F
from fairseq im... | data2vec_vision-main | infoxlm/fairseq/examples/speech_recognition/criterions/CTC_loss.py |
import importlib
import os
# ASG loss requires wav2letter
blacklist = set()
try:
import wav2letter
except ImportError:
blacklist.add("ASG_loss.py")
for file in os.listdir(os.path.dirname(__file__)):
if file.endswith(".py") and not file.startswith("_") and file not in blacklist:
criterion_name = f... | data2vec_vision-main | infoxlm/fairseq/examples/speech_recognition/criterions/__init__.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.
import argparse
import contextlib
import sys
from collections import Counter
from multiprocessing im... | data2vec_vision-main | infoxlm/fairseq/examples/roberta/multiprocessing_bpe_encoder.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.
import argparse
import json
import os
import re
class InputExample:
def __init__(self, paragrap... | data2vec_vision-main | infoxlm/fairseq/examples/roberta/preprocess_RACE.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 functools import lru_cache
import json
def convert_sentence_to_json(sentence):
if '_' in sentence:
prefix, rest = sentence.... | data2vec_vision-main | infoxlm/fairseq/examples/roberta/wsc/wsc_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
import torch.nn.functional as F
from fairseq import utils
from fairseq.data import encoders
from fairseq.criterions... | data2vec_vision-main | infoxlm/fairseq/examples/roberta/wsc/wsc_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.
from . import wsc_criterion # noqa
from . import wsc_task # noqa
| data2vec_vision-main | infoxlm/fairseq/examples/roberta/wsc/__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 tempfile
import numpy as np
import torch
import torch.nn.functional as F
from fairseq import utils
from fairseq... | data2vec_vision-main | infoxlm/fairseq/examples/roberta/wsc/wsc_task.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.