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 TapasLMPredictionHead(nn.Module):
def __init__(self, config):
super().__init__()
self.transform = TapasPredictionHeadTransform(config)
# The output weights are the same as the input embeddings, but there is
# an output-only bias for each token.
self.decoder = nn.Linear... | class_definition | 29,854 | 30,688 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tapas.py | null | 5,300 |
class TapasOnlyMLMHead(nn.Module):
def __init__(self, config):
super().__init__()
self.predictions = TapasLMPredictionHead(config)
def forward(self, sequence_output: torch.Tensor) -> torch.Tensor:
prediction_scores = self.predictions(sequence_output)
return prediction_scores | class_definition | 30,777 | 31,093 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tapas.py | null | 5,301 |
class TapasPreTrainedModel(PreTrainedModel):
"""
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
models.
"""
config_class = TapasConfig
base_model_prefix = "tapas"
supports_gradient_checkpointing = True
_supports_param_buf... | class_definition | 31,096 | 32,340 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tapas.py | null | 5,302 |
class TapasModel(TapasPreTrainedModel):
"""
This class is a small change compared to [`BertModel`], taking into account the additional token type ids.
The model can behave as an encoder (with only self-attention) as well as a decoder, in which case a layer of
cross-attention is added between the self-a... | class_definition | 36,021 | 43,075 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tapas.py | null | 5,303 |
class TapasForMaskedLM(TapasPreTrainedModel):
_tied_weights_keys = ["cls.predictions.decoder.weight", "cls.predictions.decoder.bias"]
config_class = TapasConfig
base_model_prefix = "tapas"
def __init__(self, config):
super().__init__(config)
self.tapas = TapasModel(config, add_pooling_... | class_definition | 43,182 | 47,589 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tapas.py | null | 5,304 |
class TapasForQuestionAnswering(TapasPreTrainedModel):
def __init__(self, config: TapasConfig):
super().__init__(config)
# base model
self.tapas = TapasModel(config)
# dropout (only used when training)
self.dropout = nn.Dropout(config.hidden_dropout_prob)
# cell se... | class_definition | 47,941 | 64,547 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tapas.py | null | 5,305 |
class TapasForSequenceClassification(TapasPreTrainedModel):
def __init__(self, config):
super().__init__(config)
self.num_labels = config.num_labels
self.tapas = TapasModel(config)
self.dropout = nn.Dropout(config.hidden_dropout_prob)
self.classifier = nn.Linear(config.hidde... | class_definition | 64,798 | 69,829 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tapas.py | null | 5,306 |
class AverageApproximationFunction(str, enum.Enum):
RATIO = "ratio"
FIRST_ORDER = "first_order"
SECOND_ORDER = "second_order" | class_definition | 69,858 | 69,995 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tapas.py | null | 5,307 |
class IndexMap:
"""Index grouping entries within a tensor."""
def __init__(self, indices, num_segments, batch_dims=0):
"""
Creates an index
Args:
indices (`torch.LongTensor`, same shape as a *values* Tensor to which the indices refer):
Tensor containing the ... | class_definition | 70,055 | 71,230 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tapas.py | null | 5,308 |
class ProductIndexMap(IndexMap):
"""The product of two indices."""
def __init__(self, outer_index, inner_index):
"""
Combines indices i and j into pairs (i, j). The result is an index where each segment (i, j) is the
intersection of segments i and j. For example if the inputs represent ... | class_definition | 71,233 | 73,340 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tapas.py | null | 5,309 |
class TFTableQuestionAnsweringOutput(ModelOutput):
"""
Output type of [`TFTapasForQuestionAnswering`].
Args:
loss (`tf.Tensor` of shape `(1,)`, *optional*, returned when `labels` (and possibly `answer`, `aggregation_labels`, `numeric_values` and `numeric_values_scale` are provided)):
To... | class_definition | 2,849 | 4,746 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tf_tapas.py | null | 5,310 |
class TFTapasEmbeddings(keras.layers.Layer):
"""
Construct the embeddings from word, position and token_type embeddings. Same as BertEmbeddings but with a number of
additional token type embeddings to encode tabular structure.
"""
def __init__(self, config: TapasConfig, **kwargs):
super()._... | class_definition | 4,749 | 9,959 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tf_tapas.py | null | 5,311 |
class TFTapasSelfAttention(keras.layers.Layer):
def __init__(self, config: TapasConfig, **kwargs):
super().__init__(**kwargs)
if config.hidden_size % config.num_attention_heads != 0:
raise ValueError(
f"The hidden size ({config.hidden_size}) is not a multiple of the numb... | class_definition | 10,055 | 16,875 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tf_tapas.py | null | 5,312 |
class TFTapasSelfOutput(keras.layers.Layer):
def __init__(self, config: TapasConfig, **kwargs):
super().__init__(**kwargs)
self.dense = keras.layers.Dense(
units=config.hidden_size, kernel_initializer=get_initializer(config.initializer_range), name="dense"
)
self.LayerNo... | class_definition | 16,968 | 18,297 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tf_tapas.py | null | 5,313 |
class TFTapasAttention(keras.layers.Layer):
def __init__(self, config: TapasConfig, **kwargs):
super().__init__(**kwargs)
self.self_attention = TFTapasSelfAttention(config, name="self")
self.dense_output = TFTapasSelfOutput(config, name="output")
def prune_heads(self, heads):
r... | class_definition | 18,389 | 20,225 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tf_tapas.py | null | 5,314 |
class TFTapasIntermediate(keras.layers.Layer):
def __init__(self, config: TapasConfig, **kwargs):
super().__init__(**kwargs)
self.dense = keras.layers.Dense(
units=config.intermediate_size, kernel_initializer=get_initializer(config.initializer_range), name="dense"
)
if ... | class_definition | 20,320 | 21,344 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tf_tapas.py | null | 5,315 |
class TFTapasOutput(keras.layers.Layer):
def __init__(self, config: TapasConfig, **kwargs):
super().__init__(**kwargs)
self.dense = keras.layers.Dense(
units=config.hidden_size, kernel_initializer=get_initializer(config.initializer_range), name="dense"
)
self.LayerNorm =... | class_definition | 21,433 | 22,764 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tf_tapas.py | null | 5,316 |
class TFTapasLayer(keras.layers.Layer):
def __init__(self, config: TapasConfig, **kwargs):
super().__init__(**kwargs)
self.attention = TFTapasAttention(config, name="attention")
self.is_decoder = config.is_decoder
self.add_cross_attention = config.add_cross_attention
if self... | class_definition | 22,852 | 27,587 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tf_tapas.py | null | 5,317 |
class TFTapasEncoder(keras.layers.Layer):
def __init__(self, config: TapasConfig, **kwargs):
super().__init__(**kwargs)
self.config = config
self.layer = [TFTapasLayer(config, name=f"layer_._{i}") for i in range(config.num_hidden_layers)]
def call(
self,
hidden_states: t... | class_definition | 27,677 | 30,761 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tf_tapas.py | null | 5,318 |
class TFTapasPooler(keras.layers.Layer):
def __init__(self, config: TapasConfig, **kwargs):
super().__init__(**kwargs)
self.dense = keras.layers.Dense(
units=config.hidden_size,
kernel_initializer=get_initializer(config.initializer_range),
activation="tanh",
... | class_definition | 30,850 | 31,821 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tf_tapas.py | null | 5,319 |
class TFTapasPredictionHeadTransform(keras.layers.Layer):
def __init__(self, config: TapasConfig, **kwargs):
super().__init__(**kwargs)
self.dense = keras.layers.Dense(
units=config.hidden_size,
kernel_initializer=get_initializer(config.initializer_range),
name="... | class_definition | 31,927 | 33,326 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tf_tapas.py | null | 5,320 |
class TFTapasLMPredictionHead(keras.layers.Layer):
def __init__(self, config: TapasConfig, input_embeddings: keras.layers.Layer, **kwargs):
super().__init__(**kwargs)
self.config = config
self.hidden_size = config.hidden_size
self.transform = TFTapasPredictionHeadTransform(config, ... | class_definition | 33,425 | 35,387 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tf_tapas.py | null | 5,321 |
class TFTapasMLMHead(keras.layers.Layer):
def __init__(self, config: TapasConfig, input_embeddings: keras.layers.Layer, **kwargs):
super().__init__(**kwargs)
self.predictions = TFTapasLMPredictionHead(config, input_embeddings, name="predictions")
def call(self, sequence_output: tf.Tensor) -> t... | class_definition | 35,477 | 36,183 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tf_tapas.py | null | 5,322 |
class TFTapasMainLayer(keras.layers.Layer):
config_class = TapasConfig
def __init__(self, config: TapasConfig, add_pooling_layer: bool = True, **kwargs):
super().__init__(**kwargs)
self.config = config
self.embeddings = TFTapasEmbeddings(config, name="embeddings")
self.encoder... | class_definition | 36,206 | 42,030 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tf_tapas.py | null | 5,323 |
class TFTapasPreTrainedModel(TFPreTrainedModel):
"""
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
models.
"""
config_class = TapasConfig
base_model_prefix = "tapas"
@property
def input_signature(self):
return {... | class_definition | 42,033 | 42,634 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tf_tapas.py | null | 5,324 |
class TFTapasModel(TFTapasPreTrainedModel):
def __init__(self, config: TapasConfig, *inputs, **kwargs):
super().__init__(config, *inputs, **kwargs)
self.tapas = TFTapasMainLayer(config, name="tapas")
@unpack_inputs
@add_start_docstrings_to_model_forward(TAPAS_INPUTS_DOCSTRING.format("batch... | class_definition | 48,654 | 51,340 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tf_tapas.py | null | 5,325 |
class TFTapasForMaskedLM(TFTapasPreTrainedModel, TFMaskedLanguageModelingLoss):
def __init__(self, config: TapasConfig, *inputs, **kwargs):
super().__init__(config, *inputs, **kwargs)
if config.is_decoder:
logger.warning(
"If you want to use `TFTapasForMaskedLM` make sur... | class_definition | 51,447 | 55,846 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tf_tapas.py | null | 5,326 |
class TFTapasComputeTokenLogits(keras.layers.Layer):
def __init__(self, config: TapasConfig, **kwargs):
super().__init__(**kwargs)
self.temperature = config.temperature
# cell selection heads
with tf.name_scope("output"):
self.output_weights = self.add_weight(
... | class_definition | 55,849 | 57,304 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tf_tapas.py | null | 5,327 |
class TFTapasComputeColumnLogits(keras.layers.Layer):
def __init__(self, config: TapasConfig, **kwargs):
super().__init__(**kwargs)
with tf.name_scope("column_output"):
self.column_output_weights = self.add_weight(
name="column_output_weights",
shape=[con... | class_definition | 57,307 | 60,204 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tf_tapas.py | null | 5,328 |
class TFTapasForQuestionAnswering(TFTapasPreTrainedModel):
def __init__(self, config: TapasConfig, *inputs, **kwargs):
super().__init__(config, *inputs, **kwargs)
# base model
self.tapas = TFTapasMainLayer(config, name="tapas")
# dropout
self.dropout = keras.layers.Dropout(... | class_definition | 60,556 | 76,839 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tf_tapas.py | null | 5,329 |
class TFTapasForSequenceClassification(TFTapasPreTrainedModel, TFSequenceClassificationLoss):
def __init__(self, config: TapasConfig, *inputs, **kwargs):
super().__init__(config, *inputs, **kwargs)
self.num_labels = config.num_labels
self.tapas = TFTapasMainLayer(config, name="tapas")
... | class_definition | 77,090 | 81,916 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tf_tapas.py | null | 5,330 |
class AverageApproximationFunction(str, enum.Enum):
RATIO = "ratio"
FIRST_ORDER = "first_order"
SECOND_ORDER = "second_order" | class_definition | 81,945 | 82,082 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tf_tapas.py | null | 5,331 |
class IndexMap:
"""Index grouping entries within a tensor."""
def __init__(self, indices, num_segments, batch_dims=0):
"""
Creates an index.
Args:
indices: <int32> Tensor of indices, same shape as `values`.
num_segments: <int32> Scalar tensor, the number of segments... | class_definition | 82,142 | 83,118 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tf_tapas.py | null | 5,332 |
class ProductIndexMap(IndexMap):
"""The product of two indices."""
def __init__(self, outer_index, inner_index):
"""
Combines indices i and j into pairs (i, j). The result is an index where each segment (i, j) is the
intersection of segments i and j. For example if the inputs represent ... | class_definition | 83,121 | 85,183 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/modeling_tf_tapas.py | null | 5,333 |
class TapasTruncationStrategy(ExplicitEnum):
"""
Possible values for the `truncation` argument in [`~TapasTokenizer.__call__`]. Useful for tab-completion in an IDE.
"""
DROP_ROWS_TO_FIT = "drop_rows_to_fit"
DO_NOT_TRUNCATE = "do_not_truncate" | class_definition | 1,440 | 1,703 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/tokenization_tapas.py | null | 5,334 |
class TokenCoordinates:
column_index: int
row_index: int
token_index: int | class_definition | 1,816 | 1,901 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/tokenization_tapas.py | null | 5,335 |
class TokenizedTable:
rows: List[List[List[str]]]
selected_tokens: List[TokenCoordinates] | class_definition | 1,915 | 2,012 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/tokenization_tapas.py | null | 5,336 |
class SerializedExample:
tokens: List[str]
column_ids: List[int]
row_ids: List[int]
segment_ids: List[int] | class_definition | 2,039 | 2,161 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/tokenization_tapas.py | null | 5,337 |
class TapasTokenizer(PreTrainedTokenizer):
r"""
Construct a TAPAS tokenizer. Based on WordPiece. Flattens a table and one or more related sentences to be used by
TAPAS models.
This tokenizer inherits from [`PreTrainedTokenizer`] which contains most of the main methods. Users should refer to
this su... | class_definition | 5,907 | 89,933 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/tokenization_tapas.py | null | 5,338 |
class BasicTokenizer:
"""
Constructs a BasicTokenizer that will run basic tokenization (punctuation splitting, lower casing, etc.).
Args:
do_lower_case (`bool`, *optional*, defaults to `True`):
Whether or not to lowercase the input when tokenizing.
never_split (`Iterable`, *opti... | class_definition | 90,008 | 96,756 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/tokenization_tapas.py | null | 5,339 |
class WordpieceTokenizer:
"""Runs WordPiece tokenization."""
def __init__(self, vocab, unk_token, max_input_chars_per_word=100):
self.vocab = vocab
self.unk_token = unk_token
self.max_input_chars_per_word = max_input_chars_per_word
def tokenize(self, text):
"""
Toke... | class_definition | 96,835 | 98,723 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/tokenization_tapas.py | null | 5,340 |
class Relation(enum.Enum):
HEADER_TO_CELL = 1 # Connects header to cell.
CELL_TO_HEADER = 2 # Connects cell to header.
QUERY_TO_HEADER = 3 # Connects query to headers.
QUERY_TO_CELL = 4 # Connects query to cells.
ROW_TO_CELL = 5 # Connects row to cells.
CELL_TO_ROW = 6 # Connects cells to ... | class_definition | 99,320 | 99,810 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/tokenization_tapas.py | null | 5,341 |
class Date:
year: Optional[int] = None
month: Optional[int] = None
day: Optional[int] = None | class_definition | 99,824 | 99,928 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/tokenization_tapas.py | null | 5,342 |
class NumericValue:
float_value: Optional[float] = None
date: Optional[Date] = None | class_definition | 99,942 | 100,033 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/tokenization_tapas.py | null | 5,343 |
class NumericValueSpan:
begin_index: int = None
end_index: int = None
values: List[NumericValue] = None | class_definition | 100,047 | 100,162 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/tokenization_tapas.py | null | 5,344 |
class Cell:
text: str
numeric_value: Optional[NumericValue] = None | class_definition | 100,176 | 100,250 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/tokenization_tapas.py | null | 5,345 |
class Question:
original_text: str # The original raw question string.
text: str # The question string after normalization.
numeric_spans: Optional[List[NumericValueSpan]] = None | class_definition | 100,264 | 100,456 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/tokenization_tapas.py | null | 5,346 |
class TapasConfig(PretrainedConfig):
r"""
This is the configuration class to store the configuration of a [`TapasModel`]. It is used to instantiate a TAPAS
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
defaults will yield a similar co... | class_definition | 1,034 | 12,264 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/tapas/configuration_tapas.py | null | 5,347 |
class Data2VecTextConfig(PretrainedConfig):
r"""
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... | class_definition | 878 | 6,818 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/configuration_data2vec_text.py | null | 5,348 |
class Data2VecTextOnnxConfig(OnnxConfig):
@property
def inputs(self) -> Mapping[str, Mapping[int, str]]:
if self.task == "multiple-choice":
dynamic_axis = {0: "batch", 1: "choice", 2: "sequence"}
else:
dynamic_axis = {0: "batch", 1: "sequence"}
return OrderedDict(... | class_definition | 6,821 | 7,274 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/configuration_data2vec_text.py | null | 5,349 |
class Data2VecVisionModelOutputWithPooling(BaseModelOutputWithPooling):
"""
Class for outputs of [`Data2VecVisionModel`].
Args:
last_hidden_state (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`):
Sequence of hidden-states at the output of the last layer of the... | class_definition | 1,972 | 3,524 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_data2vec_vision.py | null | 5,350 |
class Data2VecVisionDropPath(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 = drop_prob
def forward(self, hidden_states: torch.Tensor... | class_definition | 4,774 | 5,262 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_data2vec_vision.py | null | 5,351 |
class Data2VecVisionEmbeddings(nn.Module):
"""
Construct the CLS token, position and patch embeddings. Optionally, also the mask token.
"""
def __init__(self, config: Data2VecVisionConfig) -> None:
super().__init__()
self.cls_token = nn.Parameter(torch.zeros(1, 1, config.hidden_size))... | class_definition | 5,359 | 9,691 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_data2vec_vision.py | null | 5,352 |
class Data2VecVisionPatchEmbeddings(nn.Module):
"""
This class turns `pixel_values` of shape `(batch_size, num_channels, height, width)` into the initial
`hidden_states` (patch embeddings) of shape `(batch_size, seq_length, hidden_size)` to be consumed by a
Transformer.
"""
def __init__(self, c... | class_definition | 9,793 | 12,164 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_data2vec_vision.py | null | 5,353 |
class Data2VecVisionSelfAttention(nn.Module):
def __init__(self, config: Data2VecVisionConfig, window_size: Optional[tuple] = None) -> None:
super().__init__()
self.config = config
if config.hidden_size % config.num_attention_heads != 0 and not hasattr(config, "embedding_size"):
... | class_definition | 12,264 | 16,122 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_data2vec_vision.py | null | 5,354 |
class Data2VecVisionSdpaSelfAttention(Data2VecVisionSelfAttention):
def forward(
self,
hidden_states: torch.Tensor,
head_mask: Optional[torch.Tensor] = None,
output_attentions: bool = False,
relative_position_bias: Optional["Data2VecVisionRelativePositionBias"] = None,
... | class_definition | 16,226 | 19,195 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_data2vec_vision.py | null | 5,355 |
class Data2VecVisionSelfOutput(nn.Module):
"""
The residual connection is defined in Data2VecVisionLayer instead of here (as is the case with other models), due to the
layernorm applied before each block.
"""
def __init__(self, config: Data2VecVisionConfig) -> None:
super().__init__()
... | class_definition | 19,292 | 19,980 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_data2vec_vision.py | null | 5,356 |
class Data2VecVisionAttention(nn.Module):
def __init__(self, config: Data2VecVisionConfig, window_size: Optional[tuple] = None) -> None:
super().__init__()
self.attention = DATA2VEC_VISION_SELF_ATTENTION_CLASSES[config._attn_implementation](
config, window_size=window_size
)
... | class_definition | 20,226 | 22,321 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_data2vec_vision.py | null | 5,357 |
class Data2VecVisionIntermediate(nn.Module):
def __init__(self, config: Data2VecVisionConfig) -> None:
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_ac... | class_definition | 22,420 | 23,026 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_data2vec_vision.py | null | 5,358 |
class Data2VecVisionOutput(nn.Module):
def __init__(self, config: Data2VecVisionConfig) -> None:
super().__init__()
self.dense = nn.Linear(config.intermediate_size, config.hidden_size)
self.dropout = nn.Dropout(config.hidden_dropout_prob)
def forward(self, hidden_states: torch.Tensor) -... | class_definition | 23,119 | 23,586 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_data2vec_vision.py | null | 5,359 |
class Data2VecVisionLayer(nn.Module):
"""This corresponds to the Block class in the timm implementation."""
def __init__(
self, config: Data2VecVisionConfig, window_size: Optional[tuple] = None, drop_path_rate: float = 0.0
) -> None:
super().__init__()
self.chunk_size_feed_forward =... | class_definition | 23,699 | 26,663 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_data2vec_vision.py | null | 5,360 |
class Data2VecVisionRelativePositionBias(nn.Module):
def __init__(self, config: Data2VecVisionConfig, window_size: tuple) -> None:
super().__init__()
self.window_size = window_size
self.num_relative_distance = (2 * window_size[0] - 1) * (2 * window_size[1] - 1) + 3
self.relative_posi... | class_definition | 26,770 | 31,232 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_data2vec_vision.py | null | 5,361 |
class Data2VecVisionEncoder(nn.Module):
def __init__(self, config: Data2VecVisionConfig, window_size: Optional[tuple] = None) -> None:
super().__init__()
self.config = config
if config.use_shared_relative_position_bias:
self.relative_position_bias = Data2VecVisionRelativePosition... | class_definition | 31,326 | 34,707 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_data2vec_vision.py | null | 5,362 |
class Data2VecVisionPreTrainedModel(PreTrainedModel):
"""
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
models.
"""
config_class = Data2VecVisionConfig
base_model_prefix = "data2vec_vision"
main_input_name = "pixel_values"
... | class_definition | 34,831 | 36,184 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_data2vec_vision.py | null | 5,363 |
class Data2VecVisionModel(Data2VecVisionPreTrainedModel):
def __init__(self, config: Data2VecVisionConfig, add_pooling_layer: bool = False) -> None:
super().__init__(config)
self.config = config
self.embeddings = Data2VecVisionEmbeddings(config)
self.encoder = Data2VecVisionEncoder(... | class_definition | 38,411 | 42,514 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_data2vec_vision.py | null | 5,364 |
class Data2VecVisionPooler(nn.Module):
def __init__(self, config: Data2VecVisionConfig) -> None:
super().__init__()
self.layernorm = (
nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps) if config.use_mean_pooling else None
)
def forward(self, hidden_states: torch.Te... | class_definition | 42,607 | 43,342 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_data2vec_vision.py | null | 5,365 |
class Data2VecVisionForImageClassification(Data2VecVisionPreTrainedModel):
def __init__(self, config: Data2VecVisionConfig) -> None:
super().__init__(config)
self.num_labels = config.num_labels
self.data2vec_vision = Data2VecVisionModel(config, add_pooling_layer=True)
# Classifier ... | class_definition | 43,761 | 47,420 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_data2vec_vision.py | null | 5,366 |
class Data2VecVisionConvModule(nn.Module):
"""
A convolutional block that bundles conv/norm/activation layers. This block simplifies the usage of convolution
layers, which are commonly used with a norm layer (e.g., BatchNorm) and activation layer (e.g., ReLU).
Based on OpenMMLab's implementation, found... | class_definition | 47,517 | 48,718 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_data2vec_vision.py | null | 5,367 |
class Data2VecVisionPyramidPoolingBlock(nn.Module):
def __init__(self, pool_scale: int, in_channels: int, channels: int) -> None:
super().__init__()
self.layers = [
nn.AdaptiveAvgPool2d(pool_scale),
Data2VecVisionConvModule(in_channels, channels, kernel_size=1),
]
... | class_definition | 48,824 | 49,430 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_data2vec_vision.py | null | 5,368 |
class Data2VecVisionPyramidPoolingModule(nn.Module):
"""
Pyramid Pooling Module (PPM) used in PSPNet.
Args:
pool_scales (tuple[int]): Pooling scales used in Pooling Pyramid
Module.
in_channels (int): Input channels.
channels (int): Channels after modules, before conv_seg... | class_definition | 49,537 | 51,026 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_data2vec_vision.py | null | 5,369 |
class Data2VecVisionUperHead(nn.Module):
"""
Unified Perceptual Parsing for Scene Understanding. This head is the implementation of
[UPerNet](https://arxiv.org/abs/1807.10221).
Based on OpenMMLab's implementation, found in https://github.com/open-mmlab/mmsegmentation.
"""
def __init__(self, co... | class_definition | 51,121 | 54,381 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_data2vec_vision.py | null | 5,370 |
class Data2VecVisionFCNHead(nn.Module):
"""
Fully Convolution Networks for Semantic Segmentation. This head is implemented of
[FCNNet](https://arxiv.org/abs/1411.4038>).
Args:
config (Data2VecVisionConfig): Configuration.
in_channels
kernel_size (int): The kernel size for convs ... | class_definition | 54,475 | 56,821 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_data2vec_vision.py | null | 5,371 |
class Data2VecVisionForSemanticSegmentation(Data2VecVisionPreTrainedModel):
def __init__(self, config: Data2VecVisionConfig) -> None:
super().__init__(config)
self.num_labels = config.num_labels
self.data2vec_vision = Data2VecVisionModel(config, add_pooling_layer=False)
# FPNs
... | class_definition | 57,234 | 63,640 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_data2vec_vision.py | null | 5,372 |
class TFData2VecVisionModelOutputWithPooling(TFBaseModelOutputWithPooling):
"""
Class for outputs of [`TFData2VecVisionModel`].
Args:
last_hidden_state (`tf.Tensor` of shape `(batch_size, sequence_length, hidden_size)`):
Sequence of hidden-states at the output of the last layer of the m... | class_definition | 1,942 | 3,626 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_tf_data2vec_vision.py | null | 5,373 |
class TFData2VecVisionDropPath(keras.layers.Layer):
"""Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks).
References:
(1) github.com:rwightman/pytorch-image-models
"""
def __init__(self, drop_path, **kwargs):
super().__init__(**kwargs)
self.... | class_definition | 3,629 | 4,334 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_tf_data2vec_vision.py | null | 5,374 |
class TFData2VecVisionEmbeddings(keras.layers.Layer):
"""
Construct the CLS token, position and patch embeddings. Optionally, also the mask token.
"""
def __init__(self, config: Data2VecVisionConfig, **kwargs):
super().__init__(**kwargs)
self.config = config
self.patch_embeddi... | class_definition | 4,337 | 7,186 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_tf_data2vec_vision.py | null | 5,375 |
class TFData2VecVisionPatchEmbeddings(keras.layers.Layer):
"""
Image to Patch Embedding.
"""
def __init__(self, config: Data2VecVisionConfig, **kwargs):
super().__init__(**kwargs)
self.config = config
image_size, patch_size = config.image_size, config.patch_size
num_cha... | class_definition | 7,189 | 10,215 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_tf_data2vec_vision.py | null | 5,376 |
class TFData2VecVisionSelfAttention(keras.layers.Layer):
def __init__(self, config: Data2VecVisionConfig, window_size: Optional[tuple] = None, **kwargs):
super().__init__(**kwargs)
if config.hidden_size % config.num_attention_heads != 0:
raise ValueError(
f"The hidden si... | class_definition | 10,218 | 15,908 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_tf_data2vec_vision.py | null | 5,377 |
class TFData2VecVisionSelfOutput(keras.layers.Layer):
"""
The residual connection is defined in TFData2VecVisionLayer instead of here (as is the case with other models), due
to the layernorm applied before each block.
"""
def __init__(self, config: Data2VecVisionConfig, **kwargs):
super()._... | class_definition | 15,911 | 17,087 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_tf_data2vec_vision.py | null | 5,378 |
class TFData2VecVisionAttention(keras.layers.Layer):
def __init__(self, config: Data2VecVisionConfig, window_size: Optional[tuple] = None, **kwargs):
super().__init__(**kwargs)
self.attention = TFData2VecVisionSelfAttention(config, window_size=window_size, name="attention")
self.dense_outpu... | class_definition | 17,090 | 18,750 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_tf_data2vec_vision.py | null | 5,379 |
class TFData2VecVisionIntermediate(keras.layers.Layer):
def __init__(self, config: Data2VecVisionConfig, **kwargs):
super().__init__(**kwargs)
self.dense = keras.layers.Dense(
units=config.intermediate_size, kernel_initializer=get_initializer(config.initializer_range), name="dense"
... | class_definition | 18,850 | 19,892 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_tf_data2vec_vision.py | null | 5,380 |
class TFData2VecVisionOutput(keras.layers.Layer):
def __init__(self, config: Data2VecVisionConfig, **kwargs):
super().__init__(**kwargs)
self.dense = keras.layers.Dense(
units=config.hidden_size, kernel_initializer=get_initializer(config.initializer_range), name="dense"
)
... | class_definition | 19,895 | 20,851 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_tf_data2vec_vision.py | null | 5,381 |
class TFData2VecVisionLayer(keras.layers.Layer):
"""This corresponds to the Block class in the timm implementation."""
def __init__(
self, config: Data2VecVisionConfig, window_size: Optional[tuple] = None, drop_path_rate: float = 0.0, **kwargs
):
super().__init__(**kwargs)
self.conf... | class_definition | 20,854 | 25,515 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_tf_data2vec_vision.py | null | 5,382 |
class TFData2VecVisionRelativePositionBias(keras.layers.Layer):
def __init__(self, config: Data2VecVisionConfig, window_size: tuple, **kwargs) -> None:
super().__init__(**kwargs)
self.config = config
self.window_size = window_size
# +3 for cls_token_pos_len
# window_size can... | class_definition | 25,661 | 28,350 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_tf_data2vec_vision.py | null | 5,383 |
class TFData2VecVisionEncoder(keras.layers.Layer):
def __init__(self, config: Data2VecVisionConfig, window_size: Optional[tuple] = None, **kwargs):
super().__init__(**kwargs)
self.config = config
if config.use_shared_relative_position_bias:
self.relative_position_bias = TFData2Ve... | class_definition | 28,353 | 31,550 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_tf_data2vec_vision.py | null | 5,384 |
class TFData2VecVisionMainLayer(keras.layers.Layer):
config_class = Data2VecVisionConfig
def __init__(self, config: Data2VecVisionConfig, add_pooling_layer: bool = True, **kwargs):
super().__init__(**kwargs)
self.config = config
self.add_pooling_layer = add_pooling_layer
self.... | class_definition | 31,573 | 36,094 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_tf_data2vec_vision.py | null | 5,385 |
class TFData2VecVisionPooler(keras.layers.Layer):
def __init__(self, config: Data2VecVisionConfig, **kwargs):
super().__init__(**kwargs)
self.layernorm = (
keras.layers.LayerNormalization(epsilon=config.layer_norm_eps, name="layernorm")
if config.use_mean_pooling
... | class_definition | 36,097 | 37,278 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_tf_data2vec_vision.py | null | 5,386 |
class TFData2VecVisionPreTrainedModel(TFPreTrainedModel):
"""
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
models.
"""
config_class = Data2VecVisionConfig
base_model_prefix = "data2vec_vision"
main_input_name = "pixel_value... | class_definition | 37,281 | 37,673 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_tf_data2vec_vision.py | null | 5,387 |
class TFData2VecVisionModel(TFData2VecVisionPreTrainedModel):
def __init__(self, config: Data2VecVisionConfig, add_pooling_layer: bool = False, *inputs, **kwargs):
super().__init__(config, *inputs, **kwargs)
self.config = config
self.data2vec_vision = TFData2VecVisionMainLayer(
... | class_definition | 41,939 | 44,066 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_tf_data2vec_vision.py | null | 5,388 |
class TFData2VecVisionForImageClassification(TFData2VecVisionPreTrainedModel, TFSequenceClassificationLoss):
def __init__(self, config: Data2VecVisionConfig, *inputs, **kwargs):
super().__init__(config, *inputs, **kwargs)
self.num_labels = config.num_labels
self.data2vec_vision = TFData2Vec... | class_definition | 44,335 | 47,569 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_tf_data2vec_vision.py | null | 5,389 |
class TFData2VecVisionConvModule(keras.layers.Layer):
"""
A convolutional block that bundles conv/norm/activation layers. This block simplifies the usage of convolution
layers, which are commonly used with a norm layer (e.g., BatchNorm) and activation layer (e.g., ReLU).
Based on OpenMMLab's implementa... | class_definition | 47,572 | 49,345 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_tf_data2vec_vision.py | null | 5,390 |
class TFAdaptiveAvgPool2D(keras.layers.Layer):
def __init__(self, output_dims: Tuple[int, int], input_ordering: str = "NHWC", **kwargs):
super().__init__(**kwargs)
self.output_dims = output_dims
self.input_ordering = input_ordering
if input_ordering not in ("NCHW", "NHWC"):
... | class_definition | 49,348 | 55,476 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_tf_data2vec_vision.py | null | 5,391 |
class TFData2VecVisionPyramidPoolingModule(keras.layers.Layer):
"""
Pyramid Pooling Module (PPM) used in PSPNet.
Args:
pool_scales (tuple[int]): Pooling scales used in Pooling Pyramid
Module.
channels (int): Channels after modules, before conv_seg.
Based on OpenMMLab's impl... | class_definition | 55,479 | 57,309 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_tf_data2vec_vision.py | null | 5,392 |
class TFData2VecVisionUperHead(keras.layers.Layer):
"""
Unified Perceptual Parsing for Scene Understanding. This head is the implementation of
[UPerNet](https://arxiv.org/abs/1807.10221).
Based on OpenMMLab's implementation, found in https://github.com/open-mmlab/mmsegmentation.
"""
def __init... | class_definition | 57,312 | 61,729 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_tf_data2vec_vision.py | null | 5,393 |
class TFData2VecVisionFCNHead(keras.layers.Layer):
"""
Fully Convolution Networks for Semantic Segmentation. This head is implemented from
[FCNNet](https://arxiv.org/abs/1411.4038).
Args:
config (Data2VecVisionConfig): Configuration.
kernel_size (int): The kernel size for convs in the h... | class_definition | 61,732 | 64,901 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_tf_data2vec_vision.py | null | 5,394 |
class TFData2VecVisionForSemanticSegmentation(TFData2VecVisionPreTrainedModel):
def __init__(self, config: Data2VecVisionConfig, *inputs, **kwargs) -> None:
super().__init__(config, *inputs, **kwargs)
self.num_labels = config.num_labels
self.data2vec_vision = TFData2VecVisionMainLayer(config... | class_definition | 65,090 | 73,347 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_tf_data2vec_vision.py | null | 5,395 |
class Data2VecVisionConfig(PretrainedConfig):
r"""
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... | class_definition | 931 | 8,759 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/configuration_data2vec_vision.py | null | 5,396 |
class Data2VecVisionOnnxConfig(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 | 8,832 | 9,239 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/configuration_data2vec_vision.py | null | 5,397 |
class Data2VecTextForTextEmbeddings(nn.Module):
"""
Same as BertEmbeddings with a tiny tweak for positional embeddings indexing.
"""
# Copied from transformers.models.bert.modeling_bert.BertEmbeddings.__init__
def __init__(self, config):
super().__init__()
self.word_embeddings = nn.... | class_definition | 1,907 | 6,099 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_data2vec_text.py | null | 5,398 |
class Data2VecTextSelfAttention(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_... | class_definition | 6,209 | 13,567 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/data2vec/modeling_data2vec_text.py | null | 5,399 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.