repo
stringlengths
1
99
file
stringlengths
13
215
code
stringlengths
12
59.2M
file_length
int64
12
59.2M
avg_line_length
float64
3.82
1.48M
max_line_length
int64
12
2.51M
extension_type
stringclasses
1 value
DMF
DMF-main/fairseq/fairseq/benchmark/dummy_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 from dataclasses import dataclass, field from typing import Optional import torch from omegaconf import II from .dummy_datase...
3,123
31.884211
84
py
DMF
DMF-main/fairseq/fairseq/benchmark/dummy_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 from dataclasses import dataclass, field from typing import Optional import torch from .dummy_dataset import DummyDataset from...
2,757
31.833333
84
py
DMF
DMF-main/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 logging import numpy as np import torch from fairseq.data import FairseqDataset, data_utils logger = logging.getLogger(__name__) d...
19,102
38.964435
90
py
DMF
DMF-main/fairseq/fairseq/data/transform_eos_concat_langpair_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 torch from torch.utils.data.dataloader import default_collate from fairseq.data import ConcatDataset logger = logging...
5,170
35.935714
111
py
DMF
DMF-main/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. import numpy as np import torch from fairseq.data import FairseqDataset, plasma_utils from fairseq.data.indexed_dataset import best_fitting_in...
7,652
35.971014
87
py
DMF
DMF-main/fairseq/fairseq/data/subsample_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 from . import BaseWrapperDataset logger = logging.getLogger(__name__) class SubsampleDataset(BaseWrapp...
2,117
28.013699
101
py
DMF
DMF-main/fairseq/fairseq/data/prepend_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 PrependDataset(BaseWrapperDataset): def __init__(self, dataset, ...
953
31.896552
83
py
DMF
DMF-main/fairseq/fairseq/data/base_wrapper_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 torch.utils.data.dataloader import default_collate from . import FairseqDataset class BaseWrapperDataset(FairseqDataset): def __in...
2,153
26.265823
70
py
DMF
DMF-main/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. import torch from . import FairseqDataset class RawLabelDataset(FairseqDataset): def __init__(self, labels): super().__init__()...
546
21.791667
65
py
DMF
DMF-main/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 logging import numpy as np from fairseq.data import BaseWrapperDataset, plasma_utils logger = logging.getLogger(__name__) class Re...
4,314
29.821429
78
py
DMF
DMF-main/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 os from collections import Counter from multiprocessing import Pool import torch from fairseq import utils from fairseq.data import da...
12,903
31.099502
96
py
DMF
DMF-main/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. import numpy as np import torch from . import BaseWrapperDataset class AppendTokenDataset(BaseWrapperDataset): def __init__(self, datas...
1,065
24.380952
65
py
DMF
DMF-main/fairseq/fairseq/data/codedataset.py
# Copyright (c) Facebook, Inc. and its 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 logging import os import random from pathlib import Path import numpy as np import torch import torch.utils.data from . ...
18,486
31.039861
109
py
DMF
DMF-main/fairseq/fairseq/data/fasta_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 os import subprocess import threading from pathlib import Path import numpy as np import torch def fasta_file_path(prefix_path): ...
3,387
30.37037
107
py
DMF
DMF-main/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 import numpy as np import torch from fairseq.data import Dictionary, data_utils from . import BaseWrapperDat...
8,777
38.719457
102
py
DMF
DMF-main/fairseq/fairseq/data/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 bisect import numpy as np from torch.utils.data.dataloader import default_collate from . import FairseqDataset class ConcatDataset(...
4,645
36.168
86
py
DMF
DMF-main/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. try: from collections.abc import Iterable except ImportError: from collections import Iterable import contextlib import itertools impo...
21,791
35.019835
120
py
DMF
DMF-main/fairseq/fairseq/data/nested_dictionary_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 torch from torch.utils.data.dataloader import default_collate from . import FairseqDataset def ...
4,029
30.984127
86
py
DMF
DMF-main/fairseq/fairseq/data/add_target_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, data_utils from fairseq.data.text_compressor import TextCompressor, TextCompressionLevel cla...
2,996
34.678571
88
py
DMF
DMF-main/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 typing import Optional import torch from . import FairseqDataset class TransformEosLangPairDataset(FairseqDataset): """A :class:...
3,856
32.833333
98
py
DMF
DMF-main/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 typing import Dict from fairseq.data.monolingual_dataset import MonolingualDataset from . import Fairse...
3,381
33.510204
90
py
DMF
DMF-main/fairseq/fairseq/data/span_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. import numpy as np import torch from . import Dictionary, FairseqDataset, data_utils def collate( samples, pad_idx, eos_idx, ...
10,888
36.037415
206
py
DMF
DMF-main/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 BaseWrapperDataset class ColorizeDataset(BaseWrapperDataset): """Adds 'colors' property to net input that is...
843
31.461538
111
py
DMF
DMF-main/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 itertools import logging import math import operator import os import queue import time from threading import Thread from typing import...
31,799
34.972851
94
py
DMF
DMF-main/fairseq/fairseq/data/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 torch from fairseq import utils from . import FairseqDataset def backtranslate_samples(samples, collate_fn, generate_fn, cuda=True):...
6,247
36.638554
84
py
DMF
DMF-main/fairseq/fairseq/data/monolingual_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 FairseqDataset, data_utils def collate(samples, pad_idx, eos_idx, fixed_pad_length=None, pad_...
8,832
33.775591
110
py
DMF
DMF-main/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. import torch from . import BaseWrapperDataset class RollDataset(BaseWrapperDataset): def __init__(self, dataset, shifts): super...
485
24.578947
65
py
DMF
DMF-main/fairseq/fairseq/data/replace_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 ReplaceDataset(BaseWrapperDataset): """Replaces tokens found in the dataset by a specified replac...
1,370
36.054054
113
py
DMF
DMF-main/fairseq/fairseq/data/id_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 IdDataset(FairseqDataset): def __getitem__(self, index): return index def ...
423
20.2
65
py
DMF
DMF-main/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 shutil import struct from functools import lru_cache import numpy as np import torch from fairseq.dataclass.constants import DATASET_I...
18,265
30.064626
102
py
DMF
DMF-main/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. import math import numpy as np import torch from . import FairseqDataset, data_utils def collate( samples, pad_idx, eos_idx, ...
15,685
34.328829
88
py
DMF
DMF-main/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 numpy as np import torch from . import BaseWrapperDataset class PrependTokenDataset(BaseWrapperDataset): def __init__(self, data...
1,066
24.404762
65
py
DMF
DMF-main/fairseq/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
DMF
DMF-main/fairseq/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
DMF
DMF-main/fairseq/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
DMF
DMF-main/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. import torch from . import FairseqDataset class ConcatSentencesDataset(FairseqDataset): def __init__(self, *datasets): super()....
1,558
27.345455
83
py
DMF
DMF-main/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 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
DMF
DMF-main/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 FairseqDataset class TransformEosDataset(FairseqDataset): """A :class:`~fairseq.data.FairseqDataset` wrapper...
4,575
36.818182
88
py
DMF
DMF-main/fairseq/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,339
38.104478
119
py
DMF
DMF-main/fairseq/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
DMF
DMF-main/fairseq/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 impor...
7,823
38.12
119
py
DMF
DMF-main/fairseq/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,719
34.630252
86
py
DMF
DMF-main/fairseq/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...
10,161
34.65614
93
py
DMF
DMF-main/fairseq/fairseq/data/audio/speech_to_speech_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 dataclasses import dataclass from pathlib import Path from typing import Dict, List, Optional, Tuple import torch from f...
13,850
35.45
99
py
DMF
DMF-main/fairseq/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 dataclasses import datacla...
8,669
33.541833
87
py
DMF
DMF-main/fairseq/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
DMF
DMF-main/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. import logging import os import sys import io import numpy as np import torch import torch.nn.functional as F from .. import FairseqDataset...
13,679
33.720812
111
py
DMF
DMF-main/fairseq/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. import mmap from pathlib import Path import io from typing import BinaryIO, List, Optional, Tuple, Union import numpy as np import torch imp...
13,330
33.182051
84
py
DMF
DMF-main/fairseq/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 csv import logging import re from argparse import Namespace from collections import defaultdict from dataclasses import dataclass from ...
26,935
35.697548
87
py
DMF
DMF-main/fairseq/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, NamedTuple, Optional import torch from fairseq.data import ConcatData...
12,746
34.408333
86
py
DMF
DMF-main/fairseq/fairseq/data/audio/dataset_transforms/noisyoverlapaugment.py
import numpy as np import torch from fairseq.data.audio import rand_uniform from fairseq.data.audio.dataset_transforms import ( AudioDatasetTransform, register_audio_dataset_transform, ) from fairseq.data.audio.waveform_transforms.noiseaugment import ( NoiseAugmentTransform, ) _DEFAULTS = { "rate": 0....
3,743
34.320755
86
py
DMF
DMF-main/fairseq/fairseq/data/audio/feature_transforms/delta_deltas.py
import numpy as np import torch from fairseq.data.audio.feature_transforms import ( AudioFeatureTransform, register_audio_feature_transform, ) @register_audio_feature_transform("delta_deltas") class DeltaDeltas(AudioFeatureTransform): """Expand delta-deltas features from spectrum.""" @classmethod ...
1,192
30.394737
79
py
DMF
DMF-main/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 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
DMF
DMF-main/fairseq/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,807
29.583333
108
py
DMF
DMF-main/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. import math import numpy as np import torch from fairseq.data import FairseqDataset class BlockPairDataset(FairseqDataset): """Break a ...
12,877
40.275641
99
py
DMF
DMF-main/fairseq/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
DMF
DMF-main/fairseq/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,256
33.376494
88
py
DMF
DMF-main/fairseq/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
DMF
DMF-main/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 logging import os from dataclasses import dataclass, field from typing import Optional import numpy as np import torch from fairseq im...
13,952
35.335938
91
py
DMF
DMF-main/fairseq/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,938
35.022088
108
py
DMF
DMF-main/fairseq/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, Diction...
12,144
34.825959
87
py
DMF
DMF-main/fairseq/fairseq/tasks/multilingual_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 omegaconf ...
22,960
35.562102
102
py
DMF
DMF-main/fairseq/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,618
40.901903
118
py
DMF
DMF-main/fairseq/fairseq/tasks/speech_ulm_task.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 sys import t...
7,533
32.484444
88
py
DMF
DMF-main/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 contextlib import logging import os from collections import OrderedDict from argparse import ArgumentError import torch from fairseq i...
18,165
38.235421
118
py
DMF
DMF-main/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. 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
DMF
DMF-main/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 logging import os import warnings from argparse import Namespace from typing import Any, Callable, Dict, List import torch from fairse...
26,655
37.409222
110
py
DMF
DMF-main/fairseq/fairseq/tasks/speech_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 json import logging import math from argparse import Namespace from pathlib import Path from typing import List import torch import to...
22,609
36.809365
130
py
DMF
DMF-main/fairseq/fairseq/tasks/nlu_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...
19,006
38.763598
95
py
DMF
DMF-main/fairseq/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,503
38.255814
95
py
DMF
DMF-main/fairseq/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,926
39.558824
113
py
DMF
DMF-main/fairseq/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...
3,133
30.656566
79
py
DMF
DMF-main/fairseq/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...
15,805
36.813397
180
py
DMF
DMF-main/fairseq/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 om...
5,228
32.954545
88
py
DMF
DMF-main/fairseq/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 import hydra import torch from hydra.core.hydra_config import HydraConfig from omegaconf i...
2,714
28.51087
116
py
DMF
DMF-main/fairseq/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,960
33.37069
108
py
DMF
DMF-main/fairseq/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
DMF
DMF-main/fairseq/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 os impor...
19,932
34.279646
108
py
DMF
DMF-main/loss/metric_learning.py
import torch import torch.nn as nn import torch.nn.functional as F import torch.autograd from torch.nn import Parameter import math class ContrastiveLoss(nn.Module): def __init__(self, margin=0.3, **kwargs): super(ContrastiveLoss, self).__init__() self.margin = margin def forward(self, inputs...
7,001
36.047619
121
py
DMF
DMF-main/loss/softmax_loss.py
import torch import torch.nn as nn from torch.nn import functional as F class CrossEntropyLabelSmooth(nn.Module): """Cross entropy loss with label smoothing regularizer. Reference: Szegedy et al. Rethinking the Inception Architecture for Computer Vision. CVPR 2016. Equation: y = (1 - epsilon) * y + eps...
2,037
35.392857
95
py
DMF
DMF-main/loss/triplet_loss.py
import torch from torch import nn def normalize(x, axis=-1): """Normalizing to unit length along the specified dimension. Args: x: pytorch Variable Returns: x: pytorch Variable, same shape as input """ x = 1. * x / (torch.norm(x, 2, axis, keepdim=True).expand_as(x) + 1e-12) return ...
4,748
33.413043
82
py
DMF
DMF-main/loss/arcface.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import Parameter import math class ArcFace(nn.Module): def __init__(self, in_features, out_features, s=30.0, m=0.50, bias=False): super(ArcFace, self).__init__() self.in_features = in_features self.out_feature...
2,975
36.2
105
py
DMF
DMF-main/loss/center_loss.py
from __future__ import absolute_import import torch from torch import nn class CenterLoss(nn.Module): """Center loss. Reference: Wen et al. A Discriminative Feature Learning Approach for Deep Face Recognition. ECCV 2016. Args: num_classes (int): number of classes. feat_dim (int): fe...
2,335
33.352941
110
py
DMF
DMF-main/loss/make_loss.py
# encoding: utf-8 """ @author: liaoxingyu @contact: sherlockliao01@gmail.com """ import torch import torch.nn.functional as F from .softmax_loss import CrossEntropyLabelSmooth, LabelSmoothingCrossEntropy from .triplet_loss import TripletLoss from .center_loss import CenterLoss def make_loss(cfg, num_classes): # m...
3,924
44.114943
119
py
DMF
DMF-main/utils/reranking.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri, 25 May 2018 20:29:09 """ """ CVPR2017 paper:Zhong Z, Zheng L, Cao D, et al. Re-ranking Person Re-identification with k-reciprocal Encoding[J]. 2017. url:http://openaccess.thecvf.com/content_cvpr_2017/papers/Zhong_Re-Ranking_Person_Re-Identification_C...
4,397
42.117647
119
py
DMF
DMF-main/utils/metrics.py
import torch import numpy as np import os from utils.reranking import re_ranking def euclidean_distance(qf, gf): m = qf.shape[0] n = gf.shape[0] dist_mat = torch.pow(qf, 2).sum(dim=1, keepdim=True).expand(m, n) + \ torch.pow(gf, 2).sum(dim=1, keepdim=True).expand(n, m).t() dist_mat.addm...
4,677
33.145985
112
py
DMF
DMF-main/model/make_model.py
import torch import torch.nn as nn from .backbones.resnet import ResNet, Bottleneck import copy from .backbones.vit_pytorch import vit_base_patch16_224_TransReID, vit_small_patch16_224_TransReID, deit_small_patch16_224_TransReID, vit_base_patch16_224_Transcross from loss.metric_learning import Arcface, Cosface, AMSoftm...
23,022
44.320866
249
py
DMF
DMF-main/model/backbones/vit_pytorch.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 ...
35,948
42.416667
132
py
DMF
DMF-main/model/backbones/resnet.py
import math import torch from torch import nn def conv3x3(in_planes, out_planes, stride=1): """3x3 convolution with padding""" return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride, padding=1, bias=False) class BasicBlock(nn.Module): expansion = 1 def __init__(s...
4,463
30.659574
81
py
WoBERT
WoBERT-master/train.py
#! -*- coding: utf-8 -*- # 词级别的中文BERT预训练 # MLM任务 import os, json import numpy as np from bert4keras.backend import keras, K from bert4keras.layers import Loss from bert4keras.models import build_transformer_model from bert4keras.tokenizers import Tokenizer, load_vocab from bert4keras.optimizers import Adam from bert4k...
5,847
28.989744
89
py
WoBERT
WoBERT-master/test/tnews.py
#! -*- coding:utf-8 -*- # tnews文本分类例子 import os, json import numpy as np from bert4keras.backend import keras, set_gelu from bert4keras.tokenizers import Tokenizer from bert4keras.models import build_transformer_model from bert4keras.optimizers import Adam from bert4keras.snippets import sequence_padding, DataGenerato...
4,430
27.587097
114
py
WoBERT
WoBERT-master/test/csl.py
#! -*- coding: utf-8 -*- # WoBERT做Seq2Seq任务,采用UniLM方案 # 介绍链接:https://kexue.fm/archives/6933 # 数据集:https://github.com/CLUEbenchmark/CLGE 中的CSL数据集 # 补充了评测指标bleu、rouge-1、rouge-2、rouge-l from __future__ import print_function import json import numpy as np from tqdm import tqdm from bert4keras.backend import keras, K from ...
5,709
31.078652
80
py
WoBERT
WoBERT-master/test/iflytek.py
#! -*- coding:utf-8 -*- # iflytek文本分类例子 import os, json import numpy as np from bert4keras.backend import keras, set_gelu from bert4keras.tokenizers import Tokenizer from bert4keras.models import build_transformer_model from bert4keras.optimizers import Adam from bert4keras.snippets import sequence_padding, DataGenera...
4,305
26.961039
80
py
WoBERT
WoBERT-master/test/sentiment.py
#! -*- coding:utf-8 -*- # 情感分析例子 import os, json import numpy as np from bert4keras.backend import keras, set_gelu from bert4keras.tokenizers import Tokenizer from bert4keras.models import build_transformer_model from bert4keras.optimizers import Adam from bert4keras.snippets import sequence_padding, DataGenerator fro...
3,971
27.782609
80
py
WoBERT
WoBERT-master/test/lcsts.py
#! -*- coding: utf-8 -*- # WoBERT做Seq2Seq任务,采用UniLM方案 # 介绍链接:https://kexue.fm/archives/6933 # 数据集:https://github.com/CLUEbenchmark/CLGE 中的LCSTS数据集 # 补充了评测指标bleu、rouge-1、rouge-2、rouge-l from __future__ import print_function import json import numpy as np from tqdm import tqdm from bert4keras.backend import keras, K fro...
5,721
31.146067
80
py
quantum_package
quantum_package-master/doc/source/conf.py
# -*- coding: utf-8 -*- # # Selected CI documentation build configuration file, created by # sphinx-quickstart on Mon Feb 10 15:53:11 2014. # # 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 # autogenerated file. # #...
9,145
30.979021
121
py
fastonn
fastonn-master/setup.py
from setuptools import setup,find_packages # read the contents of your README file from os import path this_directory = path.abspath(path.dirname(__file__)) with open(path.join(this_directory, 'README.md'), encoding='utf-8') as f: long_description = f.read() setup(name='fastonn', version='0.1.1', desc...
1,195
35.242424
83
py
fastonn
fastonn-master/tests/fastonn_test.py
from fastonn import OpNetwork,utils,OpTier,OpBlock,Trainer,SelfONN from fastonn.osl import * import numpy as np import torch def test_configure_oplib(): nodal = [mul] pool = [summ] act = [tanh] try: OPLIB = getOPLIB(nodal,pool,act) except: raise def test_OpNetwork(): try: ...
3,350
38.892857
159
py
fastonn
fastonn-master/fastonn/OpBlock.py
from .utils import * from .osl import * from torch import nn from torch.nn.parameter import Parameter from torch.nn import init import math import numpy as np from tqdm import tqdm class OpBlock(nn.Module): # Initialize block def __init__(self,in_channels,out_channels,kernel_size,op_idx,OPLIB): super...
1,961
29.65625
96
py
fastonn
fastonn-master/fastonn/SelfONN.py
from collections.abc import Iterable from itertools import repeat import math from typing import Optional, Tuple, Union import torch from torch import Tensor, cat, no_grad from torch import nn from torch.nn import Module, Parameter import torch.nn.functional as F from torch.nn.init import _calculate_fan_in_and_fan_out...
13,944
36.386059
120
py