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 |
|---|---|---|---|---|---|---|
ELLE | ELLE-main/fairseq-0.9.0/fairseq/modules/beamable_mm.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
class BeamableMM(nn.Module):
"""This module provides an optimized MM for beam decoding with attention... | 1,779 | 36.083333 | 80 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/modules/layer_norm.py | # Copyright (c) Facebook, Inc. and 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 LayerNorm(normalized_shape, eps=1e-5, elementwise_affine=True, export=False):
if not export and torch.cuda.is_available... | 590 | 33.764706 | 81 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/modules/scalar_bias.py | # Copyright (c) Facebook, Inc. and 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
class ScalarBias(torch.autograd.Function):
"""
Adds a vector of scalars, used in self-attention mechanism to allow
... | 888 | 26.78125 | 74 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/modules/transformer_sentence_encoder.py | # Copyright (c) Facebook, Inc. and 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, Tuple
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq.modules import (
Layer... | 8,732 | 34.21371 | 88 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/modules/grad_multiply.py | # Copyright (c) Facebook, Inc. and 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
class GradMultiply(torch.autograd.Function):
@staticmethod
def forward(ctx, x, scale):
ctx.scale = scale
... | 442 | 22.315789 | 65 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/modules/sparse_transformer_sentence_encoder.py | # Copyright (c) Facebook, Inc. and 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.nn as nn
from fairseq.modules import TransformerSentenceEncoder
from fairseq.modules.sparse_transformer_sentence_encoder_layer im... | 3,164 | 36.678571 | 107 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/modules/sinusoidal_positional_embedding.py | # Copyright (c) Facebook, Inc. and 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.onnx.operators
from fairseq import utils
class SinusoidalPositionalEmbedding(n... | 3,539 | 40.162791 | 116 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/modules/lightweight_convolution.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq import utils
from fairseq.modules.unfold import unfold1d
de... | 10,290 | 39.356863 | 103 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/modules/dynamic_convolution.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq import utils
from .unfold import unfold1d
def DynamicConv(i... | 10,910 | 43.901235 | 132 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/modules/dynamicconv_layer/setup.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 setuptools import setup
from torch.utils.cpp_extension import CUDAExtension, BuildExtension
setup(
name='dyna... | 613 | 24.583333 | 67 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/modules/dynamicconv_layer/dynamicconv_layer.py | # Copyright (c) Facebook, Inc. and 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 torch import nn
from torch.autograd import Function
import torch.nn.functional as F
import dynamicconv_cuda
from fairseq im... | 8,605 | 39.403756 | 129 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/modules/lightconv_layer/setup.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 setuptools import setup
from torch.utils.cpp_extension import CUDAExtension, BuildExtension
setup(
name='ligh... | 545 | 25 | 67 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/modules/lightconv_layer/lightconv_layer.py | # Copyright (c) Facebook, Inc. and 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 torch import nn
from torch.autograd import Function
import torch.nn.functional as F
import lightconv_cuda
from fairseq impo... | 4,235 | 34.3 | 98 | py |
ELLE | ELLE-main/fairseq-0.9.0/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.
from torch.nn.modules.loss import _Loss
class FairseqCriterion(_Loss):
def __init__(self, args, task):
super().__init__()
... | 1,359 | 29.222222 | 103 | py |
ELLE | ELLE-main/fairseq-0.9.0/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 math
import torch.nn.functional as F
from fairseq import utils
import torch
from torch import Tensor
from . import FairseqCriterion, ... | 6,035 | 34.298246 | 88 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/criterions/continual_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... | 2,685 | 38.5 | 109 | py |
ELLE | ELLE-main/fairseq-0.9.0/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
import torch.nn.functional as F
from fairseq import utils
from . import FairseqCriterion, register_criterion
def ... | 6,360 | 41.97973 | 100 | py |
ELLE | ELLE-main/fairseq-0.9.0/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.nn.functional as F
from fairseq import utils
from . import FairseqCriterion, register_criterion
@register_criteri... | 3,600 | 37.72043 | 105 | py |
ELLE | ELLE-main/fairseq-0.9.0/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... | 2,837 | 33.609756 | 130 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/criterions/continual_KI.py | # Copyright (c) Facebook, Inc. and 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... | 6,465 | 37.951807 | 143 | py |
ELLE | ELLE-main/fairseq-0.9.0/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... | 2,607 | 37.352941 | 95 | py |
ELLE | ELLE-main/fairseq-0.9.0/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
import torch
import torch.nn.functional as F
from fairseq import utils
from . import FairseqCriterion, register_criterion
@re... | 3,341 | 33.453608 | 97 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/criterions/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 math
import torch
import torch.nn.functional as F
from fairseq import utils
from . import FairseqCriterion, register_criterion
@re... | 3,874 | 34.227273 | 87 | py |
ELLE | ELLE-main/fairseq-0.9.0/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.
from torch import nn
from fairseq import utils
from . import FairseqCriterion, register_criterion
@register_criterion('composite_loss')
cla... | 3,386 | 35.815217 | 96 | py |
ELLE | ELLE-main/fairseq-0.9.0/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
@reg... | 2,468 | 33.291667 | 82 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/models/levenshtein_transformer.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq.iterative_refinement_generator import DecoderOut
from fairseq... | 27,687 | 36.670748 | 120 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/models/wav2vec.py | # Copyright (c) Facebook, Inc. and 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 math
import torch
import torch.nn as nn
import torch.nn.functional as F
from . import (
BaseFairseqModel, register_mo... | 18,421 | 37.864979 | 119 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/models/lstm.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq import options, utils
from fairseq.models import (
Fairse... | 24,690 | 42.700885 | 105 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/models/nonautoregressive_ensembles.py | # Copyright (c) Facebook, Inc. and 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.models.levenshtein_transformer import (
_fill,
_skip,
_ski... | 9,040 | 37.969828 | 120 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/models/pnn_gpt.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
RoBERTa: A Robustly Optimized BERT Pretraining Approach.
"""
import torch
import torch.nn as nn
import torch.nn.functional as F
from fair... | 12,264 | 49.892116 | 205 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/models/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 torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq import utils
from fairseq.models import (
BaseFairseqMode... | 15,476 | 42.231844 | 100 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/models/model_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 typing import List, Optional
import torch
from torch import Tensor
@torch.jit.script
def script_skip_tensor_list(x: List[Tensor], mask... | 2,335 | 24.67033 | 103 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/models/insertion_transformer.py | # Copyright (c) Facebook, Inc. and 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 torch.nn.functional as F
from fairseq.models import register_model, register_model_architecture
from f... | 10,516 | 36.560714 | 88 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/models/fairseq_encoder.py | # Copyright (c) Facebook, Inc. and 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.nn as nn
class FairseqEncoder(nn.Module):
"""Base class for encoders."""
def __init__(self, dictionary):
super... | 1,396 | 29.369565 | 78 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/models/fconv.py | # Copyright (c) Facebook, Inc. and 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 import utils
from fairseq.models import (
Fai... | 27,654 | 40.399701 | 127 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/models/lightconv.py | # Copyright (c) Facebook, Inc. and 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 import options, utils
from fairseq.models import... | 34,158 | 44.00527 | 125 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/models/nonautoregressive_transformer.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn.functional as F
from fairseq import utils
from fairseq.iterative_refinement_generator import DecoderOut
from fai... | 15,538 | 35.997619 | 108 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/models/transformer.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from collections import namedtuple
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq import option... | 39,778 | 43.346711 | 159 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/models/fconv_self_att.py | # Copyright (c) Facebook, Inc. and 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 os
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq import checkpoint_utils
from fairseq.m... | 24,122 | 40.591379 | 111 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/models/fairseq_decoder.py | # Copyright (c) Facebook, Inc. and 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.nn as nn
from fairseq import utils
class FairseqDecoder(nn.Module):
"""Base class for decoders."""
def __init__(self,... | 2,829 | 33.512195 | 95 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/models/pnn_roberta.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
RoBERTa: A Robustly Optimized BERT Pretraining Approach.
"""
import torch
import torch.nn as nn
import torch.nn.functional as F
from fair... | 7,672 | 43.871345 | 209 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/models/fairseq_model.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Base classes for various fairseq models.
"""
from typing import Dict, List, Optional
import torch
import torch.nn as nn
import torch.nn.f... | 16,053 | 34.995516 | 110 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/models/iterative_nonautoregressive_transformer.py | # Copyright (c) Facebook, Inc. and 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.models import register_model, register_model_architecture
from fairseq.models.nonautoregressive_transformer import ... | 8,248 | 40.039801 | 99 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/models/distributed_fairseq_model.py | # Copyright (c) Facebook, Inc. and 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 inspect
import torch.nn as nn
from fairseq.legacy_distributed_data_parallel import LegacyDistributedDataParallel
from fairseq.models ... | 2,426 | 35.223881 | 82 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/models/bart/hub_interface.py | # Copyright (c) Facebook, Inc. and 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 copy
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from typing import List
from fairseq impor... | 6,872 | 36.763736 | 129 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/models/bart/model.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
BART: Denoising Sequence-to-Sequence Pre-training for
Natural Language Generation, Translation, and Comprehension
"""
import torch.nn as n... | 10,444 | 41.287449 | 121 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/models/roberta/hub_interface.py | # Copyright (c) Facebook, Inc. and 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 torch.nn as nn
import torch.nn.functional as F
from fairseq import utils
from fairseq.data import enco... | 8,416 | 40.058537 | 114 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/models/roberta/model.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
RoBERTa: A Robustly Optimized BERT Pretraining Approach.
"""
import torch
import torch.nn as nn
import torch.nn.functional as F
from fair... | 26,864 | 44.76661 | 144 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/models/roberta/alignment_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 collections import Counter
from typing import List
import torch
def align_bpe_to_words(roberta, bpe_tokens: torch.LongTensor, other_to... | 4,074 | 34.12931 | 98 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/optim/bmuf.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.distributed as dist
from . import FairseqOptimizer
class FairseqBMUF(FairseqOptimizer):
"""
Implements in... | 8,016 | 34.631111 | 90 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/optim/nag.py | # Copyright (c) Facebook, Inc. and 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 torch.optim.optimizer import Optimizer, required
from . import FairseqOptimizer, register_optimizer
@register_optimizer('... | 3,210 | 32.103093 | 96 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/optim/sgd.py | # Copyright (c) Facebook, Inc. and 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.optim
from . import FairseqOptimizer, register_optimizer
@register_optimizer('sgd')
class SGD(FairseqOptimizer):
def __ini... | 1,359 | 33 | 92 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/optim/adamax.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.optim
from . import FairseqOptimizer, register_optimizer
@register_optimizer('adamax')
class FairseqAdamax(Fairse... | 5,819 | 37.289474 | 92 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/optim/fp16_optimizer.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from itertools import chain
import torch
from fairseq import optim, utils
class DynamicLossScaler(object):
def __init__(
self... | 14,764 | 36.379747 | 97 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/optim/adam.py | # Copyright (c) Facebook, Inc. and 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 types
import torch
import torch.optim
import torch.distributed as dist
from . import FairseqOptimizer, register_optimizer... | 13,968 | 41.458967 | 139 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/optim/adafactor.py | # Copyright (c) Facebook, Inc. and 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.optim
from . import FairseqOptimizer, register_optimizer
@register_optimizer('adafactor')
class Fairs... | 9,545 | 43.607477 | 110 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/optim/adagrad.py | # Copyright (c) Facebook, Inc. and 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.optim
from . import FairseqOptimizer, register_optimizer
@register_optimizer('adagrad')
class Adagrad(FairseqOptimizer):
d... | 1,195 | 31.324324 | 92 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/optim/fairseq_optimizer.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import math
import torch
class FairseqOptimizer(object):
def __init__(self, args):
super().__init__()
self.args = args... | 3,751 | 31.912281 | 99 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/optim/adadelta.py | # Copyright (c) Facebook, Inc. and 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.optim
from . import FairseqOptimizer, register_optimizer
@register_optimizer('adadelta')
class Adadelta(FairseqOptimizer):
... | 1,752 | 38.840909 | 105 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/optim/lr_scheduler/inverse_square_root_schedule.py | # Copyright (c) Facebook, Inc. and 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 FairseqLRScheduler, register_lr_scheduler
@register_lr_scheduler('inverse_sqrt')
class InverseSquareRootSchedule(FairseqLRSche... | 2,952 | 38.905405 | 97 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/optim/lr_scheduler/tri_stage_lr_scheduler.py | # Copyright (c) Facebook, Inc. and 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 FairseqLRScheduler, register_lr_scheduler
import math
@register_lr_scheduler('tri_stage')
class TriStageLRSchedule(FairseqLRSc... | 4,993 | 30.018634 | 84 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/optim/lr_scheduler/reduce_lr_on_plateau.py | # Copyright (c) Facebook, Inc. and 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.optim.lr_scheduler
from . import FairseqLRScheduler, register_lr_scheduler
@register_lr_scheduler('reduce_lr_on_plateau')
clas... | 4,411 | 43.565657 | 109 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/optim/lr_scheduler/cosine_lr_scheduler.py | # Copyright (c) Facebook, Inc. and 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 . import FairseqLRScheduler, register_lr_scheduler
@register_lr_scheduler('cosine')
class CosineSchedule(FairseqLRSchedule... | 4,752 | 38.941176 | 105 | py |
ELLE | ELLE-main/fairseq-0.9.0/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 data_utils, FairseqDataset
def collate(
samples, pad_idx, eos_idx, left_pad_source=True, ... | 12,245 | 41.373702 | 107 | py |
ELLE | ELLE-main/fairseq-0.9.0/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
class TokenBlockDataset(FairseqDataset):
"""Break... | 5,961 | 34.700599 | 96 | py |
ELLE | ELLE-main/fairseq-0.9.0/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 numpy as np
from . import BaseWrapperDataset
class SubsampleDataset(BaseWrapperDataset):
"""Subsamples a given dataset by a spec... | 2,042 | 29.492537 | 101 | py |
ELLE | ELLE-main/fairseq-0.9.0/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 |
ELLE | ELLE-main/fairseq-0.9.0/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 __i... | 1,352 | 24.528302 | 65 | py |
ELLE | ELLE-main/fairseq-0.9.0/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__(... | 547 | 20.92 | 65 | py |
ELLE | ELLE-main/fairseq-0.9.0/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
from . import BaseWrapperDataset, plasma_utils
class ResamplingDataset(BaseWrapperDataset):
"""Randomly samples from... | 4,096 | 30.274809 | 78 | py |
ELLE | ELLE-main/fairseq-0.9.0/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.
from collections import Counter
from multiprocessing import Pool
import os
import torch
from fairseq.tokenizer import tokenize_line
from fai... | 10,926 | 32.621538 | 109 | py |
ELLE | ELLE-main/fairseq-0.9.0/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, data... | 1,066 | 23.813953 | 65 | py |
ELLE | ELLE-main/fairseq-0.9.0/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 data_utils, Dictionary
from . import BaseWrapperDa... | 6,814 | 38.393064 | 87 | py |
ELLE | ELLE-main/fairseq-0.9.0/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(... | 3,717 | 34.075472 | 86 | py |
ELLE | ELLE-main/fairseq-0.9.0/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 ... | 3,776 | 31.282051 | 86 | py |
ELLE | ELLE-main/fairseq-0.9.0/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.monolingual_dataset import MonolingualDataset
from . import FairseqDataset
class LMConte... | 2,910 | 35.848101 | 90 | py |
ELLE | ELLE-main/fairseq-0.9.0/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 i... | 844 | 32.8 | 113 | py |
ELLE | ELLE-main/fairseq-0.9.0/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 math
import os
import numpy as np
import torch
from . import data_utils
class CountingIterator(object):
"""Wra... | 11,820 | 32.392655 | 91 | py |
ELLE | ELLE-main/fairseq-0.9.0/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,235 | 36.566265 | 93 | py |
ELLE | ELLE-main/fairseq-0.9.0/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 data_utils, FairseqDataset
def collate(samples, pad_idx, eos_idx):
if len(samples) == 0:
... | 7,469 | 36.164179 | 117 | py |
ELLE | ELLE-main/fairseq-0.9.0/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):
supe... | 486 | 23.35 | 65 | py |
ELLE | ELLE-main/fairseq-0.9.0/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,394 | 36.702703 | 117 | py |
ELLE | ELLE-main/fairseq-0.9.0/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... | 424 | 19.238095 | 65 | py |
ELLE | ELLE-main/fairseq-0.9.0/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.
from functools import lru_cache
import os
import shutil
import struct
import numpy as np
import torch
from . import FairseqDataset
def __b... | 16,026 | 29.585878 | 105 | py |
ELLE | ELLE-main/fairseq-0.9.0/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 numpy as np
import torch
import math
from . import data_utils, FairseqDataset
def collate(
samples,
pad_idx,
eos_idx,
... | 14,119 | 35.580311 | 118 | py |
ELLE | ELLE-main/fairseq-0.9.0/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, dat... | 1,439 | 26.169811 | 67 | py |
ELLE | ELLE-main/fairseq-0.9.0/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, r... | 787 | 22.878788 | 65 | py |
ELLE | ELLE-main/fairseq-0.9.0/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 torch
import numpy as np
from fairseq.data import data_utils
class WordNoising(object):
"""Generate a noisy version of a sentenc... | 12,177 | 37.537975 | 110 | py |
ELLE | ELLE-main/fairseq-0.9.0/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,573 | 26.614035 | 75 | py |
ELLE | ELLE-main/fairseq-0.9.0/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.utils.data
class EpochListening:
"""Mixin for receiving updates whenever the epoch increments."""
de... | 2,202 | 29.178082 | 80 | py |
ELLE | ELLE-main/fairseq-0.9.0/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,300 | 35.449153 | 88 | py |
ELLE | ELLE-main/fairseq-0.9.0/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 os
import numpy as np
import sys
import torch
import torch.nn.functional as F
from .. import FairseqDataset
class RawAudioDataset(... | 4,571 | 28.121019 | 84 | py |
ELLE | ELLE-main/fairseq-0.9.0/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... | 907 | 30.310345 | 67 | py |
ELLE | ELLE-main/fairseq-0.9.0/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 fairseq.data.encoders import register_bpe
@register_bpe('bert')
class BertBPE(object):
@staticmethod
def add_args(parser):
... | 1,799 | 33.615385 | 90 | py |
ELLE | ELLE-main/fairseq-0.9.0/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,878 | 40.146965 | 99 | py |
ELLE | ELLE-main/fairseq-0.9.0/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
import numpy as np
import torch
from typing import Dict, List, Tuple
from fairseq.data import FairseqDataset, data_utils
from ... | 12,468 | 37.603715 | 83 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/tasks/continual_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 os
import torch
from fairseq import utils
from fairseq.data import (
data_utils,
Dictionary,
MonolingualDataset,
Toke... | 14,067 | 37.437158 | 145 | py |
ELLE | ELLE-main/fairseq-0.9.0/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 os
import torch
from fairseq import utils
from fairseq.data import (
data_utils,
Dictionary,
MonolingualDataset,
Toke... | 9,239 | 37.181818 | 98 | py |
ELLE | ELLE-main/fairseq-0.9.0/fairseq/tasks/continual_KI.py | # Copyright (c) Facebook, Inc. and 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 torch
import fairseq.utils
from fairseq.data import (
data_utils,
Dictionary,
IdDataset,
... | 15,477 | 39.098446 | 145 | py |
ELLE | ELLE-main/fairseq-0.9.0/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 os
import numpy as np
import torch
from fairseq.data import (
data_utils,
Dictionary,
encoders,
ConcatDataset,
Id... | 12,280 | 39.531353 | 98 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.