repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/numel_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 NumelDataset(BaseWrapperDataset):
def __init__(self, dataset, re... | 786 | 23.59375 | 65 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/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 numpy as np
import torch
from fairseq.data import data_utils
class WordNoising(object):
"""Generate a noisy version of a sentence... | 12,422 | 36.083582 | 88 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/bucket_pad_length_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.nn.functional as F
from fairseq.data import BaseWrapperDataset
from fairseq.data.data_utils import get_buckets... | 2,360 | 28.886076 | 79 | py |
CIF-HieraDist | CIF-HieraDist-main/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.
import torch
from . import FairseqDataset
class ConcatSentencesDataset(FairseqDataset):
def __init__(self, *datasets):
super().... | 1,558 | 27.345455 | 83 | py |
CIF-HieraDist | CIF-HieraDist-main/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 logging
import numpy as np
import torch.utils.data
from fairseq.data import data_utils
logger = logging.getLogger(__name__)
class Ep... | 7,123 | 33.582524 | 91 | py |
CIF-HieraDist | CIF-HieraDist-main/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 FairseqDataset
class TransformEosDataset(FairseqDataset):
"""A :class:`~fairseq.data.FairseqDataset` wrapper... | 4,575 | 36.818182 | 88 | py |
CIF-HieraDist | CIF-HieraDist-main/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 . import BaseWrapperDataset
class ListDataset(BaseWrapperDataset):
def __init__(self, dataset, sizes=None):
super().__init_... | 729 | 21.121212 | 65 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/num_samples_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
class NumSamplesDataset(FairseqDataset):
def __getitem__(self, index):
return 1
def __len__(se... | 404 | 21.5 | 65 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/multilingual/sampled_multi_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 datetime
import hashlib
import logging
import time
from bisect import bisect_right
from collections import OrderedDict, defaultdict
fro... | 18,338 | 38.185897 | 119 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/multilingual/sampling_method.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
from typing import List
logger = logging.getLogger(__name__)
def uniform(dataset_sizes: List[int]):
return [1.0] * len(... | 2,068 | 25.189873 | 78 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/multilingual/multilingual_data_manager.py | # Copyright (c) Facebook, Inc. and its 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 json
import logging
import math
import os
from collections import OrderedDict, defaultdict
from argparse import Argume... | 44,985 | 37.88159 | 120 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/multilingual/__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.
| 177 | 34.6 | 65 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/multilingual/multilingual_utils.py | from enum import Enum
from typing import Dict, List, Optional, Sequence
import torch
from fairseq.data import Dictionary
class EncoderLangtok(Enum):
"""
Prepend to the beginning of source sentence either the
source or target language token. (src/tgt).
"""
src = "src"
tgt = "tgt"
class Lang... | 1,623 | 24.375 | 85 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/multilingual/sampled_multi_epoch_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 hashlib
import logging
import math
import numpy as np
from fairseq.data import SampledMultiDataset
from .sampled_multi_dataset import... | 7,823 | 38.12 | 119 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/audio/data_cfg.py | # Copyright (c) Facebook, Inc. and 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 pathlib import Path
from typing import Dict, Optional
class S2TDataConfig(object):
"""Wrapper class for data config YAML"""
de... | 5,903 | 35.220859 | 80 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/audio/hubert_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 itertools
import logging
import os
import sys
from typing import Any, List, Optional, Union
import numpy as np
import torch
import to... | 12,325 | 34.727536 | 86 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/audio/multi_modality_dataset.py | # Copyright (c) 2021-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
import logging
import math
from ty... | 9,288 | 34.05283 | 93 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/audio/text_to_speech_dataset.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.abs
from pathlib import Path
from t... | 8,672 | 33.416667 | 87 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/audio/visual_feats_reader.py | # @Time : 2022/8/17
# @Author : Minglun Han
# @File : visual_feats_reader.py
import os
import sys
import random
import h5py
import cn2an
import string
import argparse
import logging
import numpy as np
import torch
class ImageFeaturesHdfReader(object):
"""
A reader for H5 files containing pre-extracted... | 2,163 | 27.103896 | 78 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/audio/frm_text_to_speech_dataset.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.abs
import csv
import logging
impor... | 6,923 | 32.61165 | 86 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/audio/__init__.py | 0 | 0 | 0 | py | |
CIF-HieraDist | CIF-HieraDist-main/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.
import logging
import random
import os
import sys
import io
import numpy as np
import torch
import torch.nn.functional as F
from .. import ... | 33,122 | 35.519294 | 111 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/audio/audio_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 pathlib import Path
from typing import BinaryIO, Optional, Tuple, Union, List
import mmap
import numpy as np
import torch
import torch.... | 10,247 | 33.738983 | 84 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/audio/speech_to_text_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 sys
import csv
import io
import logging
import re
import json
from collections import defaultdict
from pathlib import Path
from typing ... | 27,316 | 35.374168 | 88 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/audio/speech_to_text_joint_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 logging
from pathlib import Path
from typing import Dict, List, Optional, NamedTuple
import torch
from fairseq.data import (
Conca... | 9,676 | 32.484429 | 86 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/audio/feature_transforms/utterance_cmvn.py | import numpy as np
from fairseq.data.audio.feature_transforms import (
AudioFeatureTransform,
register_audio_feature_transform,
)
@register_audio_feature_transform("utterance_cmvn")
class UtteranceCMVN(AudioFeatureTransform):
"""Utterance-level CMVN (cepstral mean and variance normalization)"""
@clas... | 1,185 | 27.926829 | 75 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/audio/feature_transforms/specaugment.py | import math
import numbers
from typing import Optional
import numpy as np
from fairseq.data.audio.feature_transforms import (
AudioFeatureTransform,
register_audio_feature_transform,
)
@register_audio_feature_transform("specaugment")
class SpecAugmentTransform(AudioFeatureTransform):
"""SpecAugment (http... | 4,492 | 33.037879 | 87 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/audio/feature_transforms/__init__.py | import importlib
import os
from abc import ABC, abstractmethod
from typing import Dict, Optional
class AudioFeatureTransform(ABC):
@classmethod
@abstractmethod
def from_config_dict(cls, config: Optional[Dict] = None):
pass
AUDIO_FEATURE_TRANSFORM_REGISTRY = {}
AUDIO_FEATURE_TRANSFORM_CLASS_NAMES... | 2,611 | 30.46988 | 80 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/audio/feature_transforms/global_cmvn.py | import numpy as np
from fairseq.data.audio.feature_transforms import (
AudioFeatureTransform,
register_audio_feature_transform,
)
@register_audio_feature_transform("global_cmvn")
class GlobalCMVN(AudioFeatureTransform):
"""Global CMVN (cepstral mean and variance normalization). The global mean
and var... | 970 | 31.366667 | 84 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/encoders/bytes.py | # Copyright (c) Facebook, Inc. and 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
from fairseq.data.encoders.byte_utils import (
SPACE,
SPACE_ESCAPE,
byte_encode,
... | 837 | 22.942857 | 69 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/encoders/byte_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
WHITESPACE_NORMALIZER = re.compile(r"\s+")
SPACE = chr(32)
SPACE_ESCAPE = chr(9601)
# excluding non-breaking space (160) here
PRIN... | 1,643 | 30.615385 | 84 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/encoders/byte_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 dataclasses import dataclass, field
from fairseq import file_utils
from fairseq.data.encoders import register_bpe
from fairseq.data.enc... | 1,404 | 27.673469 | 78 | py |
CIF-HieraDist | CIF-HieraDist-main/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 dataclasses import dataclass, field
from fairseq import file_utils
from fairseq.data.encoders import register_bpe
from fairseq.dataclass... | 1,488 | 31.369565 | 86 | py |
CIF-HieraDist | CIF-HieraDist-main/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.data.encoders import register_tokenizer
from fairseq.dataclass import FairseqDataclass
@register_tokenizer("nltk", dataclass=Fa... | 755 | 29.24 | 75 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/encoders/hf_byte_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 dataclasses import dataclass, field
from fairseq.data.encoders import register_bpe
from fairseq.dataclass import FairseqDataclass
from f... | 1,710 | 32.54902 | 87 | py |
CIF-HieraDist | CIF-HieraDist-main/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 dataclasses import dataclass, field
from fairseq import file_utils
from fairseq.data.encoders import register_bpe
from fairseq.dataclass... | 1,157 | 30.297297 | 83 | py |
CIF-HieraDist | CIF-HieraDist-main/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 dataclasses import dataclass, field
from typing import Optional
from fairseq import file_utils
from fairseq.data.encoders import registe... | 2,334 | 34.378788 | 87 | py |
CIF-HieraDist | CIF-HieraDist-main/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 torch
from fairseq.data import encoders
def get_whole_word_mask(args, dictionary):
bpe = encoders.build_bpe(args)
if bpe is n... | 909 | 28.354839 | 67 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/encoders/gpt2_bpe_utils.py | """
Byte pair encoding utilities from GPT-2.
Original source: https://github.com/openai/gpt-2/blob/master/src/encoder.py
Original license: MIT
"""
import json
from functools import lru_cache
@lru_cache()
def bytes_to_unicode():
"""
Returns list of utf-8 byte and a corresponding list of unicode strings.
... | 4,590 | 31.560284 | 108 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/encoders/space_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.
import re
from fairseq.data.encoders import register_tokenizer
from fairseq.dataclass import FairseqDataclass
@register_tokenizer("space", ... | 590 | 25.863636 | 65 | py |
CIF-HieraDist | CIF-HieraDist-main/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.
from dataclasses import dataclass, field
from typing import Optional
from fairseq.data.encoders import register_bpe
from fairseq.dataclass im... | 1,642 | 31.215686 | 82 | py |
CIF-HieraDist | CIF-HieraDist-main/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.
from dataclasses import dataclass, field
from fairseq import file_utils
from fairseq.data.encoders import register_bpe
from fairseq.dataclass... | 1,791 | 31.581818 | 87 | py |
CIF-HieraDist | CIF-HieraDist-main/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.
import importlib
import os
from fairseq import registry
build_tokenizer, register_tokenizer, TOKENIZER_REGISTRY, _ = registry.setup_regist... | 761 | 24.4 | 85 | py |
CIF-HieraDist | CIF-HieraDist-main/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 dataclasses import dataclass, field
from fairseq.data.encoders import register_tokenizer
from fairseq.dataclass import FairseqDataclass
... | 1,660 | 32.22 | 85 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/encoders/characters.py | # Copyright (c) Facebook, Inc. and 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
SPACE = chr(32)
SPACE_ESCAPE = chr(9601)
@register_bpe("characters")
class Characters(obje... | 684 | 21.096774 | 65 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/huffman/huffman_coder.py | # Copyright (c) Facebook, Inc. and its 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
import typing as tp
from collections import Counter, deque
from dataclasses import dataclass
from bitarray import bitarray, util
fr... | 8,627 | 31.19403 | 111 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/huffman/huffman_mmap_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 mmap
import os
import shutil
import struct
import typing as tp
from functools import lru_cache
import numpy as np
import torch
from fa... | 8,809 | 29.590278 | 108 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/huffman/__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 .huffman_coder import HuffmanCodeBuilder, HuffmanCoder
from .huffman_mmap_indexed_dataset import (
HuffmanMMapIndex,
HuffmanMMapI... | 577 | 25.272727 | 65 | py |
CIF-HieraDist | CIF-HieraDist-main/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.
import math
import numpy as np
import torch
from fairseq.data import FairseqDataset
class BlockPairDataset(FairseqDataset):
"""Break a ... | 12,877 | 40.275641 | 99 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/data/legacy/masked_lm_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 math
from typing import Dict, List, Tuple
import numpy as np
import torch
from fairseq.data import Dictionary, FairseqDataset, data_ut... | 12,168 | 39.029605 | 88 | py |
CIF-HieraDist | CIF-HieraDist-main/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.
from fairseq.data import Dictionary
class MaskedLMDictionary(Dictionary):
"""
Dictionary for Masked Language Modelling tasks. This e... | 1,560 | 24.590164 | 79 | py |
CIF-HieraDist | CIF-HieraDist-main/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.
from .block_pair_dataset import BlockPairDataset
from .masked_lm_dataset import MaskedLMDataset
from .masked_lm_dictionary import BertDictiona... | 454 | 25.764706 | 68 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/tasks/text_to_speech.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
import os
import os.path as op
import torch
import torch.nn.functional as F
import numpy as np
from fairseq.data.audio.text_t... | 17,550 | 33.212476 | 88 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/tasks/multilingual_denoising.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
import os
import numpy as np
from fairseq.data import (
AppendTokenDataset,
ConcatDataset,
DenoisingDataset,
D... | 8,756 | 33.341176 | 91 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/tasks/translation_from_pretrained_bart.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
from fairseq import utils
from fairseq.data import LanguagePairDataset
from . import register_task
from .translation import Tran... | 5,243 | 38.428571 | 108 | py |
CIF-HieraDist | CIF-HieraDist-main/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 itertools
import logging
import os
import numpy as np
from fairseq import tokenizer, utils
from fairseq.data import ConcatDataset, Dic... | 5,010 | 31.751634 | 88 | py |
CIF-HieraDist | CIF-HieraDist-main/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 logging
import os
from dataclasses import dataclass, field
from typing import Optional
import numpy as np
import torch
from fairseq im... | 14,118 | 35.483204 | 129 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/tasks/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.
from dataclasses import dataclass, field
import logging
import os
from omegaconf import MISSING, II, OmegaConf
import numpy as np
from fairs... | 8,643 | 32.765625 | 87 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/tasks/translation.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from dataclasses import dataclass, field
import itertools
import json
import logging
import os
from typing import Optional
from argparse impor... | 17,888 | 34.921687 | 108 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/tasks/translation_from_pretrained_xlm.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from dataclasses import dataclass
from fairseq.data.legacy.masked_lm_dictionary import MaskedLMDictionary
from fairseq.tasks.translation impor... | 1,294 | 31.375 | 83 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/tasks/audio_pretraining.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
import logging
import os
import sy... | 7,741 | 36.582524 | 97 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/tasks/semisupervised_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 logging
import os
from collections import OrderedDict
from fairseq import utils
from fairseq.data import (
BacktranslationDataset,... | 20,375 | 40.925926 | 119 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/tasks/cross_lingual_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 itertools
import logging
import os
from collections import OrderedDict
import numpy as np
from fairseq import tokenizer, utils
from fa... | 6,454 | 32.619792 | 88 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/tasks/hubert_pretraining.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
import logging
import os
import sy... | 6,219 | 31.395833 | 88 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/tasks/multilingual_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 logging
import os
import numpy as np
import torch
from fairseq import utils
from fairseq.data import (
ConcatDataset,
Dictiona... | 12,144 | 34.825959 | 87 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/tasks/online_backtranslation.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import contextlib
import json
import logging
import math
import os
from argparse import Namespace
from collections import OrderedDict, default... | 28,578 | 40.843338 | 118 | py |
CIF-HieraDist | CIF-HieraDist-main/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.
import logging
import os
from fairseq import utils
from fairseq.data import (
AppendTokenDataset,
DenoisingDataset,
Dictionary,
... | 8,960 | 31.350181 | 88 | py |
CIF-HieraDist | CIF-HieraDist-main/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 contextlib
import logging
import os
from collections import OrderedDict
from argparse import ArgumentError
import torch
from fairseq i... | 18,125 | 38.149028 | 118 | py |
CIF-HieraDist | CIF-HieraDist-main/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.
from dataclasses import dataclass, field
import torch
from fairseq import utils
from fairseq.data import LanguagePairDataset
from fairseq.data... | 7,416 | 36.841837 | 103 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/tasks/simultaneous_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 logging
from fairseq.tasks import register_task
from fairseq.tasks.speech_to_text import SpeechToTextTask
from fairseq.tasks.translatio... | 1,226 | 28.214286 | 77 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/tasks/speech_text_pretraining.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
import logging
import random
impor... | 18,101 | 38.697368 | 97 | py |
CIF-HieraDist | CIF-HieraDist-main/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.
"""isort:skip_file"""
import argparse
import importlib
import os
from fairseq.dataclass import FairseqDataclass
from fairseq.dataclass.utils ... | 4,365 | 30.868613 | 153 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/tasks/frm_text_to_speech.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
from fairseq.data.audio.frm_text_to_speech_dataset import FrmTextToSpeechDatasetCreator
from fairseq.tasks import register_tas... | 2,093 | 36.392857 | 87 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/tasks/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 logging
import os
import contextlib
from dataclasses import dataclass, field
from typing import Optional
from omegaconf import MISSING... | 9,161 | 30.923345 | 123 | py |
CIF-HieraDist | CIF-HieraDist-main/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 logging
import os
import warnings
from argparse import Namespace
from typing import Any, Callable, Dict, List
import torch
from fairse... | 26,195 | 37.020319 | 110 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/tasks/speech_to_text.py | # Copyright (c) Facebook, Inc. and its 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 logging
from pathlib import Path
from argparse import Namespace
import torch
import torch.nn.functional as F
import numpy a... | 7,517 | 34.462264 | 85 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/tasks/audio_finetuning.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
import logging
import os
import to... | 13,463 | 38.139535 | 95 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/tasks/translation_multi_simple_epoch.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import datetime
import logging
import time
import torch
from fairseq.data import (
FairseqDataset,
LanguagePairDataset,
ListDatas... | 17,791 | 39.436364 | 113 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq/tasks/sentence_ranking.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
import os
import numpy as np
from fairseq import utils
from fairseq.data import (
ConcatSentencesDataset,
Dictionary,
... | 6,997 | 30.809091 | 86 | py |
CIF-HieraDist | CIF-HieraDist-main/docs/conf.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... | 4,270 | 30.637037 | 80 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq_cli/score.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... | 3,287 | 30.92233 | 88 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq_cli/generate.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 ast
import logging
import math
import os
import sy... | 16,216 | 36.978923 | 180 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq_cli/validate.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 logging
import os
import sys
from argparse import Namespace
from itertools import chain
import torch
from fa... | 5,228 | 32.954545 | 88 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq_cli/hydra_train.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 logging
import os
from fairseq.dataclass.initialize import add_defaults, hydra_init
from fairseq_cli.train i... | 2,715 | 28.204301 | 116 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq_cli/eval_lm.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 logging
import math
import os
import sys
from a... | 11,959 | 33.367816 | 108 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq_cli/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.
"""
Translate raw text with a trained model. Batches data on-the-fly.
"""
import ast
import fileinput
import logging... | 11,465 | 35.056604 | 88 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq_cli/__init__.py | 0 | 0 | 0 | py | |
CIF-HieraDist | CIF-HieraDist-main/fairseq_cli/train.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 argparse
import logging
import math
import random
i... | 19,207 | 33.860254 | 108 | py |
CIF-HieraDist | CIF-HieraDist-main/fairseq_cli/preprocess.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 logging
import os
import shutil
impo... | 14,806 | 34.93932 | 88 | py |
openai-eeng201-solution-generator | openai-eeng201-solution-generator-main/generate-solutions.py |
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# bu... | 2,983 | 29.762887 | 173 | py |
openai-eeng201-solution-generator | openai-eeng201-solution-generator-main/utils/convert-image-to-base64.py |
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# bu... | 1,166 | 36.645161 | 79 | py |
openai-eeng201-solution-generator | openai-eeng201-solution-generator-main/utils/generate-latex-pdf-from-json-solution-files.py |
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# bu... | 3,366 | 34.442105 | 128 | py |
SOLikeT | SOLikeT-master/setup.py | #!/usr/bin/env python
# Licensed under a 3-clause BSD style license - see LICENSE.rst
# NOTE: The configuration for the package, including the name, version, and
# other information are set in the setup.cfg file.
import os
import sys
from setuptools import setup
# First provide helpful messages if contributors try... | 1,340 | 30.928571 | 76 | py |
SOLikeT | SOLikeT-master/soliket/foreground.py | r"""
.. module:: foreground
The ``Foreground`` class initialized the foreground components and computes
the foreground spectra for each component and each channel. The information
on the arrays to use come from the ``TheoryForge`` class by default, through
the dictionary ``bands``. This is a dictionary
.. code-bloc... | 17,399 | 47.467967 | 89 | py |
SOLikeT | SOLikeT-master/soliket/ccl.py | """
.. module:: soliket.ccl
:Synopsis: A simple CCL wrapper for Cobaya.
:Author: Pablo Lemos.
.. |br| raw:: html
<br />
The `Core Cosmology Library (CCL) <https://ccl.readthedocs.io/en/latest/>`_ is a
standardized library of routines to calculate basic observables used in cosmology.
It will be the standard ana... | 9,551 | 41.265487 | 114 | py |
SOLikeT | SOLikeT-master/soliket/constants.py | from scipy import constants
C_M_S = constants.c
C_KM_S = constants.c * 1.e-3
C_HMPC = constants.c * 1.e-5
h_Planck = constants.h
k_Boltzmann = constants.k
elementary_charge = constants.e
electron_mass_kg = constants.m_e
T_CMB = 2.72548 #in K
MSUN_CGS = 1.98840987e+33
G_CGS = constants.G * 1e3
MPC2CM = constants.parsec... | 387 | 21.823529 | 32 | py |
SOLikeT | SOLikeT-master/soliket/ps.py | import numpy as np
from . import utils
from .gaussian import GaussianLikelihood
class PSLikelihood(GaussianLikelihood):
name: str = "TT"
kind: str = "tt"
lmax: int = 6000
def get_requirements(self):
return {"Cl": {self.kind: self.lmax}}
def _get_Cl(self):
return self.theory.get_... | 1,202 | 25.733333 | 88 | py |
SOLikeT | SOLikeT-master/soliket/cash.py | import numpy as np
from typing import Optional
from cobaya.likelihood import Likelihood
from .cash_data import CashCData
class CashCLikelihood(Likelihood):
name: str = "Cash-C"
datapath = Optional[str]
def initialize(self):
x, N = self._get_data()
self.data = CashCData(self.name, N)
... | 728 | 24.137931 | 73 | py |
SOLikeT | SOLikeT-master/soliket/cross_correlation.py | """
Simple likelihood for CMB-galaxy cross-correlations using the cobaya
CCL module.
First version by Pablo Lemos
"""
import numpy as np
from .gaussian import GaussianData, GaussianLikelihood
import pyccl as ccl
from cobaya.log import LoggedError
import sacc
class CrossCorrelationLikelihood(GaussianLikelihood):
... | 9,123 | 37.49789 | 88 | py |
SOLikeT | SOLikeT-master/soliket/cash_data.py | import numpy as np
from scipy.special import factorial
import math as m
def cash_c_logpdf(theory, data, usestirling=True):
data = np.asarray(data, dtype=int)
ln_fac = np.zeros_like(data, dtype=float)
if usestirling: # use Stirling's approximation for N > 10
ln_fac[data > 10] = 0.918939 + (data[... | 1,051 | 25.3 | 79 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.