id int64 0 328k | repository_name stringlengths 7 58 | file_path stringlengths 9 302 | class_name stringlengths 5 256 | human_written_code stringlengths 16 2.16M | class_skeleton stringlengths 18 1.49M ⌀ | total_program_units int64 1 1.76k | total_doc_str int64 0 771 | AvgCountLine float64 0 7.89k | AvgCountLineBlank float64 0 297 | AvgCountLineCode float64 0 7.89k | AvgCountLineComment float64 0 7.89k | AvgCyclomatic float64 0 130 | CommentToCodeRatio float64 0 168 | CountClassBase float64 0 40 | CountClassCoupled float64 0 583 | CountClassCoupledModified float64 0 575 | CountClassDerived float64 0 5.35k | CountDeclInstanceMethod float64 0 529 | CountDeclInstanceVariable float64 0 296 | CountDeclMethod float64 0 599 | CountDeclMethodAll float64 0 1.12k | CountLine float64 1 40.4k | CountLineBlank float64 0 8.16k | CountLineCode float64 1 25.7k | CountLineCodeDecl float64 1 8.15k | CountLineCodeExe float64 0 24.2k | CountLineComment float64 0 16.5k | CountStmt float64 1 9.71k | CountStmtDecl float64 1 8.15k | CountStmtExe float64 0 9.69k | MaxCyclomatic float64 0 759 | MaxInheritanceTree float64 0 16 | MaxNesting float64 0 34 | SumCyclomatic float64 0 2.9k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1,400 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/convnextv2/modeling_convnextv2.py | transformers.models.convnextv2.modeling_convnextv2.ConvNextV2DropPath | from torch import nn
from typing import Optional
import torch
class ConvNextV2DropPath(nn.Module):
"""Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks)."""
def __init__(self, drop_prob: Optional[float]=None) -> None:
super().__init__()
self.drop_prob = dro... |
class ConvNextV2DropPath(nn.Module):
'''Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks).'''
def __init__(self, drop_prob: Optional[float]=None) -> None:
pass
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
pass
def extra_repr(se... | 4 | 1 | 2 | 0 | 2 | 0 | 1 | 0.13 | 1 | 4 | 0 | 0 | 3 | 1 | 3 | 13 | 12 | 3 | 8 | 5 | 4 | 1 | 8 | 5 | 4 | 1 | 1 | 0 | 3 |
1,401 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/convnextv2/modeling_convnextv2.py | transformers.models.convnextv2.modeling_convnextv2.ConvNextV2Embeddings | import torch
from torch import nn
class ConvNextV2Embeddings(nn.Module):
"""This class is comparable to (and inspired by) the SwinEmbeddings class
found in src/transformers/models/swin/modeling_swin.py.
"""
def __init__(self, config):
super().__init__()
self.patch_embeddings = nn.Conv2... |
class ConvNextV2Embeddings(nn.Module):
'''This class is comparable to (and inspired by) the SwinEmbeddings class
found in src/transformers/models/swin/modeling_swin.py.
'''
def __init__(self, config):
pass
def forward(self, pixel_values: torch.FloatTensor) -> torch.Tensor:
pass | 3 | 1 | 8 | 0 | 8 | 0 | 2 | 0.18 | 1 | 4 | 1 | 0 | 2 | 3 | 2 | 12 | 22 | 2 | 17 | 8 | 14 | 3 | 13 | 8 | 10 | 2 | 1 | 1 | 3 |
1,402 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/convnextv2/modeling_convnextv2.py | transformers.models.convnextv2.modeling_convnextv2.ConvNextV2Encoder | from ...modeling_outputs import BackboneOutput, BaseModelOutputWithNoAttention, BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention
from typing import Optional
from torch import nn
import torch
class ConvNextV2Encoder(nn.Module):
def __init__(self, config):
super().__init__()
... |
class ConvNextV2Encoder(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states: torch.Tensor, output_hidden_states: Optional[bool]=False) -> BaseModelOutputWithNoAttention:
pass | 3 | 0 | 22 | 3 | 19 | 0 | 5 | 0 | 1 | 7 | 2 | 0 | 2 | 1 | 2 | 12 | 45 | 6 | 39 | 16 | 31 | 0 | 22 | 11 | 19 | 6 | 1 | 2 | 9 |
1,403 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/convnextv2/modeling_convnextv2.py | transformers.models.convnextv2.modeling_convnextv2.ConvNextV2ForImageClassification | from torch import nn
from ...modeling_outputs import BackboneOutput, BaseModelOutputWithNoAttention, BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention
from typing import Optional
from ...utils.generic import can_return_tuple
from ...utils import auto_docstring, logging
import torch
@auto_d... | @auto_docstring(custom_intro='\n ConvNextV2 Model with an image classification head on top (a linear layer on top of the pooled features), e.g. for\n ImageNet.\n ')
class ConvNextV2ForImageClassification(ConvNextV2PreTrainedModel):
def __init__(self, config):
pass
@can_return_tuple
@auto_d... | 6 | 1 | 33 | 5 | 24 | 4 | 8 | 0.14 | 1 | 5 | 2 | 0 | 2 | 3 | 2 | 3 | 74 | 10 | 56 | 19 | 40 | 8 | 32 | 12 | 29 | 13 | 2 | 3 | 15 |
1,404 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/convnextv2/modeling_convnextv2.py | transformers.models.convnextv2.modeling_convnextv2.ConvNextV2GRN | from torch import nn
import torch
class ConvNextV2GRN(nn.Module):
"""GRN (Global Response Normalization) layer"""
def __init__(self, dim: int):
super().__init__()
self.weight = nn.Parameter(torch.zeros(1, 1, 1, dim))
self.bias = nn.Parameter(torch.zeros(1, 1, 1, dim))
def forward(... |
class ConvNextV2GRN(nn.Module):
'''GRN (Global Response Normalization) layer'''
def __init__(self, dim: int):
pass
def forward(self, hidden_states: torch.FloatTensor) -> torch.FloatTensor:
pass | 3 | 1 | 6 | 1 | 5 | 1 | 1 | 0.2 | 1 | 2 | 0 | 0 | 2 | 2 | 2 | 12 | 15 | 3 | 10 | 7 | 7 | 2 | 10 | 7 | 7 | 1 | 1 | 0 | 2 |
1,405 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/convnextv2/modeling_convnextv2.py | transformers.models.convnextv2.modeling_convnextv2.ConvNextV2Layer | import torch
from torch import nn
from ...activations import ACT2FN
class ConvNextV2Layer(nn.Module):
"""This corresponds to the `Block` class in the original implementation.
There are two equivalent implementations: [DwConv, LayerNorm (channels_first), Conv, GELU,1x1 Conv]; all in (N, C,
H, W) (2) [DwCon... |
class ConvNextV2Layer(nn.Module):
'''This corresponds to the `Block` class in the original implementation.
There are two equivalent implementations: [DwConv, LayerNorm (channels_first), Conv, GELU,1x1 Conv]; all in (N, C,
H, W) (2) [DwConv, Permute to (N, H, W, C), LayerNorm (channels_last), Linear, GELU, ... | 3 | 1 | 13 | 1 | 11 | 2 | 2 | 0.59 | 1 | 5 | 3 | 0 | 2 | 7 | 2 | 12 | 41 | 6 | 22 | 11 | 19 | 13 | 22 | 11 | 19 | 2 | 1 | 0 | 3 |
1,406 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/convnextv2/modeling_convnextv2.py | transformers.models.convnextv2.modeling_convnextv2.ConvNextV2LayerNorm | import torch
from torch import nn
class ConvNextV2LayerNorm(nn.LayerNorm):
"""LayerNorm that supports two data formats: channels_last (default) or channels_first.
The ordering of the dimensions in the inputs. channels_last corresponds to inputs with shape (batch_size, height,
width, channels) while channel... |
class ConvNextV2LayerNorm(nn.LayerNorm):
'''LayerNorm that supports two data formats: channels_last (default) or channels_first.
The ordering of the dimensions in the inputs. channels_last corresponds to inputs with shape (batch_size, height,
width, channels) while channels_first corresponds to inputs with... | 3 | 2 | 11 | 0 | 11 | 0 | 3 | 0.18 | 1 | 3 | 0 | 0 | 2 | 5 | 2 | 12 | 28 | 2 | 22 | 11 | 19 | 4 | 21 | 11 | 18 | 3 | 1 | 1 | 5 |
1,407 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/convnextv2/modeling_convnextv2.py | transformers.models.convnextv2.modeling_convnextv2.ConvNextV2Model | from ...utils.generic import can_return_tuple
from ...utils import auto_docstring, logging
import torch
from torch import nn
from ...modeling_outputs import BackboneOutput, BaseModelOutputWithNoAttention, BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention
from typing import Optional
@auto_d... | @auto_docstring
class ConvNextV2Model(ConvNextV2PreTrainedModel):
def __init__(self, config):
pass
@can_return_tuple
@auto_docstring
def forward(self, pixel_values: Optional[torch.FloatTensor]=None, output_hidden_states: Optional[bool]=None) -> BaseModelOutputWithPoolingAndNoAttention:
... | 6 | 0 | 24 | 5 | 17 | 2 | 3 | 0.07 | 1 | 6 | 3 | 0 | 2 | 4 | 2 | 3 | 57 | 11 | 43 | 17 | 27 | 3 | 20 | 11 | 17 | 5 | 2 | 1 | 6 |
1,408 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/convnextv2/modeling_convnextv2.py | transformers.models.convnextv2.modeling_convnextv2.ConvNextV2PreTrainedModel | from ...modeling_utils import PreTrainedModel
from .configuration_convnextv2 import ConvNextV2Config
from ...utils import auto_docstring, logging
from torch import nn
@auto_docstring
class ConvNextV2PreTrainedModel(PreTrainedModel):
config: ConvNextV2Config
base_model_prefix = 'convnextv2'
main_input_name ... | @auto_docstring
class ConvNextV2PreTrainedModel(PreTrainedModel):
def _init_weights(self, module):
'''Initialize the weights'''
pass | 3 | 1 | 11 | 0 | 8 | 3 | 4 | 0.54 | 1 | 0 | 0 | 3 | 1 | 0 | 1 | 1 | 22 | 2 | 13 | 6 | 11 | 7 | 12 | 6 | 10 | 4 | 1 | 2 | 4 |
1,409 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/convnextv2/modeling_convnextv2.py | transformers.models.convnextv2.modeling_convnextv2.ConvNextV2Stage | import torch
from torch import nn
class ConvNextV2Stage(nn.Module):
"""ConvNeXTV2 stage, consisting of an optional downsampling layer + multiple residual blocks.
Args:
config ([`ConvNextV2Config`]): Model configuration class.
in_channels (`int`): Number of input channels.
out_channels ... |
class ConvNextV2Stage(nn.Module):
'''ConvNeXTV2 stage, consisting of an optional downsampling layer + multiple residual blocks.
Args:
config ([`ConvNextV2Config`]): Model configuration class.
in_channels (`int`): Number of input channels.
out_channels (`int`): Number of output channels.... | 3 | 1 | 9 | 1 | 9 | 0 | 2 | 0.44 | 1 | 5 | 2 | 0 | 2 | 2 | 2 | 12 | 30 | 4 | 18 | 5 | 15 | 8 | 12 | 5 | 9 | 2 | 1 | 1 | 3 |
1,410 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cpm/tokenization_cpm.py | transformers.models.cpm.tokenization_cpm.CpmTokenizer | from ...tokenization_utils import AddedToken, PreTrainedTokenizer
import unicodedata
import os
from ...utils import SPIECE_UNDERLINE, logging
import sentencepiece as spm
from typing import Any, Optional
from shutil import copyfile
from ...utils.import_utils import requires
@requires(backends=('sentencepiece',))
class ... | @requires(backends=('sentencepiece',))
class CpmTokenizer(PreTrainedTokenizer):
'''Runs pre-tokenization with Jieba-RS segmentation tool. It is used in CPM models.'''
def __init__(self, vocab_file, do_lower_case=False, remove_space=True, keep_accents=False, bos_token='<s>', eos_token='</s>', unk_token='<unk>',... | 18 | 9 | 19 | 2 | 10 | 7 | 2 | 0.75 | 1 | 6 | 0 | 0 | 15 | 10 | 15 | 104 | 313 | 52 | 149 | 68 | 109 | 112 | 101 | 43 | 84 | 5 | 3 | 4 | 34 |
1,411 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cpm/tokenization_cpm_fast.py | transformers.models.cpm.tokenization_cpm_fast.CpmTokenizerFast | import os
from ...tokenization_utils_fast import AddedToken, PreTrainedTokenizerFast
from shutil import copyfile
from typing import Optional
class CpmTokenizerFast(PreTrainedTokenizerFast):
"""Runs pre-tokenization with Jieba-RS segmentation tool. It is used in CPM models."""
def __init__(self, vocab_file=Non... |
class CpmTokenizerFast(PreTrainedTokenizerFast):
'''Runs pre-tokenization with Jieba-RS segmentation tool. It is used in CPM models.'''
def __init__(self, vocab_file=None, tokenizer_file=None, do_lower_case=False, remove_space=True, keep_accents=False, bos_token='<s>', eos_token='</s>', unk_token='<unk>', sep... | 7 | 4 | 28 | 4 | 13 | 11 | 2 | 0.9 | 1 | 5 | 0 | 0 | 7 | 7 | 7 | 95 | 209 | 32 | 93 | 44 | 63 | 84 | 46 | 22 | 37 | 5 | 3 | 1 | 16 |
1,412 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cpmant/configuration_cpmant.py | transformers.models.cpmant.configuration_cpmant.CpmAntConfig | from ...configuration_utils import PretrainedConfig
class CpmAntConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`CpmAntModel`]. It is used to instantiate an
CPMAnt model according to the specified arguments, defining the model architecture. Instantiating a con... |
class CpmAntConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`CpmAntModel`]. It is used to instantiate an
CPMAnt model according to the specified arguments, defining the model architecture. Instantiating a configuration
with the defaults will yield a simila... | 2 | 1 | 35 | 0 | 35 | 0 | 1 | 1.35 | 1 | 4 | 0 | 0 | 1 | 15 | 1 | 1 | 96 | 9 | 37 | 36 | 17 | 50 | 19 | 18 | 17 | 1 | 1 | 0 | 1 |
1,413 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cpmant/modeling_cpmant.py | transformers.models.cpmant.modeling_cpmant.CpmAntAttention | import torch
from .configuration_cpmant import CpmAntConfig
import math
from ...cache_utils import Cache, DynamicCache
from typing import Optional, Union
from torch import nn
import torch.nn.functional as F
class CpmAntAttention(nn.Module):
def __init__(self, config: CpmAntConfig, layer_idx=None):
super()... |
class CpmAntAttention(nn.Module):
def __init__(self, config: CpmAntConfig, layer_idx=None):
pass
def forward(self, hidden_q: torch.Tensor, hidden_kv: torch.Tensor, attention_mask: torch.BoolTensor, position_bias: torch.Tensor, output_attentions: Optional[bool]=False, past_key_values: Optional[Cache]=... | 3 | 1 | 50 | 8 | 32 | 10 | 4 | 0.31 | 1 | 5 | 1 | 0 | 2 | 9 | 2 | 12 | 102 | 17 | 65 | 29 | 53 | 20 | 46 | 20 | 43 | 5 | 1 | 1 | 7 |
1,414 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cpmant/modeling_cpmant.py | transformers.models.cpmant.modeling_cpmant.CpmAntDenseGatedACT | import torch
from .configuration_cpmant import CpmAntConfig
from torch import nn
import torch.nn.functional as F
class CpmAntDenseGatedACT(nn.Module):
def __init__(self, config: CpmAntConfig):
super().__init__()
self.w_0 = nn.Linear(config.hidden_size, config.dim_ff, bias=False)
self.w_1 =... |
class CpmAntDenseGatedACT(nn.Module):
def __init__(self, config: CpmAntConfig):
pass
def forward(self, hidden_states: torch.Tensor):
'''Transform an input tensor from one feature space to another via a nonlinear operation
Args:
hidden_states (`torch.Tensor` of shape `(batc... | 3 | 1 | 8 | 1 | 5 | 2 | 1 | 0.36 | 1 | 3 | 1 | 0 | 2 | 3 | 2 | 12 | 18 | 3 | 11 | 7 | 8 | 4 | 11 | 7 | 8 | 1 | 1 | 0 | 2 |
1,415 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cpmant/modeling_cpmant.py | transformers.models.cpmant.modeling_cpmant.CpmAntEncoder | from .configuration_cpmant import CpmAntConfig
import torch
from typing import Optional, Union
import torch.nn.functional as F
from torch import nn
from ...cache_utils import Cache, DynamicCache
class CpmAntEncoder(nn.Module):
def __init__(self, config: CpmAntConfig):
super().__init__()
self.num_l... |
class CpmAntEncoder(nn.Module):
def __init__(self, config: CpmAntConfig):
pass
def forward(self, hidden_states: torch.Tensor, attention_mask: torch.Tensor, position_bias: torch.Tensor, output_attentions: Optional[bool]=None, output_hidden_states: Optional[bool]=None, past_key_values: Optional[Cache]=... | 3 | 1 | 31 | 3 | 19 | 9 | 6 | 0.46 | 1 | 8 | 3 | 0 | 2 | 3 | 2 | 12 | 63 | 6 | 39 | 21 | 27 | 18 | 23 | 12 | 20 | 10 | 1 | 2 | 11 |
1,416 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cpmant/modeling_cpmant.py | transformers.models.cpmant.modeling_cpmant.CpmAntFFNBlock | import torch.nn.functional as F
from torch import nn
import torch
from .configuration_cpmant import CpmAntConfig
class CpmAntFFNBlock(nn.Module):
def __init__(self, config: CpmAntConfig):
super().__init__()
self.layernorm_before_ffn = CpmAntLayerNorm(config)
self.ffn = CpmAntFeedForward(co... |
class CpmAntFFNBlock(nn.Module):
def __init__(self, config: CpmAntConfig):
pass
def forward(self, hidden_states: torch.Tensor):
'''
Args:
hidden_states (`torch.Tensor` of shape `(batch, len_seq, dim_model)`):
Hidden states before feed forward layer.
... | 3 | 1 | 12 | 0 | 9 | 3 | 2 | 0.26 | 1 | 5 | 3 | 0 | 2 | 3 | 2 | 12 | 25 | 1 | 19 | 11 | 13 | 5 | 15 | 8 | 12 | 2 | 1 | 1 | 4 |
1,417 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cpmant/modeling_cpmant.py | transformers.models.cpmant.modeling_cpmant.CpmAntFeedForward | from .configuration_cpmant import CpmAntConfig
import torch
from torch import nn
import torch.nn.functional as F
class CpmAntFeedForward(nn.Module):
def __init__(self, config: CpmAntConfig):
super().__init__()
self.w_in = CpmAntDenseGatedACT(config)
if config.dropout_p is not None:
... |
class CpmAntFeedForward(nn.Module):
def __init__(self, config: CpmAntConfig):
pass
def forward(self, hidden_states: torch.Tensor):
'''
Args:
hidden_states (`torch.Tensor` of shape `(batch, seq_len, dim_in)`)
'''
pass | 3 | 1 | 11 | 2 | 7 | 2 | 2 | 0.27 | 1 | 4 | 2 | 0 | 2 | 3 | 2 | 12 | 24 | 5 | 15 | 6 | 12 | 4 | 14 | 6 | 11 | 2 | 1 | 1 | 4 |
1,418 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cpmant/modeling_cpmant.py | transformers.models.cpmant.modeling_cpmant.CpmAntForCausalLM | from typing import Optional, Union
from torch import nn
import torch
import torch.nn.functional as F
from torch.nn import CrossEntropyLoss
from ...modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast
from .configuration_cpmant import CpmAntConfig
from ...generation import GenerationMixin
from ...cach... | @auto_docstring(custom_intro='\n The CPMAnt Model with a language modeling head on top (linear layer with weights tied to the input embeddings).\n ')
class CpmAntForCausalLM(CpmAntPreTrainedModel, GenerationMixin):
def __init__(self, config: CpmAntConfig):
pass
@auto_docstring
def forward(sel... | 8 | 1 | 15 | 2 | 8 | 6 | 2 | 0.66 | 2 | 7 | 3 | 0 | 7 | 2 | 7 | 8 | 118 | 18 | 61 | 30 | 36 | 40 | 34 | 18 | 26 | 6 | 2 | 1 | 14 |
1,419 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cpmant/modeling_cpmant.py | transformers.models.cpmant.modeling_cpmant.CpmAntIntermediate | import torch.nn.functional as F
import torch
from torch import nn
from ...activations import ACT2FN
class CpmAntIntermediate(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.intermediate_size)
if isinstance(config.hidden_act, str)... |
class CpmAntIntermediate(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
pass | 3 | 0 | 6 | 0 | 6 | 0 | 2 | 0 | 1 | 3 | 0 | 0 | 2 | 2 | 2 | 12 | 13 | 1 | 12 | 5 | 9 | 0 | 11 | 5 | 8 | 2 | 1 | 1 | 3 |
1,420 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cpmant/modeling_cpmant.py | transformers.models.cpmant.modeling_cpmant.CpmAntLayerNorm | from .configuration_cpmant import CpmAntConfig
import torch.nn.functional as F
from torch import nn
import torch
class CpmAntLayerNorm(nn.Module):
"""
We use Root Mean Square (RMS) Layer Normalization, please see https://huggingface.co/papers/1910.07467 for details."
"""
def __init__(self, config: Cpm... |
class CpmAntLayerNorm(nn.Module):
'''
We use Root Mean Square (RMS) Layer Normalization, please see https://huggingface.co/papers/1910.07467 for details."
'''
def __init__(self, config: CpmAntConfig):
pass
def forward(self, hidden_states: torch.Tensor):
'''
Args:
... | 3 | 2 | 9 | 1 | 6 | 2 | 2 | 0.54 | 1 | 4 | 1 | 0 | 2 | 3 | 2 | 12 | 23 | 3 | 13 | 8 | 10 | 7 | 13 | 8 | 10 | 2 | 1 | 1 | 3 |
1,421 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cpmant/modeling_cpmant.py | transformers.models.cpmant.modeling_cpmant.CpmAntModel | from ...cache_utils import Cache, DynamicCache
import torch.nn.functional as F
from .configuration_cpmant import CpmAntConfig
from ...modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast
from typing import Optional, Union
from ...utils import auto_docstring, logging
from torch import nn
import torch
... | @auto_docstring
class CpmAntModel(CpmAntPreTrainedModel):
def __init__(self, config: CpmAntConfig):
pass
def get_input_embeddings(self):
pass
def set_input_embeddings(self, embeddings, **kwargs):
pass
def _prepare_attention_mask(self, input_ids, span, context, length):
... | 8 | 1 | 26 | 2 | 23 | 1 | 3 | 0.02 | 1 | 10 | 4 | 0 | 5 | 6 | 5 | 6 | 139 | 13 | 123 | 45 | 102 | 3 | 72 | 35 | 66 | 13 | 2 | 3 | 17 |
1,422 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cpmant/modeling_cpmant.py | transformers.models.cpmant.modeling_cpmant.CpmAntOutput | import torch.nn.functional as F
import torch
from torch import nn
class CpmAntOutput(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.intermediate_size, config.hidden_size)
self.LayerNorm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps)
... |
class CpmAntOutput(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states: torch.Tensor, input_tensor: torch.Tensor) -> torch.Tensor:
pass | 3 | 0 | 5 | 0 | 5 | 0 | 1 | 0 | 1 | 2 | 0 | 0 | 2 | 3 | 2 | 12 | 12 | 1 | 11 | 6 | 8 | 0 | 11 | 6 | 8 | 1 | 1 | 0 | 2 |
1,423 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cpmant/modeling_cpmant.py | transformers.models.cpmant.modeling_cpmant.CpmAntPreTrainedModel | from torch import nn
from .configuration_cpmant import CpmAntConfig
from ...modeling_utils import PreTrainedModel
from ...utils import auto_docstring, logging
@auto_docstring
class CpmAntPreTrainedModel(PreTrainedModel):
config: CpmAntConfig
base_model_prefix = 'cpmant'
def _init_weights(self, module):
... | @auto_docstring
class CpmAntPreTrainedModel(PreTrainedModel):
def _init_weights(self, module):
'''Initialize the weights'''
pass | 3 | 1 | 17 | 0 | 16 | 1 | 8 | 0.26 | 1 | 2 | 2 | 2 | 1 | 0 | 1 | 1 | 26 | 2 | 19 | 4 | 17 | 5 | 15 | 4 | 13 | 8 | 1 | 2 | 8 |
1,424 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cpmant/modeling_cpmant.py | transformers.models.cpmant.modeling_cpmant.CpmAntSegmentPositionEmbedding | import torch
from torch import nn
from .configuration_cpmant import CpmAntConfig
import math
import torch.nn.functional as F
class CpmAntSegmentPositionEmbedding(nn.Module):
def __init__(self, config: CpmAntConfig):
super().__init__()
self.num_heads = config.num_attention_heads
self.num_bu... |
class CpmAntSegmentPositionEmbedding(nn.Module):
def __init__(self, config: CpmAntConfig):
pass
def forward(self, key_pos: torch.Tensor, query_pos: torch.Tensor, key_segment: torch.Tensor, query_segment: torch.Tensor):
pass
def _segment_relative_position_bucket(self, query_segment, key_s... | 5 | 0 | 22 | 2 | 19 | 1 | 2 | 0.05 | 1 | 4 | 1 | 0 | 4 | 5 | 4 | 14 | 90 | 10 | 76 | 26 | 65 | 4 | 43 | 20 | 38 | 4 | 1 | 2 | 7 |
1,425 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cpmant/modeling_cpmant.py | transformers.models.cpmant.modeling_cpmant.CpmAntSelfAttentionBlock | from .configuration_cpmant import CpmAntConfig
from torch import nn
import torch.nn.functional as F
from typing import Optional, Union
from ...cache_utils import Cache, DynamicCache
import torch
class CpmAntSelfAttentionBlock(nn.Module):
def __init__(self, config: CpmAntConfig, layer_idx=None):
super().__... |
class CpmAntSelfAttentionBlock(nn.Module):
def __init__(self, config: CpmAntConfig, layer_idx=None):
pass
def forward(self, hidden_states: torch.Tensor, attention_mask: torch.Tensor, position_bias: Optional[torch.Tensor]=None, output_attentions: Optional[bool]=False, past_key_values: Optional[Cache]=... | 3 | 1 | 23 | 2 | 13 | 8 | 2 | 0.59 | 1 | 6 | 3 | 0 | 2 | 3 | 2 | 12 | 47 | 4 | 27 | 16 | 16 | 16 | 16 | 8 | 13 | 2 | 1 | 1 | 4 |
1,426 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cpmant/modeling_cpmant.py | transformers.models.cpmant.modeling_cpmant.CpmAntTransformerBlock | import torch.nn.functional as F
import torch
from .configuration_cpmant import CpmAntConfig
from typing import Optional, Union
from ...cache_utils import Cache, DynamicCache
from torch import nn
class CpmAntTransformerBlock(nn.Module):
def __init__(self, config: CpmAntConfig, layer_idx=None):
super().__in... |
class CpmAntTransformerBlock(nn.Module):
def __init__(self, config: CpmAntConfig, layer_idx=None):
pass
def forward(self, hidden_states: torch.Tensor, attention_mask: torch.Tensor, position_bias: Optional[torch.Tensor]=None, output_attentions: Optional[bool]=False, past_key_values: Optional[Cache]=No... | 3 | 1 | 22 | 2 | 12 | 8 | 1 | 0.64 | 1 | 6 | 3 | 0 | 2 | 2 | 2 | 12 | 45 | 4 | 25 | 14 | 14 | 16 | 10 | 6 | 7 | 1 | 1 | 0 | 2 |
1,427 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cpmant/tokenization_cpmant.py | transformers.models.cpmant.tokenization_cpmant.CpmAntTokenizer | from typing import Optional
from ...tokenization_utils import PreTrainedTokenizer
from transformers.utils import is_rjieba_available, requires_backends
import os
import collections
class CpmAntTokenizer(PreTrainedTokenizer):
"""
Construct a CPMAnt tokenizer. Based on byte-level Byte-Pair-Encoding.
Args:
... |
class CpmAntTokenizer(PreTrainedTokenizer):
'''
Construct a CPMAnt tokenizer. Based on byte-level Byte-Pair-Encoding.
Args:
vocab_file (`str`):
Path to the vocabulary file.
bod_token (`str`, *optional*, defaults to `"<d>"`):
The beginning of document token.
e... | 20 | 7 | 9 | 1 | 7 | 2 | 2 | 0.41 | 1 | 7 | 1 | 0 | 15 | 5 | 15 | 104 | 189 | 28 | 114 | 49 | 79 | 47 | 74 | 29 | 58 | 8 | 3 | 3 | 26 |
1,428 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cpmant/tokenization_cpmant.py | transformers.models.cpmant.tokenization_cpmant.WordpieceTokenizer | class WordpieceTokenizer:
def __init__(self, vocab, unk_token='<unk>', max_input_chars_per_word=200):
self.vocab = vocab
self.unk_token = unk_token
self.max_input_chars_per_word = max_input_chars_per_word
def tokenize(self, token):
chars = list(token)
if len(chars) > se... | class WordpieceTokenizer:
def __init__(self, vocab, unk_token='<unk>', max_input_chars_per_word=200):
pass
def tokenize(self, token):
pass | 3 | 0 | 14 | 1 | 13 | 0 | 4 | 0 | 0 | 1 | 0 | 0 | 2 | 3 | 2 | 2 | 30 | 3 | 27 | 12 | 24 | 0 | 26 | 12 | 23 | 6 | 0 | 3 | 7 |
1,429 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ctrl/configuration_ctrl.py | transformers.models.ctrl.configuration_ctrl.CTRLConfig | from ...configuration_utils import PretrainedConfig
class CTRLConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`CTRLModel`] or a [`TFCTRLModel`]. It is used to
instantiate a CTRL model according to the specified arguments, defining the model architecture. Insta... |
class CTRLConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`CTRLModel`] or a [`TFCTRLModel`]. It is used to
instantiate a CTRL model according to the specified arguments, defining the model architecture. Instantiating a
configuration with the defaults will ... | 2 | 1 | 29 | 2 | 27 | 0 | 1 | 1.17 | 1 | 1 | 0 | 0 | 1 | 11 | 1 | 1 | 90 | 12 | 36 | 30 | 20 | 42 | 17 | 16 | 15 | 1 | 1 | 0 | 1 |
1,430 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ctrl/modeling_ctrl.py | transformers.models.ctrl.modeling_ctrl.CTRLForSequenceClassification | from ...utils import auto_docstring, logging
from ...cache_utils import Cache, DynamicCache
from typing import Optional, Union
from torch import nn
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
import torch
from ...modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast, SequenceClas... | null | 5 | 1 | 88 | 14 | 43 | 31 | 9 | 0.7 | 1 | 7 | 2 | 0 | 2 | 3 | 2 | 3 | 180 | 29 | 89 | 32 | 70 | 62 | 45 | 17 | 42 | 16 | 2 | 3 | 17 |
1,431 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ctrl/modeling_ctrl.py | transformers.models.ctrl.modeling_ctrl.CTRLLMHeadModel | from ...modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast, SequenceClassifierOutput
from ...generation import GenerationMixin
import torch
from ...utils import auto_docstring, logging
from ...cache_utils import Cache, DynamicCache
from torch import nn
from typing import Optional, Union
@auto_docs... | @auto_docstring(custom_intro='\n The CTRL Model transformer with a language modeling head on top (linear layer with weights tied to the input\n embeddings).\n ')
class CTRLLMHeadModel(CTRLPreTrainedModel, GenerationMixin):
def __init__(self, config):
pass
@auto_docstring
def forward(self, ... | 6 | 1 | 22 | 3 | 13 | 6 | 2 | 0.44 | 2 | 6 | 2 | 0 | 5 | 2 | 6 | 7 | 140 | 25 | 80 | 36 | 53 | 35 | 33 | 17 | 26 | 5 | 2 | 2 | 12 |
1,432 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ctrl/modeling_ctrl.py | transformers.models.ctrl.modeling_ctrl.CTRLModel | from torch import nn
from typing import Optional, Union
from ...cache_utils import Cache, DynamicCache
import numpy as np
from ...utils import auto_docstring, logging
from ...modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast, SequenceClassifierOutput
import torch
@auto_docstring
class CTRLModel(C... | @auto_docstring
class CTRLModel(CTRLPreTrainedModel):
def __init__(self, config):
pass
def get_input_embeddings(self):
pass
def set_input_embeddings(self, new_embeddings):
pass
def _prune_heads(self, heads_to_prune):
'''
Prunes heads of the model. heads_to_pru... | 8 | 2 | 35 | 6 | 23 | 7 | 6 | 0.31 | 1 | 11 | 2 | 0 | 5 | 7 | 5 | 6 | 184 | 32 | 118 | 45 | 96 | 36 | 80 | 29 | 74 | 24 | 2 | 2 | 29 |
1,433 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ctrl/modeling_ctrl.py | transformers.models.ctrl.modeling_ctrl.CTRLPreTrainedModel | from .configuration_ctrl import CTRLConfig
from ...modeling_utils import PreTrainedModel
from ...utils import auto_docstring, logging
from ...pytorch_utils import Conv1D, find_pruneable_heads_and_indices, prune_linear_layer
from torch import nn
@auto_docstring
class CTRLPreTrainedModel(PreTrainedModel):
config: CT... | @auto_docstring
class CTRLPreTrainedModel(PreTrainedModel):
def _init_weights(self, module):
'''Initialize the weights.'''
pass | 3 | 1 | 15 | 0 | 12 | 3 | 6 | 0.47 | 1 | 1 | 1 | 3 | 1 | 0 | 1 | 1 | 24 | 2 | 15 | 4 | 13 | 7 | 13 | 4 | 11 | 6 | 1 | 2 | 6 |
1,434 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ctrl/modeling_ctrl.py | transformers.models.ctrl.modeling_ctrl.EncoderLayer | from torch import nn
class EncoderLayer(nn.Module):
def __init__(self, d_model_size, num_heads, dff, rate=0.1, layer_idx=None):
super().__init__()
self.multi_head_attention = MultiHeadAttention(d_model_size, num_heads, layer_idx=layer_idx)
self.ffn = point_wise_feed_forward_network(d_model... |
class EncoderLayer(nn.Module):
def __init__(self, d_model_size, num_heads, dff, rate=0.1, layer_idx=None):
pass
def forward(self, x, mask, layer_past=None, attention_mask=None, head_mask=None, use_cache=False, output_attentions=False, cache_position=None):
pass | 3 | 0 | 19 | 3 | 16 | 0 | 1 | 0 | 1 | 2 | 1 | 0 | 2 | 6 | 2 | 12 | 39 | 6 | 33 | 18 | 28 | 0 | 21 | 16 | 18 | 1 | 1 | 0 | 2 |
1,435 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ctrl/modeling_ctrl.py | transformers.models.ctrl.modeling_ctrl.MultiHeadAttention | from torch import nn
from ...pytorch_utils import Conv1D, find_pruneable_heads_and_indices, prune_linear_layer
class MultiHeadAttention(nn.Module):
def __init__(self, d_model_size, num_heads, layer_idx=None):
super().__init__()
self.num_heads = num_heads
self.d_model_size = d_model_size
... |
class MultiHeadAttention(nn.Module):
def __init__(self, d_model_size, num_heads, layer_idx=None):
pass
def prune_heads(self, heads):
pass
def split_into_heads(self, x, batch_size):
pass
def forward(self, v, k, q, mask, layer_past=None, attention_mask=None, head_mask=None, us... | 5 | 0 | 18 | 3 | 15 | 1 | 2 | 0.03 | 1 | 3 | 0 | 0 | 4 | 8 | 4 | 14 | 77 | 13 | 62 | 34 | 46 | 2 | 50 | 23 | 45 | 4 | 1 | 1 | 8 |
1,436 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/ctrl/tokenization_ctrl.py | transformers.models.ctrl.tokenization_ctrl.CTRLTokenizer | import os
import regex as re
import json
from typing import Optional
from ...tokenization_utils import PreTrainedTokenizer
class CTRLTokenizer(PreTrainedTokenizer):
"""
Construct a CTRL tokenizer. Based on Byte-Pair-Encoding.
This tokenizer inherits from [`PreTrainedTokenizer`] which contains most of the ... |
class CTRLTokenizer(PreTrainedTokenizer):
'''
Construct a CTRL tokenizer. Based on Byte-Pair-Encoding.
This tokenizer inherits from [`PreTrainedTokenizer`] which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.
Args:
voca... | 11 | 5 | 12 | 1 | 10 | 1 | 3 | 0.19 | 1 | 9 | 0 | 0 | 9 | 4 | 9 | 98 | 133 | 20 | 96 | 37 | 85 | 18 | 86 | 32 | 76 | 9 | 3 | 3 | 23 |
1,437 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cvt/configuration_cvt.py | transformers.models.cvt.configuration_cvt.CvtConfig | from ...configuration_utils import PretrainedConfig
class CvtConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`CvtModel`]. It is used to instantiate a CvT model
according to the specified arguments, defining the model architecture. Instantiating a configuration... |
class CvtConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`CvtModel`]. It is used to instantiate a CvT model
according to the specified arguments, defining the model architecture. Instantiating a configuration with the
defaults will yield a similar configur... | 2 | 1 | 47 | 0 | 47 | 0 | 1 | 1.27 | 1 | 1 | 0 | 0 | 1 | 21 | 1 | 1 | 120 | 9 | 49 | 48 | 23 | 62 | 25 | 24 | 23 | 1 | 1 | 0 | 1 |
1,438 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cvt/modeling_cvt.py | transformers.models.cvt.modeling_cvt.CvtAttention | from torch import nn
from ...pytorch_utils import find_pruneable_heads_and_indices, prune_linear_layer
class CvtAttention(nn.Module):
def __init__(self, num_heads, embed_dim, kernel_size, padding_q, padding_kv, stride_q, stride_kv, qkv_projection_method, qkv_bias, attention_drop_rate, drop_rate, with_cls_token=Tr... |
class CvtAttention(nn.Module):
def __init__(self, num_heads, embed_dim, kernel_size, padding_q, padding_kv, stride_q, stride_kv, qkv_projection_method, qkv_bias, attention_drop_rate, drop_rate, with_cls_token=True):
pass
def prune_heads(self, heads):
pass
def forward(self, hidden_state, ... | 4 | 0 | 17 | 1 | 16 | 1 | 1 | 0.04 | 1 | 4 | 2 | 0 | 3 | 3 | 3 | 13 | 55 | 4 | 49 | 24 | 31 | 2 | 21 | 10 | 17 | 2 | 1 | 1 | 4 |
1,439 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cvt/modeling_cvt.py | transformers.models.cvt.modeling_cvt.CvtConvEmbeddings | from torch import nn
import collections.abc
class CvtConvEmbeddings(nn.Module):
"""
Image to Conv Embedding.
"""
def __init__(self, patch_size, num_channels, embed_dim, stride, padding):
super().__init__()
patch_size = patch_size if isinstance(patch_size, collections.abc.Iterable) else... |
class CvtConvEmbeddings(nn.Module):
'''
Image to Conv Embedding.
'''
def __init__(self, patch_size, num_channels, embed_dim, stride, padding):
pass
def forward(self, pixel_values):
pass | 3 | 1 | 9 | 0 | 8 | 1 | 2 | 0.31 | 1 | 2 | 0 | 0 | 2 | 3 | 2 | 12 | 23 | 2 | 16 | 8 | 13 | 5 | 16 | 8 | 13 | 2 | 1 | 1 | 4 |
1,440 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cvt/modeling_cvt.py | transformers.models.cvt.modeling_cvt.CvtDropPath | import torch
from torch import nn
from typing import Optional, Union
class CvtDropPath(nn.Module):
"""Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks)."""
def __init__(self, drop_prob: Optional[float]=None) -> None:
super().__init__()
self.drop_prob = dro... |
class CvtDropPath(nn.Module):
'''Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks).'''
def __init__(self, drop_prob: Optional[float]=None) -> None:
pass
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
pass
def extra_repr(self) -> ... | 4 | 1 | 2 | 0 | 2 | 0 | 1 | 0.13 | 1 | 4 | 0 | 0 | 3 | 1 | 3 | 13 | 12 | 3 | 8 | 5 | 4 | 1 | 8 | 5 | 4 | 1 | 1 | 0 | 3 |
1,441 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cvt/modeling_cvt.py | transformers.models.cvt.modeling_cvt.CvtEmbeddings | from torch import nn
class CvtEmbeddings(nn.Module):
"""
Construct the CvT embeddings.
"""
def __init__(self, patch_size, num_channels, embed_dim, stride, padding, dropout_rate):
super().__init__()
self.convolution_embeddings = CvtConvEmbeddings(patch_size=patch_size, num_channels=num_... |
class CvtEmbeddings(nn.Module):
'''
Construct the CvT embeddings.
'''
def __init__(self, patch_size, num_channels, embed_dim, stride, padding, dropout_rate):
pass
def forward(self, pixel_values):
pass | 3 | 1 | 5 | 0 | 5 | 0 | 1 | 0.27 | 1 | 2 | 1 | 0 | 2 | 2 | 2 | 12 | 16 | 2 | 11 | 6 | 8 | 3 | 9 | 6 | 6 | 1 | 1 | 0 | 2 |
1,442 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cvt/modeling_cvt.py | transformers.models.cvt.modeling_cvt.CvtEncoder | from torch import nn
class CvtEncoder(nn.Module):
def __init__(self, config):
super().__init__()
self.config = config
self.stages = nn.ModuleList([])
for stage_idx in range(len(config.depth)):
self.stages.append(CvtStage(config, stage_idx))
def forward(self, pixel_... |
class CvtEncoder(nn.Module):
def __init__(self, config):
pass
def forward(self, pixel_values, output_hidden_states=False, return_dict=True):
pass | 3 | 0 | 12 | 2 | 11 | 0 | 4 | 0 | 1 | 6 | 2 | 0 | 2 | 2 | 2 | 12 | 26 | 4 | 22 | 10 | 19 | 0 | 18 | 10 | 15 | 5 | 1 | 2 | 7 |
1,443 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cvt/modeling_cvt.py | transformers.models.cvt.modeling_cvt.CvtForImageClassification | from ...modeling_outputs import ImageClassifierOutputWithNoAttention, ModelOutput
from typing import Optional, Union
import torch
from torch import nn
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from ...utils import auto_docstring, logging
@auto_docstring(custom_intro='\n Cvt Model transformer... | @auto_docstring(custom_intro='\n Cvt Model transformer with an image classification head on top (a linear layer on top of the final hidden state of\n the [CLS] token) e.g. for ImageNet.\n ')
class CvtForImageClassification(CvtPreTrainedModel):
def __init__(self, config):
pass
@auto_docstring
... | 5 | 1 | 37 | 4 | 29 | 5 | 8 | 0.14 | 1 | 6 | 2 | 0 | 2 | 4 | 2 | 3 | 83 | 9 | 65 | 23 | 49 | 9 | 40 | 16 | 37 | 13 | 2 | 3 | 15 |
1,444 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cvt/modeling_cvt.py | transformers.models.cvt.modeling_cvt.CvtIntermediate | from torch import nn
class CvtIntermediate(nn.Module):
def __init__(self, embed_dim, mlp_ratio):
super().__init__()
self.dense = nn.Linear(embed_dim, int(embed_dim * mlp_ratio))
self.activation = nn.GELU()
def forward(self, hidden_state):
hidden_state = self.dense(hidden_state... |
class CvtIntermediate(nn.Module):
def __init__(self, embed_dim, mlp_ratio):
pass
def forward(self, hidden_state):
pass | 3 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 1 | 2 | 0 | 0 | 2 | 2 | 2 | 12 | 10 | 1 | 9 | 5 | 6 | 0 | 9 | 5 | 6 | 1 | 1 | 0 | 2 |
1,445 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cvt/modeling_cvt.py | transformers.models.cvt.modeling_cvt.CvtLayer | from torch import nn
class CvtLayer(nn.Module):
"""
CvtLayer composed by attention layers, normalization and multi-layer perceptrons (mlps).
"""
def __init__(self, num_heads, embed_dim, kernel_size, padding_q, padding_kv, stride_q, stride_kv, qkv_projection_method, qkv_bias, attention_drop_rate, drop_... |
class CvtLayer(nn.Module):
'''
CvtLayer composed by attention layers, normalization and multi-layer perceptrons (mlps).
'''
def __init__(self, num_heads, embed_dim, kernel_size, padding_q, padding_kv, stride_q, stride_kv, qkv_projection_method, qkv_bias, attention_drop_rate, drop_rate, mlp_ratio, drop... | 3 | 1 | 29 | 2 | 26 | 2 | 2 | 0.13 | 1 | 5 | 4 | 0 | 2 | 6 | 2 | 12 | 64 | 6 | 52 | 28 | 33 | 7 | 19 | 12 | 16 | 2 | 1 | 0 | 3 |
1,446 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cvt/modeling_cvt.py | transformers.models.cvt.modeling_cvt.CvtModel | from ...utils import auto_docstring, logging
import torch
from typing import Optional, Union
@auto_docstring
class CvtModel(CvtPreTrainedModel):
def __init__(self, config, add_pooling_layer=True):
"""
add_pooling_layer (bool, *optional*, defaults to `True`):
Whether to add a pooling la... | @auto_docstring
class CvtModel(CvtPreTrainedModel):
def __init__(self, config, add_pooling_layer=True):
'''
add_pooling_layer (bool, *optional*, defaults to `True`):
Whether to add a pooling layer
'''
pass
def _prune_heads(self, heads_to_prune):
'''
... | 6 | 2 | 14 | 1 | 11 | 1 | 3 | 0.1 | 1 | 6 | 2 | 0 | 3 | 2 | 3 | 4 | 52 | 6 | 42 | 15 | 25 | 4 | 19 | 9 | 15 | 5 | 2 | 1 | 8 |
1,447 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cvt/modeling_cvt.py | transformers.models.cvt.modeling_cvt.CvtOutput | from torch import nn
class CvtOutput(nn.Module):
def __init__(self, embed_dim, mlp_ratio, drop_rate):
super().__init__()
self.dense = nn.Linear(int(embed_dim * mlp_ratio), embed_dim)
self.dropout = nn.Dropout(drop_rate)
def forward(self, hidden_state, input_tensor):
hidden_sta... |
class CvtOutput(nn.Module):
def __init__(self, embed_dim, mlp_ratio, drop_rate):
pass
def forward(self, hidden_state, input_tensor):
pass | 3 | 0 | 5 | 0 | 5 | 0 | 1 | 0 | 1 | 2 | 0 | 0 | 2 | 2 | 2 | 12 | 11 | 1 | 10 | 5 | 7 | 0 | 10 | 5 | 7 | 1 | 1 | 0 | 2 |
1,448 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cvt/modeling_cvt.py | transformers.models.cvt.modeling_cvt.CvtPreTrainedModel | from ...modeling_utils import PreTrainedModel
from ...utils import auto_docstring, logging
from torch import nn
from .configuration_cvt import CvtConfig
@auto_docstring
class CvtPreTrainedModel(PreTrainedModel):
config: CvtConfig
base_model_prefix = 'cvt'
main_input_name = 'pixel_values'
_no_split_modu... | @auto_docstring
class CvtPreTrainedModel(PreTrainedModel):
def _init_weights(self, module):
'''Initialize the weights'''
pass | 3 | 1 | 14 | 0 | 13 | 1 | 6 | 0.28 | 1 | 1 | 1 | 2 | 1 | 0 | 1 | 1 | 25 | 2 | 18 | 6 | 16 | 5 | 14 | 6 | 12 | 6 | 1 | 2 | 6 |
1,449 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cvt/modeling_cvt.py | transformers.models.cvt.modeling_cvt.CvtSelfAttention | from torch import nn
import torch
class CvtSelfAttention(nn.Module):
def __init__(self, num_heads, embed_dim, kernel_size, padding_q, padding_kv, stride_q, stride_kv, qkv_projection_method, qkv_bias, attention_drop_rate, with_cls_token=True, **kwargs):
super().__init__()
self.scale = embed_dim ** ... |
class CvtSelfAttention(nn.Module):
def __init__(self, num_heads, embed_dim, kernel_size, padding_q, padding_kv, stride_q, stride_kv, qkv_projection_method, qkv_bias, attention_drop_rate, with_cls_token=True, **kwargs):
pass
def rearrange_for_multi_head_attention(self, hidden_state):
pass
... | 4 | 0 | 25 | 3 | 21 | 1 | 2 | 0.05 | 1 | 2 | 1 | 0 | 3 | 11 | 3 | 13 | 79 | 11 | 65 | 41 | 47 | 3 | 41 | 27 | 37 | 3 | 1 | 1 | 6 |
1,450 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cvt/modeling_cvt.py | transformers.models.cvt.modeling_cvt.CvtSelfAttentionConvProjection | from torch import nn
class CvtSelfAttentionConvProjection(nn.Module):
def __init__(self, embed_dim, kernel_size, padding, stride):
super().__init__()
self.convolution = nn.Conv2d(embed_dim, embed_dim, kernel_size=kernel_size, padding=padding, stride=stride, bias=False, groups=embed_dim)
se... |
class CvtSelfAttentionConvProjection(nn.Module):
def __init__(self, embed_dim, kernel_size, padding, stride):
pass
def forward(self, hidden_state):
pass | 3 | 0 | 8 | 0 | 8 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 2 | 2 | 2 | 12 | 18 | 1 | 17 | 5 | 14 | 0 | 9 | 5 | 6 | 1 | 1 | 0 | 2 |
1,451 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cvt/modeling_cvt.py | transformers.models.cvt.modeling_cvt.CvtSelfAttentionLinearProjection | from torch import nn
class CvtSelfAttentionLinearProjection(nn.Module):
def forward(self, hidden_state):
batch_size, num_channels, height, width = hidden_state.shape
hidden_size = height * width
hidden_state = hidden_state.view(batch_size, num_channels, hidden_size).permute(0, 2, 1)
... |
class CvtSelfAttentionLinearProjection(nn.Module):
def forward(self, hidden_state):
pass | 2 | 0 | 6 | 0 | 5 | 1 | 1 | 0.17 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 11 | 7 | 0 | 6 | 4 | 4 | 1 | 6 | 4 | 4 | 1 | 1 | 0 | 1 |
1,452 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cvt/modeling_cvt.py | transformers.models.cvt.modeling_cvt.CvtSelfAttentionProjection | from torch import nn
class CvtSelfAttentionProjection(nn.Module):
def __init__(self, embed_dim, kernel_size, padding, stride, projection_method='dw_bn'):
super().__init__()
if projection_method == 'dw_bn':
self.convolution_projection = CvtSelfAttentionConvProjection(embed_dim, kernel_s... |
class CvtSelfAttentionProjection(nn.Module):
def __init__(self, embed_dim, kernel_size, padding, stride, projection_method='dw_bn'):
pass
def forward(self, hidden_state):
pass | 3 | 0 | 5 | 0 | 5 | 0 | 2 | 0 | 1 | 3 | 2 | 0 | 2 | 2 | 2 | 12 | 11 | 1 | 10 | 5 | 7 | 0 | 10 | 5 | 7 | 2 | 1 | 1 | 3 |
1,453 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cvt/modeling_cvt.py | transformers.models.cvt.modeling_cvt.CvtSelfOutput | from torch import nn
class CvtSelfOutput(nn.Module):
"""
The residual connection is defined in CvtLayer instead of here (as is the case with other models), due to the
layernorm applied before each block.
"""
def __init__(self, embed_dim, drop_rate):
super().__init__()
self.dense = ... |
class CvtSelfOutput(nn.Module):
'''
The residual connection is defined in CvtLayer instead of here (as is the case with other models), due to the
layernorm applied before each block.
'''
def __init__(self, embed_dim, drop_rate):
pass
def forward(self, hidden_state, input_tensor):
... | 3 | 1 | 4 | 0 | 4 | 0 | 1 | 0.44 | 1 | 1 | 0 | 0 | 2 | 2 | 2 | 12 | 15 | 2 | 9 | 5 | 6 | 4 | 9 | 5 | 6 | 1 | 1 | 0 | 2 |
1,454 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/cvt/modeling_cvt.py | transformers.models.cvt.modeling_cvt.CvtStage | from torch import nn
import torch
class CvtStage(nn.Module):
def __init__(self, config, stage):
super().__init__()
self.config = config
self.stage = stage
if self.config.cls_token[self.stage]:
self.cls_token = nn.Parameter(torch.randn(1, 1, self.config.embed_dim[-1]))
... |
class CvtStage(nn.Module):
def __init__(self, config, stage):
pass
def forward(self, hidden_state):
pass | 3 | 0 | 29 | 3 | 26 | 1 | 4 | 0.02 | 1 | 4 | 2 | 0 | 2 | 5 | 2 | 12 | 59 | 6 | 52 | 14 | 49 | 1 | 25 | 13 | 22 | 4 | 1 | 1 | 7 |
1,455 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dab_detr/configuration_dab_detr.py | transformers.models.dab_detr.configuration_dab_detr.DabDetrConfig | from ...utils.backbone_utils import verify_backbone_config_arguments
from ...configuration_utils import PretrainedConfig
from ..auto import CONFIG_MAPPING
class DabDetrConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`DabDetrModel`]. It is used to instantiate
a... |
class DabDetrConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`DabDetrModel`]. It is used to instantiate
a DAB-DETR model according to the specified arguments, defining the model architecture. Instantiating a
configuration with the defaults will yield a sim... | 4 | 1 | 114 | 3 | 105 | 7 | 7 | 0.98 | 1 | 3 | 0 | 0 | 1 | 37 | 1 | 1 | 232 | 13 | 111 | 85 | 68 | 109 | 60 | 44 | 58 | 7 | 1 | 2 | 7 |
1,456 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dab_detr/modeling_dab_detr.py | transformers.models.dab_detr.modeling_dab_detr.DabDetrAttention | import torch
from typing import Optional, Union
from torch import Tensor, nn
from .configuration_dab_detr import DabDetrConfig
class DabDetrAttention(nn.Module):
"""
Cross-Attention used in DAB-DETR 'DAB-DETR for Fast Training Convergence' paper.
The key q_proj, k_proj, v_proj are defined outside the atte... |
class DabDetrAttention(nn.Module):
'''
Cross-Attention used in DAB-DETR 'DAB-DETR for Fast Training Convergence' paper.
The key q_proj, k_proj, v_proj are defined outside the attention. This attention allows the dim of q, k to be
different to v.
'''
def __init__(self, config: DabDetrConfig, bi... | 3 | 2 | 32 | 5 | 25 | 2 | 4 | 0.16 | 1 | 5 | 1 | 0 | 2 | 9 | 2 | 12 | 72 | 13 | 51 | 24 | 41 | 8 | 36 | 17 | 33 | 4 | 1 | 1 | 8 |
1,457 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dab_detr/modeling_dab_detr.py | transformers.models.dab_detr.modeling_dab_detr.DabDetrConvEncoder | import torch
from ...utils.backbone_utils import load_backbone
from torch import Tensor, nn
from .configuration_dab_detr import DabDetrConfig
class DabDetrConvEncoder(nn.Module):
"""
Convolutional backbone, using either the AutoBackbone API or one from the timm library.
nn.BatchNorm2d layers are replaced ... |
class DabDetrConvEncoder(nn.Module):
'''
Convolutional backbone, using either the AutoBackbone API or one from the timm library.
nn.BatchNorm2d layers are replaced by DabDetrFrozenBatchNorm2d as defined above.
'''
def __init__(self, config: DabDetrConfig):
pass
def forward(self, pixel... | 3 | 1 | 11 | 2 | 8 | 2 | 2 | 0.44 | 1 | 4 | 1 | 0 | 2 | 3 | 2 | 12 | 30 | 7 | 16 | 11 | 13 | 7 | 16 | 11 | 13 | 2 | 1 | 1 | 3 |
1,458 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dab_detr/modeling_dab_detr.py | transformers.models.dab_detr.modeling_dab_detr.DabDetrConvModel | from torch import Tensor, nn
class DabDetrConvModel(nn.Module):
"""
This module adds 2D position embeddings to all intermediate feature maps of the convolutional encoder.
"""
def __init__(self, conv_encoder, position_embedding):
super().__init__()
self.conv_encoder = conv_encoder
... |
class DabDetrConvModel(nn.Module):
'''
This module adds 2D position embeddings to all intermediate feature maps of the convolutional encoder.
'''
def __init__(self, conv_encoder, position_embedding):
pass
def forward(self, pixel_values, pixel_mask):
pass | 3 | 1 | 7 | 1 | 5 | 1 | 2 | 0.45 | 1 | 1 | 0 | 0 | 2 | 2 | 2 | 12 | 19 | 3 | 11 | 8 | 8 | 5 | 11 | 8 | 8 | 2 | 1 | 1 | 3 |
1,459 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dab_detr/modeling_dab_detr.py | transformers.models.dab_detr.modeling_dab_detr.DabDetrDecoder | from torch import Tensor, nn
from .configuration_dab_detr import DabDetrConfig
import torch
from typing import Optional, Union
from ...modeling_attn_mask_utils import _prepare_4d_attention_mask
class DabDetrDecoder(DabDetrPreTrainedModel):
"""
Transformer decoder consisting of *config.decoder_layers* layers. E... |
class DabDetrDecoder(DabDetrPreTrainedModel):
'''
Transformer decoder consisting of *config.decoder_layers* layers. Each layer is a [`DabDetrDecoderLayer`].
The decoder updates the query embeddings through multiple self-attention and cross-attention layers.
Some small tweaks for DAB-DETR:
- object_... | 3 | 2 | 93 | 13 | 62 | 18 | 10 | 0.36 | 1 | 9 | 4 | 0 | 2 | 11 | 2 | 3 | 201 | 32 | 125 | 42 | 112 | 45 | 65 | 32 | 62 | 19 | 2 | 3 | 20 |
1,460 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dab_detr/modeling_dab_detr.py | transformers.models.dab_detr.modeling_dab_detr.DabDetrDecoderLayer | import torch
from typing import Optional, Union
from .configuration_dab_detr import DabDetrConfig
from ...modeling_layers import GradientCheckpointingLayer
class DabDetrDecoderLayer(GradientCheckpointingLayer):
def __init__(self, config: DabDetrConfig, is_first: bool=False):
super().__init__()
sel... |
class DabDetrDecoderLayer(GradientCheckpointingLayer):
def __init__(self, config: DabDetrConfig, is_first: bool=False):
pass
def forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.Tensor]=None, object_queries: Optional[torch.Tensor]=None, query_position_embeddings: Optional[tor... | 3 | 1 | 32 | 3 | 18 | 11 | 2 | 0.57 | 1 | 7 | 4 | 0 | 2 | 3 | 2 | 12 | 65 | 7 | 37 | 19 | 24 | 21 | 14 | 9 | 11 | 2 | 1 | 1 | 3 |
1,461 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dab_detr/modeling_dab_detr.py | transformers.models.dab_detr.modeling_dab_detr.DabDetrDecoderLayerCrossAttention | import torch
from typing import Optional, Union
from torch import Tensor, nn
from .configuration_dab_detr import DabDetrConfig
class DabDetrDecoderLayerCrossAttention(nn.Module):
def __init__(self, config: DabDetrConfig, is_first: bool=False):
super().__init__()
hidden_size = config.hidden_size
... |
class DabDetrDecoderLayerCrossAttention(nn.Module):
def __init__(self, config: DabDetrConfig, is_first: bool=False):
pass
def forward(self, hidden_states: torch.Tensor, encoder_hidden_states: Optional[torch.Tensor]=None, query_position_embeddings: Optional[torch.Tensor]=None, object_queries: Optional... | 3 | 0 | 41 | 6 | 34 | 2 | 3 | 0.04 | 1 | 5 | 2 | 0 | 2 | 12 | 2 | 12 | 83 | 12 | 68 | 36 | 56 | 3 | 46 | 27 | 43 | 3 | 1 | 1 | 5 |
1,462 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dab_detr/modeling_dab_detr.py | transformers.models.dab_detr.modeling_dab_detr.DabDetrDecoderLayerFFN | import torch
from ...activations import ACT2FN
from torch import Tensor, nn
from .configuration_dab_detr import DabDetrConfig
class DabDetrDecoderLayerFFN(nn.Module):
def __init__(self, config: DabDetrConfig):
super().__init__()
hidden_size = config.hidden_size
self.final_layer_norm = nn.L... |
class DabDetrDecoderLayerFFN(nn.Module):
def __init__(self, config: DabDetrConfig):
pass
def forward(self, hidden_states: torch.Tensor):
pass | 3 | 0 | 10 | 1 | 10 | 0 | 1 | 0 | 1 | 3 | 1 | 0 | 2 | 7 | 2 | 12 | 22 | 2 | 20 | 12 | 17 | 0 | 20 | 12 | 17 | 1 | 1 | 0 | 2 |
1,463 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dab_detr/modeling_dab_detr.py | transformers.models.dab_detr.modeling_dab_detr.DabDetrDecoderLayerSelfAttention | import torch
from typing import Optional, Union
from torch import Tensor, nn
from .configuration_dab_detr import DabDetrConfig
class DabDetrDecoderLayerSelfAttention(nn.Module):
def __init__(self, config: DabDetrConfig):
super().__init__()
self.dropout = config.dropout
self.self_attn_query... |
class DabDetrDecoderLayerSelfAttention(nn.Module):
def __init__(self, config: DabDetrConfig):
pass
def forward(self, hidden_states: torch.Tensor, query_position_embeddings: Optional[torch.Tensor]=None, attention_mask: Optional[torch.Tensor]=None, output_attentions: Optional[bool]=None):
pass | 3 | 0 | 20 | 2 | 18 | 0 | 1 | 0 | 1 | 5 | 2 | 0 | 2 | 8 | 2 | 12 | 42 | 5 | 37 | 26 | 28 | 0 | 25 | 20 | 22 | 1 | 1 | 0 | 2 |
1,464 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dab_detr/modeling_dab_detr.py | transformers.models.dab_detr.modeling_dab_detr.DabDetrDecoderOutput | from dataclasses import dataclass
from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithCrossAttentions, Seq2SeqModelOutput
import torch
from typing import Optional, Union
from ...utils import ModelOutput, auto_docstring, logging
@dataclass
@auto_docstring(custom_intro='\n Base class for outputs of th... | @dataclass
@auto_docstring(custom_intro='\n Base class for outputs of the Conditional DETR decoder. This class adds one attribute to\n BaseModelOutputWithCrossAttentions, namely an optional stack of intermediate decoder activations, i.e. the output\n of each decoder layer, each of them gone through a layernorm... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 8.67 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 31 | 2 | 3 | 3 | 2 | 26 | 3 | 3 | 2 | 0 | 2 | 0 | 0 |
1,465 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dab_detr/modeling_dab_detr.py | transformers.models.dab_detr.modeling_dab_detr.DabDetrEncoder | from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithCrossAttentions, Seq2SeqModelOutput
from typing import Optional, Union
from ...modeling_attn_mask_utils import _prepare_4d_attention_mask
from torch import Tensor, nn
from .configuration_dab_detr import DabDetrConfig
class DabDetrEncoder(DabDetrPreTra... |
class DabDetrEncoder(DabDetrPreTrainedModel):
'''
Transformer encoder consisting of *config.encoder_layers* self attention layers. Each layer is a
[`DabDetrEncoderLayer`].
The encoder updates the flattened feature map through multiple self-attention layers.
Small tweak for DAB-DETR:
- object_qu... | 3 | 2 | 51 | 9 | 30 | 13 | 8 | 0.57 | 1 | 8 | 4 | 0 | 2 | 5 | 2 | 3 | 117 | 23 | 60 | 23 | 49 | 34 | 36 | 15 | 33 | 14 | 2 | 2 | 16 |
1,466 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dab_detr/modeling_dab_detr.py | transformers.models.dab_detr.modeling_dab_detr.DabDetrEncoderLayer | from ...activations import ACT2FN
from torch import Tensor, nn
from .configuration_dab_detr import DabDetrConfig
import torch
from ...modeling_layers import GradientCheckpointingLayer
from typing import Optional, Union
class DabDetrEncoderLayer(GradientCheckpointingLayer):
def __init__(self, config: DabDetrConfig... |
class DabDetrEncoderLayer(GradientCheckpointingLayer):
def __init__(self, config: DabDetrConfig):
pass
def forward(self, hidden_states: torch.Tensor, attention_mask: torch.Tensor, object_queries: torch.Tensor, output_attentions: Optional[bool]=None):
'''
Args:
hidden_state... | 3 | 1 | 29 | 4 | 19 | 6 | 2 | 0.31 | 1 | 5 | 2 | 0 | 2 | 8 | 2 | 12 | 59 | 8 | 39 | 20 | 30 | 12 | 28 | 14 | 25 | 2 | 1 | 1 | 3 |
1,467 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dab_detr/modeling_dab_detr.py | transformers.models.dab_detr.modeling_dab_detr.DabDetrForObjectDetection | from torch import Tensor, nn
from .configuration_dab_detr import DabDetrConfig
import torch
from typing import Optional, Union
from ...utils import ModelOutput, auto_docstring, logging
@auto_docstring(custom_intro='\n DAB_DETR Model (consisting of a backbone and encoder-decoder Transformer) with object detection he... | null | 7 | 1 | 48 | 7 | 26 | 15 | 6 | 0.55 | 1 | 8 | 4 | 0 | 3 | 6 | 3 | 4 | 157 | 24 | 86 | 37 | 67 | 47 | 40 | 23 | 36 | 17 | 2 | 2 | 19 |
1,468 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dab_detr/modeling_dab_detr.py | transformers.models.dab_detr.modeling_dab_detr.DabDetrFrozenBatchNorm2d | import torch
from torch import Tensor, nn
class DabDetrFrozenBatchNorm2d(nn.Module):
"""
BatchNorm2d where the batch statistics and the affine parameters are fixed.
Copy-paste from torchvision.misc.ops with added eps before rqsrt, without which any other models than
torchvision.models.resnet[18,34,50,... |
class DabDetrFrozenBatchNorm2d(nn.Module):
'''
BatchNorm2d where the batch statistics and the affine parameters are fixed.
Copy-paste from torchvision.misc.ops with added eps before rqsrt, without which any other models than
torchvision.models.resnet[18,34,50,101] produce nans.
'''
def __init_... | 4 | 1 | 9 | 0 | 8 | 1 | 1 | 0.28 | 1 | 1 | 0 | 0 | 3 | 0 | 3 | 13 | 37 | 5 | 25 | 13 | 19 | 7 | 21 | 11 | 17 | 2 | 1 | 1 | 4 |
1,469 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dab_detr/modeling_dab_detr.py | transformers.models.dab_detr.modeling_dab_detr.DabDetrMHAttentionMap | import torch
from typing import Optional, Union
from torch import Tensor, nn
class DabDetrMHAttentionMap(nn.Module):
"""This is a 2D attention module, which only returns the attention softmax (no multiplication by value)"""
def __init__(self, query_dim, hidden_dim, num_heads, dropout=0.0, bias=True, std=None)... |
class DabDetrMHAttentionMap(nn.Module):
'''This is a 2D attention module, which only returns the attention softmax (no multiplication by value)'''
def __init__(self, query_dim, hidden_dim, num_heads, dropout=0.0, bias=True, std=None):
pass
def forward(self, q, k, mask: Optional[Tensor]=None):
... | 3 | 1 | 11 | 2 | 10 | 0 | 2 | 0.05 | 1 | 3 | 0 | 0 | 2 | 6 | 2 | 12 | 26 | 5 | 20 | 12 | 17 | 1 | 20 | 12 | 17 | 2 | 1 | 1 | 3 |
1,470 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dab_detr/modeling_dab_detr.py | transformers.models.dab_detr.modeling_dab_detr.DabDetrMLP | from torch import Tensor, nn
class DabDetrMLP(nn.Module):
"""
Very simple multi-layer perceptron (MLP, also called FFN), used to predict the normalized center coordinates,
height and width of a bounding box w.r.t. an image.
Copied from https://github.com/facebookresearch/detr/blob/master/models/detr.p... |
class DabDetrMLP(nn.Module):
'''
Very simple multi-layer perceptron (MLP, also called FFN), used to predict the normalized center coordinates,
height and width of a bounding box w.r.t. an image.
Copied from https://github.com/facebookresearch/detr/blob/master/models/detr.py
'''
def __init__(se... | 3 | 1 | 5 | 0 | 5 | 0 | 2 | 0.5 | 1 | 3 | 0 | 0 | 2 | 2 | 2 | 12 | 19 | 4 | 10 | 7 | 7 | 5 | 10 | 7 | 7 | 3 | 1 | 1 | 4 |
1,471 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dab_detr/modeling_dab_detr.py | transformers.models.dab_detr.modeling_dab_detr.DabDetrModel | from torch import Tensor, nn
from .configuration_dab_detr import DabDetrConfig
from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithCrossAttentions, Seq2SeqModelOutput
import torch
from typing import Optional, Union
from ...utils import ModelOutput, auto_docstring, logging
@auto_docstring(custom_intro='... | null | 8 | 1 | 37 | 6 | 25 | 8 | 5 | 0.31 | 1 | 13 | 8 | 0 | 6 | 12 | 6 | 7 | 232 | 38 | 150 | 49 | 130 | 46 | 75 | 37 | 68 | 21 | 2 | 2 | 31 |
1,472 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dab_detr/modeling_dab_detr.py | transformers.models.dab_detr.modeling_dab_detr.DabDetrObjectDetectionOutput | from ...utils import ModelOutput, auto_docstring, logging
from dataclasses import dataclass
import torch
from typing import Optional, Union
@dataclass
@auto_docstring(custom_intro='\n Output type of [`DabDetrForObjectDetection`].\n ')
class DabDetrObjectDetectionOutput(ModelOutput):
"""
loss (`torch.Floa... | @dataclass
@auto_docstring(custom_intro='\n Output type of [`DabDetrForObjectDetection`].\n ')
class DabDetrObjectDetectionOutput(ModelOutput):
'''
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` are provided)):
Total loss as a linear combination of a negative log-lik... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 3.46 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 60 | 2 | 13 | 13 | 12 | 45 | 13 | 13 | 12 | 0 | 1 | 0 | 0 |
1,473 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dab_detr/modeling_dab_detr.py | transformers.models.dab_detr.modeling_dab_detr.DabDetrPreTrainedModel | from ...utils import ModelOutput, auto_docstring, logging
from ...modeling_utils import PreTrainedModel
import math
from torch import Tensor, nn
from .configuration_dab_detr import DabDetrConfig
@auto_docstring
class DabDetrPreTrainedModel(PreTrainedModel):
config: DabDetrConfig
base_model_prefix = 'model'
... | @auto_docstring
class DabDetrPreTrainedModel(PreTrainedModel):
def _init_weights(self, module):
pass | 3 | 0 | 27 | 2 | 22 | 3 | 7 | 0.11 | 1 | 2 | 2 | 4 | 1 | 0 | 1 | 1 | 33 | 3 | 27 | 10 | 25 | 3 | 25 | 10 | 23 | 7 | 1 | 2 | 7 |
1,474 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dab_detr/modeling_dab_detr.py | transformers.models.dab_detr.modeling_dab_detr.DabDetrSinePositionEmbedding | import math
import torch
from torch import Tensor, nn
from .configuration_dab_detr import DabDetrConfig
class DabDetrSinePositionEmbedding(nn.Module):
"""
This is a more standard version of the position embedding, very similar to the one used by the Attention is all you
need paper, generalized to work on i... |
class DabDetrSinePositionEmbedding(nn.Module):
'''
This is a more standard version of the position embedding, very similar to the one used by the Attention is all you
need paper, generalized to work on images.
'''
def __init__(self, config: DabDetrConfig):
pass
def forward(self, pixel... | 3 | 1 | 19 | 2 | 16 | 2 | 2 | 0.25 | 1 | 3 | 1 | 0 | 2 | 5 | 2 | 12 | 45 | 5 | 32 | 16 | 29 | 8 | 32 | 16 | 29 | 2 | 1 | 1 | 4 |
1,475 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dab_detr/modeling_dab_detr.py | transformers.models.dab_detr.modeling_dab_detr.DetrAttention | import torch
from typing import Optional, Union
from torch import Tensor, nn
from .configuration_dab_detr import DabDetrConfig
class DetrAttention(nn.Module):
"""
Multi-headed attention from 'Attention Is All You Need' paper.
Here, we add position embeddings to the queries and keys (as explained in the DE... |
class DetrAttention(nn.Module):
'''
Multi-headed attention from 'Attention Is All You Need' paper.
Here, we add position embeddings to the queries and keys (as explained in the DETR paper).
'''
def __init__(self, config: DabDetrConfig, bias: bool=True):
pass
def forward(self, hidden_s... | 3 | 2 | 34 | 5 | 28 | 1 | 4 | 0.11 | 1 | 5 | 1 | 0 | 2 | 10 | 2 | 12 | 75 | 12 | 57 | 31 | 43 | 6 | 40 | 20 | 37 | 5 | 1 | 1 | 7 |
1,476 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dac/configuration_dac.py | transformers.models.dac.configuration_dac.DacConfig | import math
import numpy as np
from ...configuration_utils import PretrainedConfig
class DacConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of an [`DacModel`]. It is used to instantiate a
Dac model according to the specified arguments, defining the model architectur... |
class DacConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of an [`DacModel`]. It is used to instantiate a
Dac model according to the specified arguments, defining the model architecture. Instantiating a configuration
with the defaults will yield a similar configu... | 4 | 1 | 17 | 2 | 16 | 0 | 1 | 1.12 | 1 | 2 | 0 | 0 | 2 | 13 | 2 | 2 | 84 | 12 | 34 | 32 | 17 | 38 | 20 | 18 | 17 | 1 | 1 | 0 | 2 |
1,477 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dac/feature_extraction_dac.py | transformers.models.dac.feature_extraction_dac.DacFeatureExtractor | from ...feature_extraction_sequence_utils import SequenceFeatureExtractor
from typing import Optional, Union
from ...feature_extraction_utils import BatchFeature
import numpy as np
from ...utils import PaddingStrategy, TensorType, logging
class DacFeatureExtractor(SequenceFeatureExtractor):
"""
Constructs an D... |
class DacFeatureExtractor(SequenceFeatureExtractor):
'''
Constructs an Dac feature extractor.
This feature extractor inherits from [`~feature_extraction_sequence_utils.SequenceFeatureExtractor`] which contains
most of the main methods. Users should refer to this superclass for more information regardin... | 3 | 2 | 61 | 7 | 37 | 17 | 9 | 0.64 | 1 | 10 | 1 | 0 | 2 | 1 | 2 | 19 | 142 | 19 | 75 | 24 | 57 | 48 | 40 | 9 | 37 | 17 | 3 | 2 | 18 |
1,478 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dac/modeling_dac.py | transformers.models.dac.modeling_dac.DacDecoder | from .configuration_dac import DacConfig
import torch.nn as nn
class DacDecoder(nn.Module):
"""DAC Decoder"""
def __init__(self, config: DacConfig):
super().__init__()
input_channel = config.hidden_size
channels = config.decoder_hidden_size
strides = config.upsampling_ratios
... |
class DacDecoder(nn.Module):
'''DAC Decoder'''
def __init__(self, config: DacConfig):
pass
def forward(self, hidden_state):
pass | 3 | 1 | 16 | 4 | 11 | 1 | 2 | 0.13 | 1 | 5 | 3 | 0 | 2 | 5 | 2 | 12 | 35 | 9 | 23 | 15 | 20 | 3 | 23 | 15 | 20 | 2 | 1 | 1 | 4 |
1,479 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dac/modeling_dac.py | transformers.models.dac.modeling_dac.DacDecoderBlock | import math
import torch.nn as nn
from .configuration_dac import DacConfig
class DacDecoderBlock(nn.Module):
"""Decoder block used in DAC decoder."""
def __init__(self, config: DacConfig, stride: int=1, stride_index: int=1):
super().__init__()
input_dim = config.decoder_hidden_size // 2 ** str... |
class DacDecoderBlock(nn.Module):
'''Decoder block used in DAC decoder.'''
def __init__(self, config: DacConfig, stride: int=1, stride_index: int=1):
pass
def forward(self, hidden_state):
pass | 3 | 1 | 13 | 2 | 11 | 0 | 1 | 0.04 | 1 | 5 | 3 | 0 | 2 | 5 | 2 | 12 | 29 | 5 | 23 | 10 | 20 | 1 | 17 | 10 | 14 | 1 | 1 | 0 | 2 |
1,480 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dac/modeling_dac.py | transformers.models.dac.modeling_dac.DacDecoderOutput | from typing import Optional
from ...utils import ModelOutput, auto_docstring
import torch
import torch.nn as nn
from dataclasses import dataclass
import torch.nn.functional as F
@dataclass
@auto_docstring
class DacDecoderOutput(ModelOutput):
"""
audio_values (`torch.FloatTensor` of shape `(batch_size, input_l... | @dataclass
@auto_docstring
class DacDecoderOutput(ModelOutput):
'''
audio_values (`torch.FloatTensor` of shape `(batch_size, input_length)`, *optional*):
Decoded audio values, obtained using the decoder part of Dac.
'''
pass | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 2.5 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 8 | 1 | 2 | 2 | 1 | 5 | 2 | 2 | 1 | 0 | 1 | 0 | 0 |
1,481 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dac/modeling_dac.py | transformers.models.dac.modeling_dac.DacEncoder | import torch.nn as nn
from .configuration_dac import DacConfig
class DacEncoder(nn.Module):
"""DAC Encoder"""
def __init__(self, config: DacConfig):
super().__init__()
strides = config.downsampling_ratios
self.conv1 = nn.Conv1d(1, config.encoder_hidden_size, kernel_size=7, padding=3)
... |
class DacEncoder(nn.Module):
'''DAC Encoder'''
def __init__(self, config: DacConfig):
pass
def forward(self, hidden_state):
pass | 3 | 1 | 14 | 3 | 10 | 1 | 2 | 0.15 | 1 | 5 | 3 | 0 | 2 | 4 | 2 | 12 | 31 | 8 | 20 | 11 | 17 | 3 | 20 | 11 | 17 | 2 | 1 | 1 | 4 |
1,482 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dac/modeling_dac.py | transformers.models.dac.modeling_dac.DacEncoderBlock | import math
import torch.nn as nn
from .configuration_dac import DacConfig
class DacEncoderBlock(nn.Module):
"""Encoder block used in DAC encoder."""
def __init__(self, config: DacConfig, stride: int=1, stride_index: int=1):
super().__init__()
dimension = config.encoder_hidden_size * 2 ** stri... |
class DacEncoderBlock(nn.Module):
'''Encoder block used in DAC encoder.'''
def __init__(self, config: DacConfig, stride: int=1, stride_index: int=1):
pass
def forward(self, hidden_state):
pass | 3 | 1 | 9 | 1 | 8 | 0 | 1 | 0.06 | 1 | 5 | 3 | 0 | 2 | 5 | 2 | 12 | 22 | 4 | 17 | 9 | 14 | 1 | 15 | 9 | 12 | 1 | 1 | 0 | 2 |
1,483 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dac/modeling_dac.py | transformers.models.dac.modeling_dac.DacEncoderOutput | import torch.nn.functional as F
from ...utils import ModelOutput, auto_docstring
from typing import Optional
import torch
from dataclasses import dataclass
import torch.nn as nn
@dataclass
@auto_docstring
class DacEncoderOutput(ModelOutput):
"""
loss (`torch.Tensor`):
Loss from the encoder model, compr... | @dataclass
@auto_docstring
class DacEncoderOutput(ModelOutput):
'''
loss (`torch.Tensor`):
Loss from the encoder model, comprising the weighted combination of the commitment and codebook losses.
quantized_representation (`torch.Tensor` of shape `(batch_size, dimension, time_steps)`, *optional*):
... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 2.2 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 17 | 1 | 5 | 5 | 4 | 11 | 5 | 5 | 4 | 0 | 1 | 0 | 0 |
1,484 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dac/modeling_dac.py | transformers.models.dac.modeling_dac.DacModel | import torch.nn as nn
import torch
import math
from .configuration_dac import DacConfig
from typing import Optional
from ...utils import ModelOutput, auto_docstring
import torch.nn.functional as F
@auto_docstring(custom_intro='\n The DAC (Descript Audio Codec) model.\n ')
class DacModel(DacPreTrainedModel):
... | @auto_docstring(custom_intro='\n The DAC (Descript Audio Codec) model.\n ')
class DacModel(DacPreTrainedModel):
def __init__(self, config: DacConfig):
pass
@auto_docstring
def encode(self, input_values: torch.Tensor, n_quantizers: Optional[int]=None, return_dict: Optional[bool]=None):
... | 9 | 3 | 31 | 6 | 14 | 11 | 3 | 0.73 | 1 | 12 | 7 | 0 | 4 | 5 | 4 | 7 | 132 | 28 | 60 | 35 | 36 | 44 | 37 | 17 | 32 | 5 | 2 | 1 | 13 |
1,485 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dac/modeling_dac.py | transformers.models.dac.modeling_dac.DacOutput | import torch.nn.functional as F
from ...utils import ModelOutput, auto_docstring
import torch.nn as nn
from typing import Optional
from dataclasses import dataclass
import torch
@dataclass
@auto_docstring
class DacOutput(ModelOutput):
"""
loss (`torch.Tensor`):
Loss from the encoder model, comprising t... | @dataclass
@auto_docstring
class DacOutput(ModelOutput):
'''
loss (`torch.Tensor`):
Loss from the encoder model, comprising the weighted combination of the commitment and codebook losses.
audio_values (`torch.Tensor` of shape `(batch_size, input_length)`):
Reconstructed audio data.
quant... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 2.17 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 20 | 1 | 6 | 6 | 5 | 13 | 6 | 6 | 5 | 0 | 1 | 0 | 0 |
1,486 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dac/modeling_dac.py | transformers.models.dac.modeling_dac.DacPreTrainedModel | from ...modeling_utils import PreTrainedAudioTokenizerBase
from .configuration_dac import DacConfig
from ...utils import ModelOutput, auto_docstring
import torch.nn as nn
@auto_docstring
class DacPreTrainedModel(PreTrainedAudioTokenizerBase):
config: DacConfig
base_model_prefix = 'dac'
main_input_name = 'i... | @auto_docstring
class DacPreTrainedModel(PreTrainedAudioTokenizerBase):
def _init_weights(self, module):
pass
def apply_weight_norm(self):
pass
def remove_weight_norm(self):
pass | 5 | 0 | 21 | 3 | 18 | 0 | 4 | 0.05 | 1 | 0 | 0 | 1 | 3 | 0 | 3 | 3 | 75 | 13 | 59 | 10 | 55 | 3 | 59 | 10 | 55 | 5 | 1 | 1 | 11 |
1,487 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dac/modeling_dac.py | transformers.models.dac.modeling_dac.DacResidualUnit | import torch.nn as nn
class DacResidualUnit(nn.Module):
"""
A residual unit composed of Snake1d and weight-normalized Conv1d layers with dilations.
"""
def __init__(self, dimension: int=16, dilation: int=1):
super().__init__()
pad = (7 - 1) * dilation // 2
self.snake1 = Snake1d... |
class DacResidualUnit(nn.Module):
'''
A residual unit composed of Snake1d and weight-normalized Conv1d layers with dilations.
'''
def __init__(self, dimension: int=16, dilation: int=1):
pass
def forward(self, hidden_state):
'''
Forward pass through the residual unit.
... | 3 | 2 | 15 | 2 | 8 | 5 | 2 | 0.71 | 1 | 3 | 1 | 0 | 2 | 4 | 2 | 12 | 35 | 6 | 17 | 10 | 14 | 12 | 17 | 10 | 14 | 2 | 1 | 1 | 3 |
1,488 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dac/modeling_dac.py | transformers.models.dac.modeling_dac.DacResidualVectorQuantize | import torch.nn as nn
import numpy as np
from .configuration_dac import DacConfig
import torch
import torch.nn.functional as F
from typing import Optional
class DacResidualVectorQuantize(nn.Module):
"""
ResidualVectorQuantize block - Introduced in SoundStream: An end2end neural audio codec (https://huggingface... |
class DacResidualVectorQuantize(nn.Module):
'''
ResidualVectorQuantize block - Introduced in SoundStream: An end2end neural audio codec (https://huggingface.co/papers/2107.03312)
'''
def __init__(self, config: DacConfig):
pass
def forward(self, hidden_state, n_quantizers: Optional[int]=No... | 5 | 4 | 32 | 5 | 15 | 12 | 3 | 0.79 | 1 | 7 | 2 | 0 | 4 | 3 | 4 | 14 | 136 | 25 | 62 | 36 | 57 | 49 | 60 | 36 | 55 | 5 | 1 | 2 | 10 |
1,489 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dac/modeling_dac.py | transformers.models.dac.modeling_dac.DacVectorQuantize | import torch.nn as nn
from .configuration_dac import DacConfig
import torch.nn.functional as F
class DacVectorQuantize(nn.Module):
"""
Implementation of VQ similar to Karpathy's repo (https://github.com/karpathy/deep-vector-quantization)
Additionally uses following tricks from improved VQGAN
(https://... |
class DacVectorQuantize(nn.Module):
'''
Implementation of VQ similar to Karpathy's repo (https://github.com/karpathy/deep-vector-quantization)
Additionally uses following tricks from improved VQGAN
(https://huggingface.co/papers/2110.04627):
1. Factorized codes: Perform nearest neighbor lookup ... | 4 | 2 | 18 | 3 | 8 | 7 | 1 | 1.15 | 1 | 2 | 1 | 0 | 3 | 3 | 3 | 13 | 68 | 13 | 26 | 18 | 22 | 30 | 26 | 18 | 22 | 1 | 1 | 0 | 3 |
1,490 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/dac/modeling_dac.py | transformers.models.dac.modeling_dac.Snake1d | import torch.nn as nn
import torch
import torch.nn.functional as F
class Snake1d(nn.Module):
"""
A 1-dimensional Snake activation function module.
"""
def __init__(self, hidden_dim):
super().__init__()
self.alpha = nn.Parameter(torch.ones(1, hidden_dim, 1))
def forward(self, hidde... |
class Snake1d(nn.Module):
'''
A 1-dimensional Snake activation function module.
'''
def __init__(self, hidden_dim):
pass
def forward(self, hidden_states):
pass | 3 | 1 | 5 | 0 | 5 | 0 | 1 | 0.3 | 1 | 1 | 0 | 0 | 2 | 1 | 2 | 12 | 15 | 2 | 10 | 5 | 7 | 3 | 10 | 5 | 7 | 1 | 1 | 0 | 2 |
1,491 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/data2vec/configuration_data2vec_audio.py | transformers.models.data2vec.configuration_data2vec_audio.Data2VecAudioConfig | import math
from ...configuration_utils import PretrainedConfig
class Data2VecAudioConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`Data2VecAudioModel`]. It is used to instantiate
an Data2VecAudio model according to the specified arguments, defining the model ... | null | 4 | 1 | 58 | 3 | 52 | 3 | 2 | 1.27 | 1 | 3 | 0 | 0 | 2 | 42 | 2 | 2 | 260 | 17 | 107 | 94 | 56 | 136 | 50 | 46 | 47 | 2 | 1 | 1 | 3 |
1,492 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/data2vec/configuration_data2vec_text.py | transformers.models.data2vec.configuration_data2vec_text.Data2VecTextConfig | from ...configuration_utils import PretrainedConfig
class Data2VecTextConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`Data2VecTextModel`] and [`Data2VecTextModel`]. It
is used to instantiate a Data2VecText model according to the specified arguments, defining ... |
class Data2VecTextConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`Data2VecTextModel`] and [`Data2VecTextModel`]. It
is used to instantiate a Data2VecText model according to the specified arguments, defining the model architecture.
Instantiating a configur... | 2 | 1 | 39 | 1 | 38 | 0 | 1 | 1.45 | 1 | 1 | 0 | 0 | 1 | 15 | 1 | 1 | 109 | 11 | 40 | 39 | 17 | 58 | 19 | 18 | 17 | 1 | 1 | 0 | 1 |
1,493 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/data2vec/configuration_data2vec_text.py | transformers.models.data2vec.configuration_data2vec_text.Data2VecTextOnnxConfig | from collections import OrderedDict
from collections.abc import Mapping
from ...onnx import OnnxConfig
class Data2VecTextOnnxConfig(OnnxConfig):
@property
def inputs(self) -> Mapping[str, Mapping[int, str]]:
if self.task == 'multiple-choice':
dynamic_axis = {0: 'batch', 1: 'choice', 2: 'se... |
class Data2VecTextOnnxConfig(OnnxConfig):
@property
def inputs(self) -> Mapping[str, Mapping[int, str]]:
pass | 3 | 0 | 11 | 0 | 11 | 0 | 2 | 0 | 1 | 3 | 0 | 0 | 1 | 0 | 1 | 1 | 13 | 0 | 13 | 4 | 10 | 0 | 6 | 3 | 4 | 2 | 1 | 1 | 2 |
1,494 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/data2vec/configuration_data2vec_vision.py | transformers.models.data2vec.configuration_data2vec_vision.Data2VecVisionConfig | from ...configuration_utils import PretrainedConfig
class Data2VecVisionConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`Data2VecVisionModel`]. It is used to instantiate
an Data2VecVision model according to the specified arguments, defining the model architect... |
class Data2VecVisionConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`Data2VecVisionModel`]. It is used to instantiate
an Data2VecVision model according to the specified arguments, defining the model architecture. Instantiating a
configuration with the defa... | 2 | 1 | 63 | 2 | 59 | 2 | 1 | 1.21 | 1 | 1 | 0 | 0 | 1 | 27 | 1 | 1 | 145 | 10 | 61 | 60 | 29 | 74 | 31 | 30 | 29 | 1 | 1 | 0 | 1 |
1,495 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/data2vec/configuration_data2vec_vision.py | transformers.models.data2vec.configuration_data2vec_vision.Data2VecVisionOnnxConfig | from collections import OrderedDict
from ...onnx import OnnxConfig
from packaging import version
from collections.abc import Mapping
class Data2VecVisionOnnxConfig(OnnxConfig):
torch_onnx_minimum_version = version.parse('1.11')
@property
def inputs(self) -> Mapping[str, Mapping[int, str]]:
return ... |
class Data2VecVisionOnnxConfig(OnnxConfig):
@property
def inputs(self) -> Mapping[str, Mapping[int, str]]:
pass
@property
def atol_for_validation(self) -> float:
pass | 5 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 1 | 4 | 0 | 0 | 2 | 0 | 2 | 2 | 14 | 2 | 12 | 6 | 7 | 0 | 6 | 4 | 3 | 1 | 1 | 0 | 2 |
1,496 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/data2vec/modeling_data2vec_audio.py | transformers.models.data2vec.modeling_data2vec_audio.Data2VecAudioAdapter | import numpy as np
from torch import nn
class Data2VecAudioAdapter(nn.Module):
def __init__(self, config):
super().__init__()
if config.output_hidden_size != config.hidden_size:
self.proj = nn.Linear(config.hidden_size, config.output_hidden_size)
self.proj_layer_norm = nn.L... |
class Data2VecAudioAdapter(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states):
pass | 3 | 0 | 14 | 3 | 10 | 1 | 3 | 0.1 | 1 | 3 | 1 | 0 | 2 | 4 | 2 | 12 | 29 | 6 | 21 | 9 | 18 | 2 | 20 | 9 | 17 | 4 | 1 | 2 | 6 |
1,497 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/data2vec/modeling_data2vec_audio.py | transformers.models.data2vec.modeling_data2vec_audio.Data2VecAudioAdapterLayer | from torch import nn
class Data2VecAudioAdapterLayer(nn.Module):
def __init__(self, config):
super().__init__()
self.conv = nn.Conv1d(config.output_hidden_size, 2 * config.output_hidden_size, config.adapter_kernel_size, stride=config.adapter_stride, padding=1)
def forward(self, hidden_states)... |
class Data2VecAudioAdapterLayer(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states):
pass | 3 | 0 | 7 | 1 | 7 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 2 | 1 | 2 | 12 | 16 | 2 | 14 | 4 | 11 | 0 | 8 | 4 | 5 | 1 | 1 | 0 | 2 |
1,498 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/data2vec/modeling_data2vec_audio.py | transformers.models.data2vec.modeling_data2vec_audio.Data2VecAudioAttention | from ...modeling_flash_attention_utils import FlashAttentionKwargs
import torch
from .configuration_data2vec_audio import Data2VecAudioConfig
from typing import Callable, Optional, Union
from ...processing_utils import Unpack
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
from torch import nn
c... |
class Data2VecAudioAttention(nn.Module):
'''Multi-headed attention from 'Attention Is All You Need' paper'''
def __init__(self, embed_dim: int, num_heads: int, dropout: float=0.0, is_decoder: bool=False, bias: bool=True, is_causal: bool=False, config: Optional[Data2VecAudioConfig]=None):
pass
def... | 3 | 2 | 50 | 7 | 35 | 8 | 5 | 0.24 | 1 | 7 | 1 | 2 | 3 | 12 | 3 | 13 | 156 | 23 | 107 | 44 | 86 | 26 | 68 | 27 | 64 | 12 | 1 | 2 | 15 |
1,499 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/data2vec/modeling_data2vec_audio.py | transformers.models.data2vec.modeling_data2vec_audio.Data2VecAudioConvLayer | from ...activations import ACT2FN
from torch import nn
from ...modeling_layers import GradientCheckpointingLayer
class Data2VecAudioConvLayer(GradientCheckpointingLayer):
def __init__(self, config, layer_id=0):
super().__init__()
self.in_conv_dim = config.conv_dim[layer_id - 1] if layer_id > 0 els... |
class Data2VecAudioConvLayer(GradientCheckpointingLayer):
def __init__(self, config, layer_id=0):
pass
def forward(self, hidden_states):
pass | 3 | 0 | 12 | 2 | 10 | 0 | 2 | 0 | 1 | 1 | 0 | 0 | 2 | 5 | 2 | 12 | 25 | 4 | 21 | 8 | 18 | 0 | 15 | 8 | 12 | 2 | 1 | 0 | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.