text stringlengths 31 243k | type stringclasses 1
value | start int64 36 275k | end int64 286 280k | depth int64 0 1 | filepath stringlengths 85 188 | parent_class stringclasses 3
values | class_index int64 0 10.8k |
|---|---|---|---|---|---|---|---|
class Gemma2DecoderLayer(nn.Module):
def __init__(self, config: Gemma2Config, layer_idx: int):
super().__init__()
self.hidden_size = config.hidden_size
self.config = config
self.is_sliding = not bool(layer_idx % 2)
self.self_attn = Gemma2Attention(config=config, layer_idx=lay... | class_definition | 13,177 | 16,423 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/gemma2/modular_gemma2.py | null | 4,000 |
class Gemma2Model(GemmaModel):
def __init__(self, config: Gemma2Config):
super().__init__(config)
self.layers = nn.ModuleList(
[Gemma2DecoderLayer(config, layer_idx) for layer_idx in range(config.num_hidden_layers)]
)
def forward(
self,
input_ids: torch.LongT... | class_definition | 16,426 | 23,178 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/gemma2/modular_gemma2.py | null | 4,001 |
class Gemma2ForCausalLM(GemmaForCausalLM):
def __init__(self, config):
super().__init__(config)
self.model = Gemma2Model(config)
self.post_init()
def forward(
self,
input_ids: torch.LongTensor = None,
attention_mask: Optional[torch.Tensor] = None,
positio... | class_definition | 23,181 | 30,775 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/gemma2/modular_gemma2.py | null | 4,002 |
class Gemma2ForSequenceClassification(GemmaForSequenceClassification):
def __init__(self, config):
super().__init__(config)
self.model = Gemma2Model(config)
self.post_init() | class_definition | 30,778 | 30,979 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/gemma2/modular_gemma2.py | null | 4,003 |
class Gemma2ForTokenClassification(GemmaForTokenClassification):
def __init__(self, config):
super().__init__(config)
self.model = Gemma2Model(config)
self.post_init() | class_definition | 30,982 | 31,177 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/gemma2/modular_gemma2.py | null | 4,004 |
class MixtralBlockSparseTop2MLP(nn.Module):
def __init__(self, config: MixtralConfig):
super().__init__()
self.ffn_dim = config.intermediate_size
self.hidden_dim = config.hidden_size
self.w1 = nn.Linear(self.hidden_dim, self.ffn_dim, bias=False)
self.w2 = nn.Linear(self.ffn_... | class_definition | 2,944 | 3,649 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mixtral/modeling_mixtral.py | null | 4,005 |
class MixtralSparseMoeBlock(nn.Module):
"""
This implementation is
strictly equivalent to standard MoE with full capacity (no
dropped tokens). It's faster since it formulates MoE operations
in terms of block-sparse operations to accommodate imbalanced
assignments of tokens to experts, whereas st... | class_definition | 3,652 | 7,059 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mixtral/modeling_mixtral.py | null | 4,006 |
class MixtralRMSNorm(nn.Module):
def __init__(self, hidden_size, eps=1e-6):
"""
MixtralRMSNorm is equivalent to T5LayerNorm
"""
super().__init__()
self.weight = nn.Parameter(torch.ones(hidden_size))
self.variance_epsilon = eps
def forward(self, hidden_states):
... | class_definition | 7,062 | 7,786 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mixtral/modeling_mixtral.py | null | 4,007 |
class MixtralAttention(nn.Module):
"""Multi-headed attention from 'Attention Is All You Need' paper"""
def __init__(self, config: MixtralConfig, layer_idx: int):
super().__init__()
self.config = config
self.layer_idx = layer_idx
self.head_dim = getattr(config, "head_dim", config... | class_definition | 11,065 | 14,580 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mixtral/modeling_mixtral.py | null | 4,008 |
class MixtralDecoderLayer(nn.Module):
def __init__(self, config: MixtralConfig, layer_idx: int):
super().__init__()
self.hidden_size = config.hidden_size
self.self_attn = MixtralAttention(config, layer_idx)
self.block_sparse_moe = MixtralSparseMoeBlock(config)
self.input_la... | class_definition | 14,583 | 18,279 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mixtral/modeling_mixtral.py | null | 4,009 |
class MixtralRotaryEmbedding(nn.Module):
def __init__(self, config: MixtralConfig, device=None):
super().__init__()
# BC: "rope_type" was originally "type"
if hasattr(config, "rope_scaling") and config.rope_scaling is not None:
self.rope_type = config.rope_scaling.get("rope_type"... | class_definition | 18,282 | 21,481 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mixtral/modeling_mixtral.py | null | 4,010 |
class MixtralPreTrainedModel(PreTrainedModel):
config_class = MixtralConfig
base_model_prefix = "model"
supports_gradient_checkpointing = True
_no_split_modules = ["MixtralDecoderLayer"]
_skip_keys_device_placement = ["past_key_values"]
_supports_flash_attn_2 = True
_supports_sdpa = True
... | class_definition | 22,511 | 23,440 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mixtral/modeling_mixtral.py | null | 4,011 |
class MixtralModel(MixtralPreTrainedModel):
"""
Transformer decoder consisting of *config.num_hidden_layers* layers. Each layer is a [`MixtralDecoderLayer`]
Args:
config: MixtralConfig
"""
def __init__(self, config: MixtralConfig):
super().__init__(config)
self.padding_idx ... | class_definition | 28,250 | 41,937 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mixtral/modeling_mixtral.py | null | 4,012 |
class KwargsForCausalLM(FlashAttentionKwargs, LossKwargs): ... | class_definition | 41,940 | 42,002 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mixtral/modeling_mixtral.py | null | 4,013 |
class MixtralForCausalLM(MixtralPreTrainedModel, GenerationMixin):
_tied_weights_keys = ["lm_head.weight"]
_tp_plan = {"lm_head": "colwise_rep"}
def __init__(self, config):
super().__init__(config)
self.model = MixtralModel(config)
self.vocab_size = config.vocab_size
self.lm... | class_definition | 45,502 | 51,659 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mixtral/modeling_mixtral.py | null | 4,014 |
class MixtralForSequenceClassification(MixtralPreTrainedModel):
def __init__(self, config):
super().__init__(config)
self.num_labels = config.num_labels
self.model = MixtralModel(config)
self.score = nn.Linear(config.hidden_size, self.num_labels, bias=False)
# Initialize wei... | class_definition | 52,458 | 56,278 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mixtral/modeling_mixtral.py | null | 4,015 |
class MixtralForTokenClassification(MixtralPreTrainedModel):
def __init__(self, config):
super().__init__(config)
self.num_labels = config.num_labels
self.model = MixtralModel(config)
if getattr(config, "classifier_dropout", None) is not None:
classifier_dropout = config.... | class_definition | 56,529 | 59,749 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mixtral/modeling_mixtral.py | null | 4,016 |
class MixtralForQuestionAnswering(MixtralPreTrainedModel):
base_model_prefix = "model"
def __init__(self, config):
super().__init__(config)
self.qa_outputs = nn.Linear(config.hidden_size, 2)
self.model = MixtralModel(config) # diff with Llama: transformer->model
# Initialize w... | class_definition | 60,049 | 63,458 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mixtral/modeling_mixtral.py | null | 4,017 |
class MixtralConfig(PretrainedConfig):
r"""
This is the configuration class to store the configuration of a [`MixtralModel`]. It is used to instantiate an
Mixtral model according to the specified arguments, defining the model architecture. Instantiating a configuration
with the defaults will yield a sim... | class_definition | 799 | 8,365 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mixtral/configuration_mixtral.py | null | 4,018 |
class MixtralBlockSparseTop2MLP(nn.Module):
def __init__(self, config: MixtralConfig):
super().__init__()
self.ffn_dim = config.intermediate_size
self.hidden_dim = config.hidden_size
self.w1 = nn.Linear(self.hidden_dim, self.ffn_dim, bias=False)
self.w2 = nn.Linear(self.ffn_... | class_definition | 5,344 | 6,049 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mixtral/modular_mixtral.py | null | 4,019 |
class MixtralSparseMoeBlock(nn.Module):
"""
This implementation is
strictly equivalent to standard MoE with full capacity (no
dropped tokens). It's faster since it formulates MoE operations
in terms of block-sparse operations to accommodate imbalanced
assignments of tokens to experts, whereas st... | class_definition | 6,052 | 9,459 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mixtral/modular_mixtral.py | null | 4,020 |
class MixtralRMSNorm(MistralRMSNorm):
pass | class_definition | 9,462 | 9,508 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mixtral/modular_mixtral.py | null | 4,021 |
class MixtralAttention(MistralAttention):
pass | class_definition | 9,511 | 9,561 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mixtral/modular_mixtral.py | null | 4,022 |
class MixtralDecoderLayer(nn.Module):
def __init__(self, config: MixtralConfig, layer_idx: int):
super().__init__()
self.hidden_size = config.hidden_size
self.self_attn = MixtralAttention(config, layer_idx)
self.block_sparse_moe = MixtralSparseMoeBlock(config)
self.input_la... | class_definition | 9,564 | 13,260 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mixtral/modular_mixtral.py | null | 4,023 |
class MixtralModel(MistralModel):
def __init__(self, config: MixtralConfig):
super().__init__(config)
self.layers = nn.ModuleList(
[MixtralDecoderLayer(config, layer_idx) for layer_idx in range(config.num_hidden_layers)]
)
def forward(
self,
input_ids: torch.... | class_definition | 13,263 | 18,398 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mixtral/modular_mixtral.py | null | 4,024 |
class KwargsForCausalLM(FlashAttentionKwargs, LossKwargs): ... | class_definition | 18,401 | 18,463 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mixtral/modular_mixtral.py | null | 4,025 |
class MixtralForCausalLM(MistralForCausalLM):
_tied_weights_keys = ["lm_head.weight"]
def __init__(self, config):
super().__init__(config)
self.model = MixtralModel(config)
self.router_aux_loss_coef = config.router_aux_loss_coef
self.num_experts = config.num_local_experts
... | class_definition | 18,466 | 23,749 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mixtral/modular_mixtral.py | null | 4,026 |
class MixtralForSequenceClassification(MistralForSequenceClassification):
pass | class_definition | 23,752 | 23,834 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mixtral/modular_mixtral.py | null | 4,027 |
class MixtralForTokenClassification(MistralForTokenClassification):
pass | class_definition | 23,837 | 23,913 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mixtral/modular_mixtral.py | null | 4,028 |
class MixtralForQuestionAnswering(MistralForQuestionAnswering):
pass | class_definition | 23,916 | 23,988 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mixtral/modular_mixtral.py | null | 4,029 |
class Pix2StructTextConfig(PretrainedConfig):
r"""
This is the configuration class to store the configuration of a [`Pix2StructTextModel`]. It is used to instantiate
a Pix2Struct text model according to the specified arguments, defining the model architecture. Instantiating a
configuration with the defa... | class_definition | 787 | 6,400 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pix2struct/configuration_pix2struct.py | null | 4,030 |
class Pix2StructVisionConfig(PretrainedConfig):
r"""
This is the configuration class to store the configuration of a [`Pix2StructVisionModel`]. It is used to
instantiate a Pix2Struct vision model according to the specified arguments, defining the model architecture.
Instantiating a configuration default... | class_definition | 6,403 | 11,292 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pix2struct/configuration_pix2struct.py | null | 4,031 |
class Pix2StructConfig(PretrainedConfig):
r"""
[`Pix2StructConfig`] is the configuration class to store the configuration of a
[`Pix2StructForConditionalGeneration`]. It is used to instantiate a Pix2Struct model according to the specified
arguments, defining the text model and vision model configs. Inst... | class_definition | 11,295 | 15,719 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pix2struct/configuration_pix2struct.py | null | 4,032 |
class Pix2StructImagesKwargs(ImagesKwargs, total=False):
max_patches: Optional[int]
header_text: Optional[Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]]] | class_definition | 942 | 1,134 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pix2struct/processing_pix2struct.py | null | 4,033 |
class Pix2StructProcessorKwargs(ProcessingKwargs, total=False):
images_kwargs: Pix2StructImagesKwargs
_defaults = {
"text_kwargs": {
"add_special_tokens": True,
"padding": False,
"stride": 0,
"return_overflowing_tokens": False,
"return_special_... | class_definition | 1,137 | 1,719 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pix2struct/processing_pix2struct.py | null | 4,034 |
class Pix2StructProcessor(ProcessorMixin):
r"""
Constructs a PIX2STRUCT processor which wraps a BERT tokenizer and PIX2STRUCT image processor into a single
processor.
[`Pix2StructProcessor`] offers all the functionalities of [`Pix2StructImageProcessor`] and [`T5TokenizerFast`]. See
the docstring of... | class_definition | 1,762 | 6,875 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pix2struct/processing_pix2struct.py | null | 4,035 |
class Pix2StructLayerNorm(nn.Module):
def __init__(self, hidden_size, eps=1e-6):
"""
Construct a layernorm module in the T5 style. No bias and no subtraction of mean.
"""
super().__init__()
self.weight = nn.Parameter(torch.ones(hidden_size))
self.variance_epsilon = ep... | class_definition | 1,796 | 2,897 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pix2struct/modeling_pix2struct.py | null | 4,036 |
class Pix2StructVisionEmbeddings(nn.Module):
r"""
Construct the embeddings from patch. In `Pix2Struct` the input is different from classic Vision-transformer models.
Here the input is a sequence of `seq_len` flattened patches that also combines padding patches (tokens). Each patch
is represented by a ve... | class_definition | 3,357 | 4,885 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pix2struct/modeling_pix2struct.py | null | 4,037 |
class Pix2StructVisionAttention(nn.Module):
def __init__(self, config):
super().__init__()
self.hidden_size = config.hidden_size
self.key_value_proj_dim = config.d_kv
self.n_heads = config.num_attention_heads
self.dropout = config.attention_dropout
self.inner_dim = se... | class_definition | 4,888 | 8,980 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pix2struct/modeling_pix2struct.py | null | 4,038 |
class Pix2StructVisionMlp(nn.Module):
def __init__(self, config: Pix2StructVisionConfig):
super().__init__()
self.wi_0 = nn.Linear(config.hidden_size, config.d_ff, bias=False)
self.wi_1 = nn.Linear(config.hidden_size, config.d_ff, bias=False)
self.wo = nn.Linear(config.d_ff, config.h... | class_definition | 9,195 | 10,507 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pix2struct/modeling_pix2struct.py | null | 4,039 |
class Pix2StructVisionLayer(nn.Module):
def __init__(self, config: Pix2StructConfig) -> None:
super().__init__()
self.chunk_size_feed_forward = config.chunk_size_feed_forward
self.seq_len_dim = 1
self.attention = Pix2StructVisionAttention(config)
self.mlp = Pix2StructVisionMl... | class_definition | 10,510 | 12,272 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pix2struct/modeling_pix2struct.py | null | 4,040 |
class Pix2StructVisionEncoder(nn.Module):
def __init__(self, config: Pix2StructConfig) -> None:
super().__init__()
self.config = config
self.layer = nn.ModuleList([Pix2StructVisionLayer(config) for _ in range(config.num_hidden_layers)])
self.gradient_checkpointing = False
def fo... | class_definition | 12,275 | 14,336 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pix2struct/modeling_pix2struct.py | null | 4,041 |
class Pix2StructPreTrainedModel(PreTrainedModel):
"""
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
models.
"""
config_class = Pix2StructConfig
_supports_cache_class = True
_supports_static_cache = False
@property
d... | class_definition | 14,339 | 20,717 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pix2struct/modeling_pix2struct.py | null | 4,042 |
class Pix2StructVisionModel(Pix2StructPreTrainedModel):
config_class = Pix2StructVisionConfig
main_input_name = "flattened_patches"
supports_gradient_checkpointing = True
_no_split_modules = ["Pix2StructVisionLayer"]
def __init__(self, config: Pix2StructConfig):
super().__init__(config)
... | class_definition | 23,055 | 27,395 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pix2struct/modeling_pix2struct.py | null | 4,043 |
class Pix2StructTextDenseGatedActDense(nn.Module):
def __init__(self, config: Pix2StructTextConfig):
super().__init__()
self.wi_0 = nn.Linear(config.hidden_size, config.d_ff, bias=False)
self.wi_1 = nn.Linear(config.hidden_size, config.d_ff, bias=False)
self.wo = nn.Linear(config.d_f... | class_definition | 27,513 | 28,836 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pix2struct/modeling_pix2struct.py | null | 4,044 |
class Pix2StructTextLayerFF(nn.Module):
def __init__(self, config: Pix2StructTextConfig):
super().__init__()
self.DenseReluDense = Pix2StructTextDenseGatedActDense(config)
self.layer_norm = Pix2StructLayerNorm(config.hidden_size, eps=config.layer_norm_epsilon)
self.dropout = nn.Drop... | class_definition | 28,839 | 29,516 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pix2struct/modeling_pix2struct.py | null | 4,045 |
class Pix2StructTextAttention(nn.Module):
def __init__(
self, config: Pix2StructTextConfig, has_relative_attention_bias=False, layer_idx: Optional[int] = None
):
super().__init__()
self.has_relative_attention_bias = has_relative_attention_bias
self.relative_attention_num_buckets ... | class_definition | 29,519 | 40,288 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pix2struct/modeling_pix2struct.py | null | 4,046 |
class Pix2StructTextLayerSelfAttention(nn.Module):
def __init__(self, config, has_relative_attention_bias=False, layer_idx: Optional[int] = None):
super().__init__()
self.attention = Pix2StructTextAttention(
config, has_relative_attention_bias=has_relative_attention_bias, layer_idx=layer... | class_definition | 40,561 | 41,939 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pix2struct/modeling_pix2struct.py | null | 4,047 |
class Pix2StructTextLayerCrossAttention(nn.Module):
def __init__(self, config, layer_idx: Optional[int] = None):
super().__init__()
self.attention = Pix2StructTextAttention(config, has_relative_attention_bias=False, layer_idx=layer_idx)
self.layer_norm = Pix2StructLayerNorm(config.hidden_siz... | class_definition | 42,217 | 43,654 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pix2struct/modeling_pix2struct.py | null | 4,048 |
class Pix2StructTextBlock(nn.Module):
def __init__(self, config, has_relative_attention_bias=False, layer_idx: Optional[int] = None):
super().__init__()
self.self_attention = Pix2StructTextLayerSelfAttention(
config,
has_relative_attention_bias=has_relative_attention_bias,
... | class_definition | 43,657 | 47,297 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pix2struct/modeling_pix2struct.py | null | 4,049 |
class Pix2StructTextModel(Pix2StructPreTrainedModel):
config_class = Pix2StructTextConfig
_no_split_modules = ["Pix2StructTextBlock"]
_tied_weights_keys = ["lm_head.weight"]
supports_gradient_checkpointing = True
def __init__(self, config):
super().__init__(config)
self.embed_tokens... | class_definition | 60,673 | 80,864 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pix2struct/modeling_pix2struct.py | null | 4,050 |
class Pix2StructForConditionalGeneration(Pix2StructPreTrainedModel, GenerationMixin):
config_class = Pix2StructConfig
main_input_name = "flattened_patches"
_tied_weights_keys = ["decoder.lm_head.weight"]
def __init__(self, config: Pix2StructConfig):
super().__init__(config)
self.encode... | class_definition | 81,036 | 88,496 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pix2struct/modeling_pix2struct.py | null | 4,051 |
class Pix2StructImageProcessor(BaseImageProcessor):
r"""
Constructs a Pix2Struct image processor.
Args:
do_convert_rgb (`bool`, *optional*, defaults to `True`):
Whether to convert the image to RGB.
do_normalize (`bool`, *optional*, defaults to `True`):
Whether to nor... | class_definition | 7,309 | 19,727 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pix2struct/image_processing_pix2struct.py | null | 4,052 |
class ConditionalDetrFeatureExtractor(ConditionalDetrImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn(
"The class ConditionalDetrFeatureExtractor is deprecated and will be removed in version 5 of Transformers."
" Please use ConditionalDetrImageProcessor ins... | class_definition | 1,146 | 1,552 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/conditional_detr/feature_extraction_conditional_detr.py | null | 4,053 |
class ConditionalDetrDecoderOutput(BaseModelOutputWithCrossAttentions):
"""
Base class for outputs of the Conditional DETR decoder. This class adds one attribute to
BaseModelOutputWithCrossAttentions, namely an optional stack of intermediate decoder activations, i.e. the output
of each decoder layer, ea... | class_definition | 1,622 | 4,086 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/conditional_detr/modeling_conditional_detr.py | null | 4,054 |
class ConditionalDetrModelOutput(Seq2SeqModelOutput):
"""
Base class for outputs of the Conditional DETR encoder-decoder model. This class adds one attribute to
Seq2SeqModelOutput, namely an optional stack of intermediate decoder activations, i.e. the output of each decoder
layer, each of them gone thro... | class_definition | 4,100 | 7,681 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/conditional_detr/modeling_conditional_detr.py | null | 4,055 |
class ConditionalDetrObjectDetectionOutput(ModelOutput):
"""
Output type of [`ConditionalDetrForObjectDetection`].
Args:
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` are provided)):
Total loss as a linear combination of a negative log-likehood (cross-ent... | class_definition | 7,801 | 12,783 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/conditional_detr/modeling_conditional_detr.py | null | 4,056 |
class ConditionalDetrSegmentationOutput(ModelOutput):
"""
Output type of [`ConditionalDetrForSegmentation`].
Args:
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` are provided)):
Total loss as a linear combination of a negative log-likehood (cross-entropy) ... | class_definition | 12,900 | 18,418 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/conditional_detr/modeling_conditional_detr.py | null | 4,057 |
class ConditionalDetrFrozenBatchNorm2d(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... | class_definition | 18,523 | 20,046 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/conditional_detr/modeling_conditional_detr.py | null | 4,058 |
class ConditionalDetrConvEncoder(nn.Module):
"""
Convolutional backbone, using either the AutoBackbone API or one from the timm library.
nn.BatchNorm2d layers are replaced by ConditionalDetrFrozenBatchNorm2d as defined above.
"""
def __init__(self, config):
super().__init__()
sel... | class_definition | 21,084 | 24,261 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/conditional_detr/modeling_conditional_detr.py | null | 4,059 |
class ConditionalDetrConvModel(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
self.position_embed... | class_definition | 24,358 | 25,120 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/conditional_detr/modeling_conditional_detr.py | null | 4,060 |
class ConditionalDetrSinePositionEmbedding(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, embedding_dim=64, temperature=10000, normalize=False, scal... | class_definition | 25,123 | 26,838 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/conditional_detr/modeling_conditional_detr.py | null | 4,061 |
class ConditionalDetrLearnedPositionEmbedding(nn.Module):
"""
This module learns positional embeddings up to a fixed maximum size.
"""
def __init__(self, embedding_dim=256):
super().__init__()
self.row_embeddings = nn.Embedding(50, embedding_dim)
self.column_embeddings = nn.Embe... | class_definition | 26,950 | 27,902 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/conditional_detr/modeling_conditional_detr.py | null | 4,062 |
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,
embed_dim: int,
num_heads: int,
dropout: float = 0.0... | class_definition | 29,488 | 35,363 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/conditional_detr/modeling_conditional_detr.py | null | 4,063 |
class ConditionalDetrAttention(nn.Module):
"""
Cross-Attention used in Conditional DETR 'Conditional 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__(
... | class_definition | 35,366 | 40,462 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/conditional_detr/modeling_conditional_detr.py | null | 4,064 |
class ConditionalDetrEncoderLayer(nn.Module):
def __init__(self, config: ConditionalDetrConfig):
super().__init__()
self.embed_dim = config.d_model
self.self_attn = DetrAttention(
embed_dim=self.embed_dim,
num_heads=config.encoder_attention_heads,
dropout=... | class_definition | 40,620 | 43,705 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/conditional_detr/modeling_conditional_detr.py | null | 4,065 |
class ConditionalDetrDecoderLayer(nn.Module):
def __init__(self, config: ConditionalDetrConfig):
super().__init__()
self.embed_dim = config.d_model
d_model = config.d_model
# Decoder Self-Attention projections
self.sa_qcontent_proj = nn.Linear(d_model, d_model)
self.... | class_definition | 43,708 | 51,448 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/conditional_detr/modeling_conditional_detr.py | null | 4,066 |
class MLP(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__(self, in... | class_definition | 51,558 | 52,313 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/conditional_detr/modeling_conditional_detr.py | null | 4,067 |
class ConditionalDetrPreTrainedModel(PreTrainedModel):
config_class = ConditionalDetrConfig
base_model_prefix = "model"
main_input_name = "pixel_values"
_no_split_modules = [r"ConditionalDetrConvEncoder", r"ConditionalDetrEncoderLayer", r"ConditionalDetrDecoderLayer"]
def _init_weights(self, module... | class_definition | 52,416 | 53,919 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/conditional_detr/modeling_conditional_detr.py | null | 4,068 |
class ConditionalDetrEncoder(ConditionalDetrPreTrainedModel):
"""
Transformer encoder consisting of *config.encoder_layers* self attention layers. Each layer is a
[`ConditionalDetrEncoderLayer`].
The encoder updates the flattened feature map through multiple self-attention layers.
Small tweak for ... | class_definition | 57,401 | 62,295 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/conditional_detr/modeling_conditional_detr.py | null | 4,069 |
class ConditionalDetrDecoder(ConditionalDetrPreTrainedModel):
"""
Transformer decoder consisting of *config.decoder_layers* layers. Each layer is a [`ConditionalDetrDecoderLayer`].
The decoder updates the query embeddings through multiple self-attention and cross-attention layers.
Some small tweaks fo... | class_definition | 62,298 | 71,378 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/conditional_detr/modeling_conditional_detr.py | null | 4,070 |
class ConditionalDetrModel(ConditionalDetrPreTrainedModel):
def __init__(self, config: ConditionalDetrConfig):
super().__init__(config)
# Create backbone + positional encoding
backbone = ConditionalDetrConvEncoder(config)
object_queries = build_position_encoding(config)
self... | class_definition | 71,623 | 79,022 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/conditional_detr/modeling_conditional_detr.py | null | 4,071 |
class ConditionalDetrMLPPredictionHead(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
"... | class_definition | 79,127 | 79,911 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/conditional_detr/modeling_conditional_detr.py | null | 4,072 |
class ConditionalDetrForObjectDetection(ConditionalDetrPreTrainedModel):
def __init__(self, config: ConditionalDetrConfig):
super().__init__(config)
# CONDITIONAL DETR encoder-decoder model
self.model = ConditionalDetrModel(config)
# Object detection heads
self.class_labels... | class_definition | 80,154 | 87,581 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/conditional_detr/modeling_conditional_detr.py | null | 4,073 |
class ConditionalDetrForSegmentation(ConditionalDetrPreTrainedModel):
def __init__(self, config: ConditionalDetrConfig):
super().__init__(config)
# object detection model
self.conditional_detr = ConditionalDetrForObjectDetection(config)
# segmentation head
hidden_size, numb... | class_definition | 87,821 | 98,126 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/conditional_detr/modeling_conditional_detr.py | null | 4,074 |
class ConditionalDetrMaskHeadSmallConv(nn.Module):
"""
Simple convolutional head, using group norm. Upsampling is done using a FPN approach
"""
def __init__(self, dim, fpn_dims, context_dim):
super().__init__()
if dim % 8 != 0:
raise ValueError(
"The hidden_... | class_definition | 98,344 | 101,698 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/conditional_detr/modeling_conditional_detr.py | null | 4,075 |
class ConditionalDetrMHAttentionMap(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):
super().__init__()
self.num_heads = num_heads
... | class_definition | 101,800 | 103,215 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/conditional_detr/modeling_conditional_detr.py | null | 4,076 |
class ConditionalDetrImageProcessor(BaseImageProcessor):
r"""
Constructs a Conditional Detr image processor.
Args:
format (`str`, *optional*, defaults to `"coco_detection"`):
Data format of the annotations. One of "coco_detection" or "coco_panoptic".
do_resize (`bool`, *optional... | class_definition | 30,228 | 85,727 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/conditional_detr/image_processing_conditional_detr.py | null | 4,077 |
class ConditionalDetrConfig(PretrainedConfig):
r"""
This is the configuration class to store the configuration of a [`ConditionalDetrModel`]. It is used to instantiate
a Conditional DETR model according to the specified arguments, defining the model architecture. Instantiating a
configuration with the d... | class_definition | 1,022 | 12,753 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/conditional_detr/configuration_conditional_detr.py | null | 4,078 |
class ConditionalDetrOnnxConfig(OnnxConfig):
torch_onnx_minimum_version = version.parse("1.11")
@property
def inputs(self) -> Mapping[str, Mapping[int, str]]:
return OrderedDict(
[
("pixel_values", {0: "batch", 1: "num_channels", 2: "height", 3: "width"}),
... | class_definition | 12,756 | 13,284 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/conditional_detr/configuration_conditional_detr.py | null | 4,079 |
class VisionTextDualEncoderProcessor(ProcessorMixin):
r"""
Constructs a VisionTextDualEncoder processor which wraps an image processor and a tokenizer into a single
processor.
[`VisionTextDualEncoderProcessor`] offers all the functionalities of [`AutoImageProcessor`] and [`AutoTokenizer`].
See the ... | class_definition | 775 | 6,928 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/vision_text_dual_encoder/processing_vision_text_dual_encoder.py | null | 4,080 |
class TFVisionTextDualEncoderModel(TFPreTrainedModel):
config_class = VisionTextDualEncoderConfig
base_model_prefix = "vision_text_dual_encoder"
load_weight_prefix = "tf_vision_text_dual_encoder_model"
def __init__(
self,
config: Optional[VisionTextDualEncoderConfig] = None,
vis... | class_definition | 8,694 | 28,639 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/vision_text_dual_encoder/modeling_tf_vision_text_dual_encoder.py | null | 4,081 |
class FlaxVisionTextDualEncoderModule(nn.Module):
config: VisionTextDualEncoderConfig
dtype: jnp.dtype = jnp.float32
def setup(self):
vision_config = self.config.vision_config
text_config = self.config.text_config
self.vision_embed_dim = vision_config.hidden_size
self.text_... | class_definition | 6,567 | 10,012 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/vision_text_dual_encoder/modeling_flax_vision_text_dual_encoder.py | null | 4,082 |
class FlaxVisionTextDualEncoderModel(FlaxPreTrainedModel):
config_class = VisionTextDualEncoderConfig
module_class = FlaxVisionTextDualEncoderModule
def __init__(
self,
config: VisionTextDualEncoderConfig,
input_shape: Optional[Tuple] = None,
seed: int = 0,
dtype: jn... | class_definition | 10,079 | 24,117 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/vision_text_dual_encoder/modeling_flax_vision_text_dual_encoder.py | null | 4,083 |
class VisionTextDualEncoderConfig(PretrainedConfig):
r"""
[`VisionTextDualEncoderConfig`] is the configuration class to store the configuration of a
[`VisionTextDualEncoderModel`]. It is used to instantiate [`VisionTextDualEncoderModel`] model according to the
specified arguments, defining the text mode... | class_definition | 1,212 | 4,969 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/vision_text_dual_encoder/configuration_vision_text_dual_encoder.py | null | 4,084 |
class VisionTextDualEncoderModel(PreTrainedModel):
config_class = VisionTextDualEncoderConfig
base_model_prefix = "vision_text_dual_encoder"
_supports_flash_attn_2 = True
_supports_sdpa = True
def __init__(
self,
config: Optional[VisionTextDualEncoderConfig] = None,
vision_m... | class_definition | 8,461 | 25,198 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/vision_text_dual_encoder/modeling_vision_text_dual_encoder.py | null | 4,085 |
class MvpLearnedPositionalEmbedding(nn.Embedding):
"""
This module learns positional embeddings up to a fixed maximum size.
"""
def __init__(self, num_embeddings: int, embedding_dim: int):
# MVP is set up so that if padding_idx is specified then offset the embedding ids by 2
# and adjus... | class_definition | 2,555 | 3,457 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mvp/modeling_mvp.py | null | 4,086 |
class MvpAttention(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,
):
super().__init__()
sel... | class_definition | 3,460 | 10,889 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mvp/modeling_mvp.py | null | 4,087 |
class MvpEncoderLayer(nn.Module):
def __init__(self, config: MvpConfig):
super().__init__()
self.embed_dim = config.d_model
self.self_attn = MvpAttention(
embed_dim=self.embed_dim,
num_heads=config.encoder_attention_heads,
dropout=config.attention_dropout,... | class_definition | 10,892 | 14,261 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mvp/modeling_mvp.py | null | 4,088 |
class MvpDecoderLayer(nn.Module):
def __init__(self, config: MvpConfig):
super().__init__()
self.embed_dim = config.d_model
self.self_attn = MvpAttention(
embed_dim=self.embed_dim,
num_heads=config.decoder_attention_heads,
dropout=config.attention_dropout... | class_definition | 14,264 | 20,553 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mvp/modeling_mvp.py | null | 4,089 |
class MvpClassificationHead(nn.Module):
"""Head for sentence-level classification tasks."""
def __init__(
self,
input_dim: int,
inner_dim: int,
num_classes: int,
pooler_dropout: float,
):
super().__init__()
self.dense = nn.Linear(input_dim, inner_dim)... | class_definition | 20,647 | 21,432 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mvp/modeling_mvp.py | null | 4,090 |
class MvpPrompt(nn.Module):
"""Layer-wise prompt for encoder or decoder."""
def __init__(self, config, num_layers, num_heads):
super().__init__()
self.prompt_length = config.prompt_length
self.num_layers = num_layers
self.num_heads = num_heads
self.head_dim = config.d_mo... | class_definition | 21,435 | 22,482 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mvp/modeling_mvp.py | null | 4,091 |
class MvpPreTrainedModel(PreTrainedModel):
config_class = MvpConfig
base_model_prefix = "model"
supports_gradient_checkpointing = True
def _init_weights(self, module):
std = self.config.init_std
if isinstance(module, nn.Linear):
module.weight.data.normal_(mean=0.0, std=std)
... | class_definition | 22,485 | 23,441 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mvp/modeling_mvp.py | null | 4,092 |
class MvpEncoder(MvpPreTrainedModel):
"""
Transformer encoder consisting of *config.encoder_layers* self attention layers. Each layer is a
[`MvpEncoderLayer`].
Args:
config: MvpConfig
embed_tokens (nn.Embedding): output embedding
use_prompt (bool): whether to use prompt
"""
... | class_definition | 34,034 | 42,775 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mvp/modeling_mvp.py | null | 4,093 |
class MvpDecoder(MvpPreTrainedModel):
"""
Transformer decoder consisting of *config.decoder_layers* layers. Each layer is a [`MvpDecoderLayer`]
Args:
config: MvpConfig
embed_tokens (nn.Embedding): output embedding
use_prompt (bool): whether to use prompt
"""
def __init__(
... | class_definition | 42,778 | 56,699 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mvp/modeling_mvp.py | null | 4,094 |
class MvpModel(MvpPreTrainedModel):
_keys_to_ignore_on_load_unexpected = ["final_logits_bias"]
_tied_weights_keys = ["encoder.embed_tokens.weight", "decoder.embed_tokens.weight"]
def __init__(self, config: MvpConfig):
super().__init__(config)
padding_idx, vocab_size = config.pad_token_id, ... | class_definition | 56,841 | 62,800 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mvp/modeling_mvp.py | null | 4,095 |
class MvpForConditionalGeneration(MvpPreTrainedModel, GenerationMixin):
_tied_weights_keys = ["encoder.embed_tokens.weight", "decoder.embed_tokens.weight", "lm_head.weight"]
def __init__(self, config: MvpConfig):
super().__init__(config)
self.model = MvpModel(config)
self.register_buffe... | class_definition | 62,947 | 69,251 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mvp/modeling_mvp.py | null | 4,096 |
class MvpForSequenceClassification(MvpPreTrainedModel):
_tied_weights_keys = ["encoder.embed_tokens.weight", "decoder.embed_tokens.weight"]
def __init__(self, config: MvpConfig, **kwargs):
super().__init__(config, **kwargs)
self.model = MvpModel(config)
self.classification_head = MvpCla... | class_definition | 69,448 | 74,900 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mvp/modeling_mvp.py | null | 4,097 |
class MvpForQuestionAnswering(MvpPreTrainedModel):
_tied_weights_keys = ["encoder.embed_tokens.weight", "decoder.embed_tokens.weight"]
def __init__(self, config):
super().__init__(config)
config.num_labels = 2
self.num_labels = config.num_labels
self.model = MvpModel(config)
... | class_definition | 75,184 | 80,526 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mvp/modeling_mvp.py | null | 4,098 |
class MvpDecoderWrapper(MvpPreTrainedModel):
"""
This wrapper class is a helper class to correctly load pretrained checkpoints when the causal language model is
used in combination with the [`EncoderDecoderModel`] framework.
"""
def __init__(self, config):
super().__init__(config)
s... | class_definition | 80,616 | 81,054 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mvp/modeling_mvp.py | null | 4,099 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.