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 LayoutLMOnnxConfig(OnnxConfig):
def __init__(
self,
config: PretrainedConfig,
task: str = "default",
patching_specs: List[PatchingSpec] = None,
):
super().__init__(config, task=task, patching_specs=patching_specs)
self.max_2d_positions = config.max_2d_positi... | class_definition | 6,721 | 9,080 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/layoutlm/configuration_layoutlm.py | null | 9,600 |
class LayoutLMTokenizerFast(PreTrainedTokenizerFast):
r"""
Construct a "fast" LayoutLM tokenizer (backed by HuggingFace's *tokenizers* library). Based on WordPiece.
This tokenizer inherits from [`PreTrainedTokenizerFast`] which contains most of the main methods. Users should
refer to this superclass fo... | class_definition | 1,152 | 7,785 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/layoutlm/tokenization_layoutlm_fast.py | null | 9,601 |
class LayoutLMEmbeddings(nn.Module):
"""Construct the embeddings from word, position and token_type embeddings."""
def __init__(self, config):
super(LayoutLMEmbeddings, self).__init__()
self.word_embeddings = nn.Embedding(config.vocab_size, config.hidden_size, padding_idx=config.pad_token_id)
... | class_definition | 1,646 | 4,945 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/layoutlm/modeling_layoutlm.py | null | 9,602 |
class LayoutLMSelfAttention(nn.Module):
def __init__(self, config, position_embedding_type=None):
super().__init__()
if config.hidden_size % config.num_attention_heads != 0 and not hasattr(config, "embedding_size"):
raise ValueError(
f"The hidden size ({config.hidden_size... | class_definition | 5,039 | 12,389 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/layoutlm/modeling_layoutlm.py | null | 9,603 |
class LayoutLMSelfOutput(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.hidden_size)
self.LayerNorm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps)
self.dropout = nn.Dropout(config.hidden_dropout_prob)
d... | class_definition | 12,480 | 13,090 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/layoutlm/modeling_layoutlm.py | null | 9,604 |
class LayoutLMAttention(nn.Module):
def __init__(self, config, position_embedding_type=None):
super().__init__()
self.self = LAYOUTLM_SELF_ATTENTION_CLASSES[config._attn_implementation](
config, position_embedding_type=position_embedding_type
)
self.output = LayoutLMSelfO... | class_definition | 13,271 | 15,405 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/layoutlm/modeling_layoutlm.py | null | 9,605 |
class LayoutLMIntermediate(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.intermediate_size)
if isinstance(config.hidden_act, str):
self.intermediate_act_fn = ACT2FN[config.hidden_act]
else:
self.in... | class_definition | 15,478 | 16,047 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/layoutlm/modeling_layoutlm.py | null | 9,606 |
class LayoutLMOutput(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)
self.dropout = nn.Dropout(config.hidden_dropout_prob)
... | class_definition | 16,134 | 16,746 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/layoutlm/modeling_layoutlm.py | null | 9,607 |
class LayoutLMLayer(nn.Module):
def __init__(self, config):
super().__init__()
self.chunk_size_feed_forward = config.chunk_size_feed_forward
self.seq_len_dim = 1
self.attention = LayoutLMAttention(config)
self.is_decoder = config.is_decoder
self.add_cross_attention = ... | class_definition | 16,832 | 20,759 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/layoutlm/modeling_layoutlm.py | null | 9,608 |
class LayoutLMEncoder(nn.Module):
def __init__(self, config):
super().__init__()
self.config = config
self.layer = nn.ModuleList([LayoutLMLayer(config) for _ in range(config.num_hidden_layers)])
self.gradient_checkpointing = False
def forward(
self,
hidden_states... | class_definition | 20,847 | 24,645 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/layoutlm/modeling_layoutlm.py | null | 9,609 |
class LayoutLMPooler(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.hidden_size)
self.activation = nn.Tanh()
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
# We "pool" the model by simply taking the h... | class_definition | 24,712 | 25,275 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/layoutlm/modeling_layoutlm.py | null | 9,610 |
class LayoutLMPredictionHeadTransform(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.hidden_size)
if isinstance(config.hidden_act, str):
self.transform_act_fn = ACT2FN[config.hidden_act]
else:
self.... | class_definition | 25,379 | 26,083 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/layoutlm/modeling_layoutlm.py | null | 9,611 |
class LayoutLMLMPredictionHead(nn.Module):
def __init__(self, config):
super().__init__()
self.transform = LayoutLMPredictionHeadTransform(config)
# The output weights are the same as the input embeddings, but there is
# an output-only bias for each token.
self.decoder = nn.... | class_definition | 26,180 | 27,020 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/layoutlm/modeling_layoutlm.py | null | 9,612 |
class LayoutLMOnlyMLMHead(nn.Module):
def __init__(self, config):
super().__init__()
self.predictions = LayoutLMLMPredictionHead(config)
def forward(self, sequence_output: torch.Tensor) -> torch.Tensor:
prediction_scores = self.predictions(sequence_output)
return prediction_scor... | class_definition | 27,112 | 27,434 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/layoutlm/modeling_layoutlm.py | null | 9,613 |
class LayoutLMPreTrainedModel(PreTrainedModel):
"""
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
models.
"""
config_class = LayoutLMConfig
base_model_prefix = "layoutlm"
supports_gradient_checkpointing = True
def _init... | class_definition | 27,437 | 28,558 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/layoutlm/modeling_layoutlm.py | null | 9,614 |
class LayoutLMModel(LayoutLMPreTrainedModel):
def __init__(self, config):
super(LayoutLMModel, self).__init__(config)
self.config = config
self.embeddings = LayoutLMEmbeddings(config)
self.encoder = LayoutLMEncoder(config)
self.pooler = LayoutLMPooler(config)
# Init... | class_definition | 32,712 | 39,051 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/layoutlm/modeling_layoutlm.py | null | 9,615 |
class LayoutLMForMaskedLM(LayoutLMPreTrainedModel):
_tied_weights_keys = ["cls.predictions.decoder.bias", "cls.predictions.decoder.weight"]
def __init__(self, config):
super().__init__(config)
self.layoutlm = LayoutLMModel(config)
self.cls = LayoutLMOnlyMLMHead(config)
# Initi... | class_definition | 39,164 | 44,109 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/layoutlm/modeling_layoutlm.py | null | 9,616 |
class LayoutLMForSequenceClassification(LayoutLMPreTrainedModel):
def __init__(self, config):
super().__init__(config)
self.num_labels = config.num_labels
self.layoutlm = LayoutLMModel(config)
self.dropout = nn.Dropout(config.hidden_dropout_prob)
self.classifier = nn.Linear(c... | class_definition | 44,415 | 49,850 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/layoutlm/modeling_layoutlm.py | null | 9,617 |
class LayoutLMForTokenClassification(LayoutLMPreTrainedModel):
def __init__(self, config):
super().__init__(config)
self.num_labels = config.num_labels
self.layoutlm = LayoutLMModel(config)
self.dropout = nn.Dropout(config.hidden_dropout_prob)
self.classifier = nn.Linear(conf... | class_definition | 50,227 | 54,547 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/layoutlm/modeling_layoutlm.py | null | 9,618 |
class LayoutLMForQuestionAnswering(LayoutLMPreTrainedModel):
def __init__(self, config, has_visual_segment_embedding=True):
super().__init__(config)
self.num_labels = config.num_labels
self.layoutlm = LayoutLMModel(config)
self.qa_outputs = nn.Linear(config.hidden_size, config.num_l... | class_definition | 54,888 | 61,012 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/layoutlm/modeling_layoutlm.py | null | 9,619 |
class Owlv2ImageProcessor(BaseImageProcessor):
r"""
Constructs an OWLv2 image processor.
Args:
do_rescale (`bool`, *optional*, defaults to `True`):
Whether to rescale the image by the specified scale `rescale_factor`. Can be overriden by `do_rescale` in
the `preprocess` meth... | class_definition | 6,974 | 27,954 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/owlv2/image_processing_owlv2.py | null | 9,620 |
class Owlv2Processor(ProcessorMixin):
r"""
Constructs an Owlv2 processor which wraps [`Owlv2ImageProcessor`] and [`CLIPTokenizer`]/[`CLIPTokenizerFast`] into
a single processor that interits both the image processor and tokenizer functionalities. See the
[`~OwlViTProcessor.__call__`] and [`~OwlViTProces... | class_definition | 1,059 | 14,423 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/owlv2/processing_owlv2.py | null | 9,621 |
class Owlv2TextConfig(PretrainedConfig):
r"""
This is the configuration class to store the configuration of an [`Owlv2TextModel`]. It is used to instantiate an
Owlv2 text encoder according to the specified arguments, defining the model architecture. Instantiating a
configuration with the defaults will y... | class_definition | 1,021 | 5,718 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/owlv2/configuration_owlv2.py | null | 9,622 |
class Owlv2VisionConfig(PretrainedConfig):
r"""
This is the configuration class to store the configuration of an [`Owlv2VisionModel`]. It is used to instantiate
an OWLv2 image encoder according to the specified arguments, defining the model architecture. Instantiating a
configuration with the defaults w... | class_definition | 5,901 | 9,926 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/owlv2/configuration_owlv2.py | null | 9,623 |
class Owlv2Config(PretrainedConfig):
r"""
[`Owlv2Config`] is the configuration class to store the configuration of an [`Owlv2Model`]. It is used to
instantiate an OWLv2 model according to the specified arguments, defining the text model and vision model
configs. Instantiating a configuration with the de... | class_definition | 10,095 | 13,134 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/owlv2/configuration_owlv2.py | null | 9,624 |
class Owlv2Output(ModelOutput):
"""
Args:
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `return_loss` is `True`):
Contrastive loss for image-text similarity.
logits_per_image (`torch.FloatTensor` of shape `(image_batch_size, text_batch_size)`):
The ... | class_definition | 2,199 | 4,108 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/owlv2/modeling_owlv2.py | null | 9,625 |
class Owlv2ObjectDetectionOutput(ModelOutput):
"""
Output type of [`Owlv2ForObjectDetection`].
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) for class pred... | class_definition | 6,762 | 9,927 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/owlv2/modeling_owlv2.py | null | 9,626 |
class Owlv2ImageGuidedObjectDetectionOutput(ModelOutput):
"""
Output type of [`Owlv2ForObjectDetection.image_guided_detection`].
Args:
logits (`torch.FloatTensor` of shape `(batch_size, num_patches, num_queries)`):
Classification logits (including no-object) for all queries.
tar... | class_definition | 10,071 | 12,984 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/owlv2/modeling_owlv2.py | null | 9,627 |
class Owlv2VisionEmbeddings(nn.Module):
def __init__(self, config: Owlv2VisionConfig):
super().__init__()
self.patch_size = config.patch_size
self.config = config
self.embed_dim = config.hidden_size
self.class_embedding = nn.Parameter(torch.randn(config.hidden_size))
... | class_definition | 13,086 | 16,668 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/owlv2/modeling_owlv2.py | null | 9,628 |
class Owlv2TextEmbeddings(nn.Module):
def __init__(self, config: Owlv2TextConfig):
super().__init__()
self.token_embedding = nn.Embedding(config.vocab_size, config.hidden_size)
self.position_embedding = nn.Embedding(config.max_position_embeddings, config.hidden_size)
# position_ids ... | class_definition | 16,768 | 17,972 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/owlv2/modeling_owlv2.py | null | 9,629 |
class Owlv2Attention(nn.Module):
"""Multi-headed attention from 'Attention Is All You Need' paper"""
def __init__(self, config):
super().__init__()
self.config = config
self.embed_dim = config.hidden_size
self.num_heads = config.num_attention_heads
self.head_dim = self.e... | class_definition | 18,067 | 22,960 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/owlv2/modeling_owlv2.py | null | 9,630 |
class Owlv2MLP(nn.Module):
def __init__(self, config):
super().__init__()
self.config = config
self.activation_fn = ACT2FN[config.hidden_act]
self.fc1 = nn.Linear(config.hidden_size, config.intermediate_size)
self.fc2 = nn.Linear(config.intermediate_size, config.hidden_size)
... | class_definition | 23,041 | 23,612 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/owlv2/modeling_owlv2.py | null | 9,631 |
class Owlv2EncoderLayer(nn.Module):
def __init__(self, config: Owlv2Config):
super().__init__()
self.embed_dim = config.hidden_size
self.self_attn = Owlv2Attention(config)
self.layer_norm1 = nn.LayerNorm(self.embed_dim, eps=config.layer_norm_eps)
self.mlp = Owlv2MLP(config)
... | class_definition | 23,714 | 25,663 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/owlv2/modeling_owlv2.py | null | 9,632 |
class Owlv2PreTrainedModel(PreTrainedModel):
"""
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
models.
"""
config_class = Owlv2Config
base_model_prefix = "owlv2"
supports_gradient_checkpointing = True
_no_split_modules =... | class_definition | 25,778 | 28,460 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/owlv2/modeling_owlv2.py | null | 9,633 |
class Owlv2Encoder(nn.Module):
"""
Transformer encoder consisting of `config.num_hidden_layers` self attention layers. Each layer is a
[`Owlv2EncoderLayer`].
Args:
config: Owlv2Config
"""
def __init__(self, config: Owlv2Config):
super().__init__()
self.layers = nn.Modul... | class_definition | 35,913 | 39,951 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/owlv2/modeling_owlv2.py | null | 9,634 |
class Owlv2TextTransformer(nn.Module):
def __init__(self, config: Owlv2TextConfig):
super().__init__()
self.config = config
embed_dim = config.hidden_size
self.embeddings = Owlv2TextEmbeddings(config)
self.encoder = Owlv2Encoder(config)
self.final_layer_norm = nn.Laye... | class_definition | 40,066 | 43,470 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/owlv2/modeling_owlv2.py | null | 9,635 |
class Owlv2TextModel(Owlv2PreTrainedModel):
config_class = Owlv2TextConfig
def __init__(self, config: Owlv2TextConfig):
super().__init__(config)
self.text_model = Owlv2TextTransformer(config)
# Initialize weights and apply final processing
self.post_init()
def get_input_emb... | class_definition | 43,634 | 45,605 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/owlv2/modeling_owlv2.py | null | 9,636 |
class Owlv2VisionTransformer(nn.Module):
def __init__(self, config: Owlv2VisionConfig):
super().__init__()
self.config = config
self.embeddings = Owlv2VisionEmbeddings(config)
self.pre_layernorm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps)
self.encoder = Owl... | class_definition | 45,722 | 48,155 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/owlv2/modeling_owlv2.py | null | 9,637 |
class Owlv2VisionModel(Owlv2PreTrainedModel):
config_class = Owlv2VisionConfig
main_input_name = "pixel_values"
def __init__(self, config: Owlv2VisionConfig):
super().__init__(config)
self.vision_model = Owlv2VisionTransformer(config)
# Initialize weights and apply final processing
... | class_definition | 48,320 | 50,330 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/owlv2/modeling_owlv2.py | null | 9,638 |
class Owlv2Model(Owlv2PreTrainedModel):
config_class = Owlv2Config
def __init__(self, config: Owlv2Config):
super().__init__(config)
if not isinstance(config.text_config, Owlv2TextConfig):
raise TypeError(
"config.text_config is expected to be of type Owlv2TextConfi... | class_definition | 50,573 | 59,839 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/owlv2/modeling_owlv2.py | null | 9,639 |
class Owlv2BoxPredictionHead(nn.Module):
def __init__(self, config: Owlv2Config, out_dim: int = 4):
super().__init__()
width = config.vision_config.hidden_size
self.dense0 = nn.Linear(width, width)
self.dense1 = nn.Linear(width, width)
self.gelu = nn.GELU()
self.dens... | class_definition | 59,942 | 60,578 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/owlv2/modeling_owlv2.py | null | 9,640 |
class Owlv2ClassPredictionHead(nn.Module):
def __init__(self, config: Owlv2Config):
super().__init__()
out_dim = config.text_config.hidden_size
self.query_dim = config.vision_config.hidden_size
self.dense0 = nn.Linear(self.query_dim, out_dim)
self.logit_shift = nn.Linear(se... | class_definition | 60,683 | 62,663 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/owlv2/modeling_owlv2.py | null | 9,641 |
class Owlv2ForObjectDetection(Owlv2PreTrainedModel):
config_class = Owlv2Config
def __init__(self, config: Owlv2Config):
super().__init__(config)
self.owlv2 = Owlv2Model(config)
self.class_head = Owlv2ClassPredictionHead(config)
self.box_head = Owlv2BoxPredictionHead(config)
... | class_definition | 62,666 | 86,042 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/owlv2/modeling_owlv2.py | null | 9,642 |
class GitVisionConfig(PretrainedConfig):
r"""
This is the configuration class to store the configuration of a [`GitVisionModel`]. It is used to instantiate a GIT
vision encoder according to the specified arguments, defining the model architecture. Instantiating a configuration
with the defaults will yie... | class_definition | 751 | 4,365 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/git/configuration_git.py | null | 9,643 |
class GitConfig(PretrainedConfig):
r"""
This is the configuration class to store the configuration of a [`GitModel`]. It is used to instantiate a GIT model
according to the specified arguments, defining the model architecture. Instantiating a configuration with the
defaults will yield a similar configur... | class_definition | 4,368 | 10,385 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/git/configuration_git.py | null | 9,644 |
class GitProcessorKwargs(ProcessingKwargs, total=False):
_defaults = {} | class_definition | 989 | 1,064 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/git/processing_git.py | null | 9,645 |
class GitProcessor(ProcessorMixin):
r"""
Constructs a GIT processor which wraps a CLIP image processor and a BERT tokenizer into a single processor.
[`GitProcessor`] offers all the functionalities of [`CLIPImageProcessor`] and [`BertTokenizerFast`]. See the
[`~GitProcessor.__call__`] and [`~GitProcesso... | class_definition | 1,107 | 6,846 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/git/processing_git.py | null | 9,646 |
class GitVisionModelOutput(ModelOutput):
"""
Base class for vision model's outputs that also contains image embeddings of the pooling of the last hidden states.
Args:
image_embeds (`torch.FloatTensor` of shape `(batch_size, output_dim)` *optional* returned when model is initialized with `with_proje... | class_definition | 1,832 | 3,615 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/git/modeling_git.py | null | 9,647 |
class GitEmbeddings(nn.Module):
"""Construct the embeddings from word and position embeddings."""
def __init__(self, config):
super().__init__()
self.word_embeddings = nn.Embedding(config.vocab_size, config.hidden_size, padding_idx=config.pad_token_id)
self.position_embeddings = nn.Embe... | class_definition | 3,618 | 5,662 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/git/modeling_git.py | null | 9,648 |
class GitSelfAttention(nn.Module):
def __init__(self, config, position_embedding_type=None, layer_idx=None):
super().__init__()
if config.hidden_size % config.num_attention_heads != 0 and not hasattr(config, "embedding_size"):
raise ValueError(
f"The hidden size ({config.... | class_definition | 5,665 | 12,147 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/git/modeling_git.py | null | 9,649 |
class GitSelfOutput(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.hidden_size)
self.LayerNorm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps)
self.dropout = nn.Dropout(config.hidden_dropout_prob)
def fo... | class_definition | 12,218 | 12,823 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/git/modeling_git.py | null | 9,650 |
class GitAttention(nn.Module):
def __init__(self, config, position_embedding_type=None, layer_idx=None):
super().__init__()
self.self = GIT_SELF_ATTENTION_CLASSES[config._attn_implementation](
config, position_embedding_type=position_embedding_type, layer_idx=layer_idx
)
... | class_definition | 12,892 | 14,987 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/git/modeling_git.py | null | 9,651 |
class GitIntermediate(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.intermediate_size)
if isinstance(config.hidden_act, str):
self.intermediate_act_fn = ACT2FN[config.hidden_act]
else:
self.interme... | class_definition | 15,060 | 15,624 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/git/modeling_git.py | null | 9,652 |
class GitOutput(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)
self.dropout = nn.Dropout(config.hidden_dropout_prob)
def ... | class_definition | 15,691 | 16,298 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/git/modeling_git.py | null | 9,653 |
class GitLayer(nn.Module):
def __init__(self, config, layer_idx=None):
super().__init__()
self.chunk_size_feed_forward = config.chunk_size_feed_forward
self.seq_len_dim = 1
self.attention = GitAttention(config, layer_idx=layer_idx)
self.intermediate = GitIntermediate(config)
... | class_definition | 16,301 | 18,196 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/git/modeling_git.py | null | 9,654 |
class GitEncoder(nn.Module):
def __init__(self, config):
super().__init__()
self.config = config
self.layer = nn.ModuleList([GitLayer(config, i) for i in range(config.num_hidden_layers)])
self.gradient_checkpointing = False
def forward(
self,
hidden_states: torch... | class_definition | 18,199 | 22,214 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/git/modeling_git.py | null | 9,655 |
class GitPreTrainedModel(PreTrainedModel):
"""
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
models.
"""
config_class = GitConfig
base_model_prefix = "git"
supports_gradient_checkpointing = True
_supports_cache_class = T... | class_definition | 22,217 | 23,728 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/git/modeling_git.py | null | 9,656 |
class GitVisionEmbeddings(nn.Module):
def __init__(self, config: GitVisionConfig):
super().__init__()
self.config = config
self.embed_dim = config.hidden_size
self.image_size = config.image_size
self.patch_size = config.patch_size
self.class_embedding = nn.Parameter(... | class_definition | 28,663 | 32,487 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/git/modeling_git.py | null | 9,657 |
class GitVisionMLP(nn.Module):
def __init__(self, config):
super().__init__()
self.config = config
self.activation_fn = ACT2FN[config.hidden_act]
self.fc1 = nn.Linear(config.hidden_size, config.intermediate_size)
self.fc2 = nn.Linear(config.intermediate_size, config.hidden_si... | class_definition | 32,551 | 33,126 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/git/modeling_git.py | null | 9,658 |
class GitVisionAttention(nn.Module):
"""Multi-headed attention from 'Attention Is All You Need' paper"""
def __init__(self, config):
super().__init__()
self.config = config
self.embed_dim = config.hidden_size
self.num_heads = config.num_attention_heads
self.head_dim = se... | class_definition | 33,217 | 37,952 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/git/modeling_git.py | null | 9,659 |
class GitVisionEncoderLayer(nn.Module):
def __init__(self, config: GitVisionConfig):
super().__init__()
self.embed_dim = config.hidden_size
self.self_attn = GitVisionAttention(config)
self.layer_norm1 = nn.LayerNorm(self.embed_dim, eps=config.layer_norm_eps)
self.mlp = GitVis... | class_definition | 38,058 | 40,023 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/git/modeling_git.py | null | 9,660 |
class GitVisionEncoder(nn.Module):
"""
Transformer encoder consisting of `config.num_hidden_layers` self attention layers. Each layer is a
[`GitVisionEncoderLayer`].
Args:
config: GitVisionConfig
"""
def __init__(self, config: GitVisionConfig):
super().__init__()
self.c... | class_definition | 40,136 | 44,549 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/git/modeling_git.py | null | 9,661 |
class GitVisionTransformer(nn.Module):
# Copied from transformers.models.altclip.modeling_altclip.AltCLIPVisionTransformer.__init__ with AltCLIPEncoder->GitVisionEncoder, AltCLIP->Git
def __init__(self, config: GitVisionConfig):
super().__init__()
self.config = config
embed_dim = config.... | class_definition | 45,573 | 47,967 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/git/modeling_git.py | null | 9,662 |
class GitVisionModel(GitPreTrainedModel):
config_class = GitVisionConfig
main_input_name = "pixel_values"
# Copied from transformers.models.clip.modeling_clip.CLIPVisionModel.__init__ with CLIP->Git
def __init__(self, config: GitVisionConfig):
super().__init__(config)
self.vision_model ... | class_definition | 48,111 | 50,190 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/git/modeling_git.py | null | 9,663 |
class GitProjection(nn.Module):
def __init__(self, config: GitConfig):
super().__init__()
self.config = config
self.visual_projection = nn.Sequential(
nn.Linear(config.vision_config.hidden_size, config.hidden_size),
nn.LayerNorm(config.hidden_size, eps=config.vision_c... | class_definition | 50,193 | 50,661 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/git/modeling_git.py | null | 9,664 |
class GitModel(GitPreTrainedModel):
def __init__(self, config):
super().__init__(config)
self.config = config
self.embeddings = GitEmbeddings(config)
self.image_encoder = GitVisionModel(config.vision_config)
self.encoder = GitEncoder(config)
self.visual_projection =... | class_definition | 50,874 | 62,439 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/git/modeling_git.py | null | 9,665 |
class GitForCausalLM(GitPreTrainedModel, GenerationMixin):
_tied_weights_keys = ["output.weight"]
def __init__(self, config):
super().__init__(config)
self.git = GitModel(config)
self.output = nn.Linear(config.hidden_size, config.vocab_size)
# Initialize weights and apply fina... | class_definition | 62,585 | 73,426 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/git/modeling_git.py | null | 9,666 |
class TFMistralRMSNorm(keras.layers.Layer):
def __init__(self, hidden_size, eps=1e-6, **kwargs):
"""
TFMistralRMSNorm is equivalent to T5LayerNorm
"""
super().__init__(**kwargs)
self.hidden_size = hidden_size
self.variance_epsilon = eps
def build(self, input_shap... | class_definition | 3,483 | 4,401 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modeling_tf_mistral.py | null | 9,667 |
class TFMistralRotaryEmbedding(keras.layers.Layer):
def __init__(self, dim, max_position_embeddings=2048, base=10000, **kwargs):
super().__init__(**kwargs)
self.dim = dim
self.max_position_embeddings = max_position_embeddings
self.base = base
self.inv_freq = 1.0 / (self.base ... | class_definition | 4,519 | 5,532 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modeling_tf_mistral.py | null | 9,668 |
class TFMistralMLP(keras.layers.Layer):
def __init__(self, config, **kwargs):
super().__init__(**kwargs)
self.config = config
self.hidden_size = config.hidden_size
self.intermediate_size = config.intermediate_size
self.gate_proj = keras.layers.Dense(self.intermediate_size, us... | class_definition | 7,588 | 8,908 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modeling_tf_mistral.py | null | 9,669 |
class TFMistralAttention(keras.layers.Layer):
"""
Multi-headed attention from 'Attention Is All You Need' paper. Modified to use sliding window attention: Longformer
and "Generating Long Sequences with Sparse Transformers".
"""
def __init__(self, config: MistralConfig, layer_idx: Optional[int] = No... | class_definition | 9,652 | 16,026 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modeling_tf_mistral.py | null | 9,670 |
class TFMistralDecoderLayer(keras.layers.Layer):
def __init__(self, config: MistralConfig, layer_idx: int, **kwargs):
super().__init__(**kwargs)
self.hidden_size = config.hidden_size
self.self_attn = TFMistralAttention(config, layer_idx, name="self_attn")
self.mlp = TFMistralMLP(co... | class_definition | 16,029 | 19,775 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modeling_tf_mistral.py | null | 9,671 |
class TFMistralMainLayer(keras.layers.Layer):
"""
Transformer decoder consisting of *config.num_hidden_layers* layers. Each layer is a [`MistralDecoderLayer`]
Args:
config: MistralConfig
"""
config_class = MistralConfig
def __init__(self, config: MistralConfig, **kwargs):
supe... | class_definition | 19,798 | 26,447 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modeling_tf_mistral.py | null | 9,672 |
class TFMistralPreTrainedModel(TFPreTrainedModel):
config_class = MistralConfig
base_model_prefix = "model" | class_definition | 29,057 | 29,172 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modeling_tf_mistral.py | null | 9,673 |
class TFMistralModel(TFMistralPreTrainedModel):
def __init__(self, config: MistralConfig, *inputs, **kwargs):
super().__init__(config, *inputs, **kwargs)
self.model = TFMistralMainLayer(config, name="model")
@unpack_inputs
@add_start_docstrings_to_model_forward(MISTRAL_INPUTS_DOCSTRING)
... | class_definition | 33,454 | 34,973 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modeling_tf_mistral.py | null | 9,674 |
class TFMistralForCausalLM(TFMistralPreTrainedModel, TFCausalLanguageModelingLoss):
def __init__(self, config, *inputs, **kwargs):
super().__init__(config, *inputs, **kwargs)
self.model = TFMistralMainLayer(config, name="model")
self.vocab_size = config.vocab_size
self.lm_head = kera... | class_definition | 34,976 | 39,640 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modeling_tf_mistral.py | null | 9,675 |
class TFMistralForSequenceClassification(TFMistralPreTrainedModel, TFSequenceClassificationLoss):
def __init__(self, config, *inputs, **kwargs):
super().__init__(config, *inputs, **kwargs)
self.num_labels = config.num_labels
self.model = TFMistralMainLayer(config, name="model")
self.... | class_definition | 40,439 | 45,263 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modeling_tf_mistral.py | null | 9,676 |
class MistralMLP(LlamaMLP):
def __init__(self, config):
super().__init__(config)
self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
self.down_proj = nn.Linear(self.intermediat... | class_definition | 934 | 1,291 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modular_mistral.py | null | 9,677 |
class MistralAttention(LlamaAttention):
def __init__(self, config: MistralConfig, layer_idx: int):
super().__init__()
self.q_proj = nn.Linear(config.hidden_size, config.num_attention_heads * self.head_dim, bias=False)
self.k_proj = nn.Linear(config.hidden_size, config.num_key_value_heads * s... | class_definition | 1,294 | 4,351 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modular_mistral.py | null | 9,678 |
class MistralDecoderLayer(LlamaDecoderLayer):
def __init__(self, config: MistralConfig, layer_idx: int):
super().__init__(config, layer_idx)
self.self_attn = MistralAttention(config=config, layer_idx=layer_idx)
self.mlp = MistralMLP(config) | class_definition | 4,354 | 4,622 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modular_mistral.py | null | 9,679 |
class MistralModel(LlamaModel):
def __init__(self, config: MistralConfig):
super().__init__(config)
self.layers = nn.ModuleList(
[MistralDecoderLayer(config, layer_idx) for layer_idx in range(config.num_hidden_layers)]
)
def _update_causal_mask(
self,
attenti... | class_definition | 4,625 | 12,578 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modular_mistral.py | null | 9,680 |
class MistralForCausalLM(LlamaForCausalLM):
pass | class_definition | 12,581 | 12,633 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modular_mistral.py | null | 9,681 |
class MistralForTokenClassification(LlamaForTokenClassification):
pass | class_definition | 12,636 | 12,710 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modular_mistral.py | null | 9,682 |
class MistralForSequenceClassification(LlamaForSequenceClassification):
pass | class_definition | 12,713 | 12,793 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modular_mistral.py | null | 9,683 |
class MistralForQuestionAnswering(LlamaForQuestionAnswering):
base_model_prefix = "model"
def __init__(self, config):
super().__init__(config)
self.model = MistralModel(config) # diff with Llama: transformer->model
del self.transformer
def get_input_embeddings(self):
retur... | class_definition | 12,796 | 16,027 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modular_mistral.py | null | 9,684 |
class FlaxMistralRMSNorm(nn.Module):
config: MistralConfig
dtype: jnp.dtype = jnp.float32
def setup(self):
self.epsilon = self.config.rms_norm_eps
self.weight = self.param("weight", lambda _, shape: jnp.ones(shape), self.config.hidden_size)
def __call__(self, hidden_states):
va... | class_definition | 6,526 | 7,222 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modeling_flax_mistral.py | null | 9,685 |
class FlaxMistralRotaryEmbedding(nn.Module):
config: MistralConfig
dtype: jnp.dtype = jnp.float32
def setup(self):
head_dim = self.config.hidden_size // self.config.num_attention_heads
self.sincos = create_sinusoidal_positions(self.config.max_position_embeddings, head_dim)
def __call__... | class_definition | 7,330 | 8,034 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modeling_flax_mistral.py | null | 9,686 |
class FlaxMistralMLP(nn.Module):
config: MistralConfig
dtype: jnp.dtype = jnp.float32
def setup(self):
embed_dim = self.config.hidden_size
inner_dim = self.config.intermediate_size if self.config.intermediate_size is not None else 4 * embed_dim
kernel_init = jax.nn.initializers.nor... | class_definition | 8,130 | 9,099 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modeling_flax_mistral.py | null | 9,687 |
class FlaxMistralAttention(nn.Module):
config: MistralConfig
dtype: jnp.dtype = jnp.float32
def setup(self):
config = self.config
self.hidden_size = config.hidden_size
self.num_heads = config.num_attention_heads
self.head_dim = self.hidden_size // self.num_heads
self... | class_definition | 10,089 | 17,184 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modeling_flax_mistral.py | null | 9,688 |
class FlaxMistralDecoderLayer(nn.Module):
config: MistralConfig
dtype: jnp.dtype = jnp.float32
def setup(self):
self.input_layernorm = FlaxMistralRMSNorm(self.config, dtype=self.dtype)
self.self_attn = FlaxMistralAttention(self.config, dtype=self.dtype)
self.post_attention_layernorm... | class_definition | 17,289 | 18,714 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modeling_flax_mistral.py | null | 9,689 |
class FlaxMistralPreTrainedModel(FlaxPreTrainedModel):
"""
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
models.
"""
config_class = MistralConfig
base_model_prefix = "model"
module_class: nn.Module = None
def __init__(
... | class_definition | 18,866 | 24,189 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modeling_flax_mistral.py | null | 9,690 |
class FlaxMistralLayerCollection(nn.Module):
config: MistralConfig
dtype: jnp.dtype = jnp.float32
def setup(self):
self.blocks = [
FlaxMistralDecoderLayer(self.config, dtype=self.dtype, name=str(i))
for i in range(self.config.num_hidden_layers)
]
def __call__(
... | class_definition | 24,297 | 25,780 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modeling_flax_mistral.py | null | 9,691 |
class FlaxMistralModule(nn.Module):
config: MistralConfig
dtype: jnp.dtype = jnp.float32
def setup(self):
self.hidden_size = self.config.hidden_size
embedding_init = jax.nn.initializers.normal(stddev=self.config.initializer_range)
self.embed_tokens = nn.Embed(
self.confi... | class_definition | 25,879 | 27,779 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modeling_flax_mistral.py | null | 9,692 |
class FlaxMistralModel(FlaxMistralPreTrainedModel):
module_class = FlaxMistralModule | class_definition | 27,941 | 28,029 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modeling_flax_mistral.py | null | 9,693 |
class FlaxMistralForCausalLMModule(nn.Module):
config: MistralConfig
dtype: jnp.dtype = jnp.float32
def setup(self):
self.model = FlaxMistralModule(self.config, dtype=self.dtype)
self.lm_head = nn.Dense(
self.config.vocab_size,
use_bias=False,
dtype=self.... | class_definition | 28,320 | 29,692 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modeling_flax_mistral.py | null | 9,694 |
class FlaxMistralForCausalLM(FlaxMistralPreTrainedModel):
module_class = FlaxMistralForCausalLMModule
def prepare_inputs_for_generation(self, input_ids, max_length, attention_mask: Optional[jax.Array] = None):
# initializing the cache
batch_size, seq_length = input_ids.shape
past_key_v... | class_definition | 29,951 | 31,484 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modeling_flax_mistral.py | null | 9,695 |
class MistralConfig(PretrainedConfig):
r"""
This is the configuration class to store the configuration of a [`MistralModel`]. It is used to instantiate an
Mistral model according to the specified arguments, defining the model architecture. Instantiating a configuration
with the defaults will yield a sim... | class_definition | 799 | 7,533 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/configuration_mistral.py | null | 9,696 |
class MistralMLP(nn.Module):
def __init__(self, config):
super().__init__()
self.config = config
self.hidden_size = config.hidden_size
self.intermediate_size = config.intermediate_size
self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
se... | class_definition | 1,919 | 2,589 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modeling_mistral.py | null | 9,697 |
class MistralAttention(nn.Module):
"""Multi-headed attention from 'Attention Is All You Need' paper"""
def __init__(self, config: MistralConfig, layer_idx: int):
super().__init__()
self.config = config
self.layer_idx = layer_idx
self.head_dim = getattr(config, "head_dim", config... | class_definition | 5,868 | 9,383 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modeling_mistral.py | null | 9,698 |
class MistralRMSNorm(nn.Module):
def __init__(self, hidden_size, eps=1e-6):
"""
MistralRMSNorm 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 | 9,386 | 10,110 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/mistral/modeling_mistral.py | null | 9,699 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.