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 FlaxElectraDiscriminatorPredictions(nn.Module):
"""Prediction module for the discriminator, made up of two dense layers."""
config: ElectraConfig
dtype: jnp.dtype = jnp.float32
def setup(self):
self.dense = nn.Dense(self.config.hidden_size, dtype=self.dtype)
self.dense_prediction... | class_definition | 27,493 | 28,107 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_flax_electra.py | null | 3,800 |
class FlaxElectraPreTrainedModel(FlaxPreTrainedModel):
"""
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
models.
"""
config_class = ElectraConfig
base_model_prefix = "electra"
module_class: nn.Module = None
def __init__... | class_definition | 28,110 | 36,189 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_flax_electra.py | null | 3,801 |
class FlaxElectraModule(nn.Module):
config: ElectraConfig
dtype: jnp.dtype = jnp.float32 # the dtype of the computation
gradient_checkpointing: bool = False
def setup(self):
self.embeddings = FlaxElectraEmbeddings(self.config, dtype=self.dtype)
if self.config.embedding_size != self.con... | class_definition | 36,192 | 37,966 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_flax_electra.py | null | 3,802 |
class FlaxElectraModel(FlaxElectraPreTrainedModel):
module_class = FlaxElectraModule | class_definition | 38,128 | 38,216 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_flax_electra.py | null | 3,803 |
class FlaxElectraTiedDense(nn.Module):
embedding_size: int
dtype: jnp.dtype = jnp.float32
precision = None
bias_init: Callable[..., np.ndarray] = jax.nn.initializers.zeros
def setup(self):
self.bias = self.param("bias", self.bias_init, (self.embedding_size,))
def __call__(self, x, kern... | class_definition | 38,327 | 38,972 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_flax_electra.py | null | 3,804 |
class FlaxElectraForMaskedLMModule(nn.Module):
config: ElectraConfig
dtype: jnp.dtype = jnp.float32
gradient_checkpointing: bool = False
def setup(self):
self.electra = FlaxElectraModule(
config=self.config, dtype=self.dtype, gradient_checkpointing=self.gradient_checkpointing
... | class_definition | 38,975 | 41,027 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_flax_electra.py | null | 3,805 |
class FlaxElectraForMaskedLM(FlaxElectraPreTrainedModel):
module_class = FlaxElectraForMaskedLMModule | class_definition | 41,138 | 41,243 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_flax_electra.py | null | 3,806 |
class FlaxElectraForPreTrainingModule(nn.Module):
config: ElectraConfig
dtype: jnp.dtype = jnp.float32
gradient_checkpointing: bool = False
def setup(self):
self.electra = FlaxElectraModule(
config=self.config, dtype=self.dtype, gradient_checkpointing=self.gradient_checkpointing
... | class_definition | 41,359 | 42,840 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_flax_electra.py | null | 3,807 |
class FlaxElectraForPreTraining(FlaxElectraPreTrainedModel):
module_class = FlaxElectraForPreTrainingModule | class_definition | 43,111 | 43,222 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_flax_electra.py | null | 3,808 |
class FlaxElectraForTokenClassificationModule(nn.Module):
config: ElectraConfig
dtype: jnp.dtype = jnp.float32
gradient_checkpointing: bool = False
def setup(self):
self.electra = FlaxElectraModule(
config=self.config, dtype=self.dtype, gradient_checkpointing=self.gradient_checkpoin... | class_definition | 44,047 | 45,803 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_flax_electra.py | null | 3,809 |
class FlaxElectraForTokenClassification(FlaxElectraPreTrainedModel):
module_class = FlaxElectraForTokenClassificationModule | class_definition | 46,009 | 46,136 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_flax_electra.py | null | 3,810 |
class FlaxElectraSequenceSummary(nn.Module):
r"""
Compute a single vector summary of a sequence hidden states.
Args:
config ([`PretrainedConfig`]):
The config used by the model. Relevant arguments in the config class of the model are (refer to the actual
config class of your... | class_definition | 46,331 | 49,617 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_flax_electra.py | null | 3,811 |
class FlaxElectraForMultipleChoiceModule(nn.Module):
config: ElectraConfig
dtype: jnp.dtype = jnp.float32
gradient_checkpointing: bool = False
def setup(self):
self.electra = FlaxElectraModule(
config=self.config, dtype=self.dtype, gradient_checkpointing=self.gradient_checkpointing
... | class_definition | 49,620 | 51,777 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_flax_electra.py | null | 3,812 |
class FlaxElectraForMultipleChoice(FlaxElectraPreTrainedModel):
module_class = FlaxElectraForMultipleChoiceModule | class_definition | 52,014 | 52,131 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_flax_electra.py | null | 3,813 |
class FlaxElectraForQuestionAnsweringModule(nn.Module):
config: ElectraConfig
dtype: jnp.dtype = jnp.float32
gradient_checkpointing: bool = False
def setup(self):
self.electra = FlaxElectraModule(
config=self.config, dtype=self.dtype, gradient_checkpointing=self.gradient_checkpointi... | class_definition | 52,481 | 54,152 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_flax_electra.py | null | 3,814 |
class FlaxElectraForQuestionAnswering(FlaxElectraPreTrainedModel):
module_class = FlaxElectraForQuestionAnsweringModule | class_definition | 54,445 | 54,568 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_flax_electra.py | null | 3,815 |
class FlaxElectraClassificationHead(nn.Module):
"""Head for sentence-level classification tasks."""
config: ElectraConfig
dtype: jnp.dtype = jnp.float32
def setup(self):
self.dense = nn.Dense(self.config.hidden_size, dtype=self.dtype)
classifier_dropout = (
self.config.clas... | class_definition | 54,726 | 55,729 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_flax_electra.py | null | 3,816 |
class FlaxElectraForSequenceClassificationModule(nn.Module):
config: ElectraConfig
dtype: jnp.dtype = jnp.float32
gradient_checkpointing: bool = False
def setup(self):
self.electra = FlaxElectraModule(
config=self.config, dtype=self.dtype, gradient_checkpointing=self.gradient_checkp... | class_definition | 55,732 | 57,213 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_flax_electra.py | null | 3,817 |
class FlaxElectraForSequenceClassification(FlaxElectraPreTrainedModel):
module_class = FlaxElectraForSequenceClassificationModule | class_definition | 57,441 | 57,574 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_flax_electra.py | null | 3,818 |
class FlaxElectraForCausalLMModule(nn.Module):
config: ElectraConfig
dtype: jnp.dtype = jnp.float32
gradient_checkpointing: bool = False
def setup(self):
self.electra = FlaxElectraModule(
config=self.config, dtype=self.dtype, gradient_checkpointing=self.gradient_checkpointing
... | class_definition | 57,733 | 60,267 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_flax_electra.py | null | 3,819 |
class FlaxElectraForCausalLM(FlaxElectraPreTrainedModel):
module_class = FlaxElectraForCausalLMModule
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 | 60,579 | 62,116 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_flax_electra.py | null | 3,820 |
class ElectraConfig(PretrainedConfig):
r"""
This is the configuration class to store the configuration of a [`ElectraModel`] or a [`TFElectraModel`]. It is
used to instantiate a ELECTRA model according to the specified arguments, defining the model architecture.
Instantiating a configuration with the de... | class_definition | 962 | 8,592 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/configuration_electra.py | null | 3,821 |
class ElectraOnnxConfig(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 | 8,595 | 9,093 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/configuration_electra.py | null | 3,822 |
class TFElectraSelfAttention(keras.layers.Layer):
def __init__(self, config: ElectraConfig, **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 ... | class_definition | 2,027 | 8,853 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_tf_electra.py | null | 3,823 |
class TFElectraSelfOutput(keras.layers.Layer):
def __init__(self, config: ElectraConfig, **kwargs):
super().__init__(**kwargs)
self.dense = keras.layers.Dense(
units=config.hidden_size, kernel_initializer=get_initializer(config.initializer_range), name="dense"
)
self.Lay... | class_definition | 8,948 | 10,281 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_tf_electra.py | null | 3,824 |
class TFElectraAttention(keras.layers.Layer):
def __init__(self, config: ElectraConfig, **kwargs):
super().__init__(**kwargs)
self.self_attention = TFElectraSelfAttention(config, name="self")
self.dense_output = TFElectraSelfOutput(config, name="output")
def prune_heads(self, heads):
... | class_definition | 10,375 | 12,219 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_tf_electra.py | null | 3,825 |
class TFElectraIntermediate(keras.layers.Layer):
def __init__(self, config: ElectraConfig, **kwargs):
super().__init__(**kwargs)
self.dense = keras.layers.Dense(
units=config.intermediate_size, kernel_initializer=get_initializer(config.initializer_range), name="dense"
)
... | class_definition | 12,316 | 13,344 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_tf_electra.py | null | 3,826 |
class TFElectraOutput(keras.layers.Layer):
def __init__(self, config: ElectraConfig, **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 | 13,435 | 14,770 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_tf_electra.py | null | 3,827 |
class TFElectraLayer(keras.layers.Layer):
def __init__(self, config: ElectraConfig, **kwargs):
super().__init__(**kwargs)
self.attention = TFElectraAttention(config, name="attention")
self.is_decoder = config.is_decoder
self.add_cross_attention = config.add_cross_attention
i... | class_definition | 14,860 | 19,607 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_tf_electra.py | null | 3,828 |
class TFElectraEncoder(keras.layers.Layer):
def __init__(self, config: ElectraConfig, **kwargs):
super().__init__(**kwargs)
self.config = config
self.layer = [TFElectraLayer(config, name=f"layer_._{i}") for i in range(config.num_hidden_layers)]
def call(
self,
hidden_sta... | class_definition | 19,699 | 22,789 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_tf_electra.py | null | 3,829 |
class TFElectraPooler(keras.layers.Layer):
def __init__(self, config: ElectraConfig, **kwargs):
super().__init__(**kwargs)
self.dense = keras.layers.Dense(
units=config.hidden_size,
kernel_initializer=get_initializer(config.initializer_range),
activation="tanh",
... | class_definition | 22,880 | 23,855 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_tf_electra.py | null | 3,830 |
class TFElectraEmbeddings(keras.layers.Layer):
"""Construct the embeddings from word, position and token_type embeddings."""
def __init__(self, config: ElectraConfig, **kwargs):
super().__init__(**kwargs)
self.config = config
self.embedding_size = config.embedding_size
self.max... | class_definition | 23,958 | 27,405 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_tf_electra.py | null | 3,831 |
class TFElectraDiscriminatorPredictions(keras.layers.Layer):
def __init__(self, config, **kwargs):
super().__init__(**kwargs)
self.dense = keras.layers.Dense(config.hidden_size, name="dense")
self.dense_prediction = keras.layers.Dense(1, name="dense_prediction")
self.config = config... | class_definition | 27,408 | 28,521 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_tf_electra.py | null | 3,832 |
class TFElectraGeneratorPredictions(keras.layers.Layer):
def __init__(self, config, **kwargs):
super().__init__(**kwargs)
self.LayerNorm = keras.layers.LayerNormalization(epsilon=config.layer_norm_eps, name="LayerNorm")
self.dense = keras.layers.Dense(config.embedding_size, name="dense")
... | class_definition | 28,524 | 29,612 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_tf_electra.py | null | 3,833 |
class TFElectraPreTrainedModel(TFPreTrainedModel):
"""
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
models.
"""
config_class = ElectraConfig
base_model_prefix = "electra"
# When the model is loaded from a PT model
_keys... | class_definition | 29,615 | 30,047 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_tf_electra.py | null | 3,834 |
class TFElectraMainLayer(keras.layers.Layer):
config_class = ElectraConfig
def __init__(self, config, **kwargs):
super().__init__(**kwargs)
self.config = config
self.is_decoder = config.is_decoder
self.embeddings = TFElectraEmbeddings(config, name="embeddings")
if con... | class_definition | 30,070 | 39,430 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_tf_electra.py | null | 3,835 |
class TFElectraForPreTrainingOutput(ModelOutput):
"""
Output type of [`TFElectraForPreTraining`].
Args:
loss (*optional*, returned when `labels` is provided, `tf.Tensor` of shape `(1,)`):
Total loss of the ELECTRA objective.
logits (`tf.Tensor` of shape `(batch_size, sequence_le... | class_definition | 39,444 | 40,837 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_tf_electra.py | null | 3,836 |
class TFElectraModel(TFElectraPreTrainedModel):
def __init__(self, config, *inputs, **kwargs):
super().__init__(config, *inputs, **kwargs)
self.electra = TFElectraMainLayer(config, name="electra")
@unpack_inputs
@add_start_docstrings_to_model_forward(ELECTRA_INPUTS_DOCSTRING.format("batch_... | class_definition | 46,609 | 50,477 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_tf_electra.py | null | 3,837 |
class TFElectraForPreTraining(TFElectraPreTrainedModel):
def __init__(self, config, **kwargs):
super().__init__(config, **kwargs)
self.electra = TFElectraMainLayer(config, name="electra")
self.discriminator_predictions = TFElectraDiscriminatorPredictions(config, name="discriminator_predicti... | class_definition | 50,874 | 54,006 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_tf_electra.py | null | 3,838 |
class TFElectraMaskedLMHead(keras.layers.Layer):
def __init__(self, config, input_embeddings, **kwargs):
super().__init__(**kwargs)
self.config = config
self.embedding_size = config.embedding_size
self.input_embeddings = input_embeddings
def build(self, input_shape):
se... | class_definition | 54,009 | 55,385 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_tf_electra.py | null | 3,839 |
class TFElectraForMaskedLM(TFElectraPreTrainedModel, TFMaskedLanguageModelingLoss):
def __init__(self, config, **kwargs):
super().__init__(config, **kwargs)
self.config = config
self.electra = TFElectraMainLayer(config, name="electra")
self.generator_predictions = TFElectraGenerator... | class_definition | 55,707 | 59,962 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_tf_electra.py | null | 3,840 |
class TFElectraClassificationHead(keras.layers.Layer):
"""Head for sentence-level classification tasks."""
def __init__(self, config, **kwargs):
super().__init__(**kwargs)
self.dense = keras.layers.Dense(
config.hidden_size, kernel_initializer=get_initializer(config.initializer_ran... | class_definition | 59,965 | 61,574 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_tf_electra.py | null | 3,841 |
class TFElectraForSequenceClassification(TFElectraPreTrainedModel, TFSequenceClassificationLoss):
def __init__(self, config, *inputs, **kwargs):
super().__init__(config, *inputs, **kwargs)
self.num_labels = config.num_labels
self.electra = TFElectraMainLayer(config, name="electra")
s... | class_definition | 61,802 | 64,980 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_tf_electra.py | null | 3,842 |
class TFElectraForMultipleChoice(TFElectraPreTrainedModel, TFMultipleChoiceLoss):
def __init__(self, config, *inputs, **kwargs):
super().__init__(config, *inputs, **kwargs)
self.electra = TFElectraMainLayer(config, name="electra")
self.sequence_summary = TFSequenceSummary(
confi... | class_definition | 65,217 | 69,698 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_tf_electra.py | null | 3,843 |
class TFElectraForTokenClassification(TFElectraPreTrainedModel, TFTokenClassificationLoss):
def __init__(self, config, **kwargs):
super().__init__(config, **kwargs)
self.electra = TFElectraMainLayer(config, name="electra")
classifier_dropout = (
config.classifier_dropout if conf... | class_definition | 69,904 | 73,548 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_tf_electra.py | null | 3,844 |
class TFElectraForQuestionAnswering(TFElectraPreTrainedModel, TFQuestionAnsweringLoss):
def __init__(self, config, *inputs, **kwargs):
super().__init__(config, *inputs, **kwargs)
self.num_labels = config.num_labels
self.electra = TFElectraMainLayer(config, name="electra")
self.qa_ou... | class_definition | 73,841 | 78,332 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_tf_electra.py | null | 3,845 |
class ElectraTokenizer(PreTrainedTokenizer):
r"""
Construct a Electra tokenizer. Based on WordPiece.
This tokenizer inherits from [`PreTrainedTokenizer`] which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.
Args:
vocab... | class_definition | 1,761 | 12,436 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/tokenization_electra.py | null | 3,846 |
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 | 12,511 | 19,259 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/tokenization_electra.py | null | 3,847 |
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 | 19,338 | 21,226 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/tokenization_electra.py | null | 3,848 |
class ElectraTokenizerFast(PreTrainedTokenizerFast):
r"""
Construct a "fast" ELECTRA 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 for ... | class_definition | 1,057 | 7,684 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/tokenization_electra_fast.py | null | 3,849 |
class ElectraEmbeddings(nn.Module):
"""Construct the embeddings from word, position and token_type embeddings."""
def __init__(self, config):
super().__init__()
self.word_embeddings = nn.Embedding(config.vocab_size, config.embedding_size, padding_idx=config.pad_token_id)
self.position_e... | class_definition | 5,445 | 8,714 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_electra.py | null | 3,850 |
class ElectraSelfAttention(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 | 8,807 | 16,155 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_electra.py | null | 3,851 |
class ElectraSelfOutput(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)
de... | class_definition | 16,226 | 16,835 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_electra.py | null | 3,852 |
class ElectraAttention(nn.Module):
def __init__(self, config, position_embedding_type=None):
super().__init__()
self.self = ELECTRA_SELF_ATTENTION_CLASSES[config._attn_implementation](
config, position_embedding_type=position_embedding_type
)
self.output = ElectraSelfOutp... | class_definition | 17,012 | 19,143 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_electra.py | null | 3,853 |
class ElectraIntermediate(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.int... | class_definition | 19,216 | 19,784 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_electra.py | null | 3,854 |
class ElectraOutput(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 | 19,851 | 20,462 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_electra.py | null | 3,855 |
class ElectraLayer(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 = ElectraAttention(config)
self.is_decoder = config.is_decoder
self.add_cross_attention = co... | class_definition | 20,547 | 24,469 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_electra.py | null | 3,856 |
class ElectraEncoder(nn.Module):
def __init__(self, config):
super().__init__()
self.config = config
self.layer = nn.ModuleList([ElectraLayer(config) for _ in range(config.num_hidden_layers)])
self.gradient_checkpointing = False
def forward(
self,
hidden_states: ... | class_definition | 24,556 | 28,352 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_electra.py | null | 3,857 |
class ElectraDiscriminatorPredictions(nn.Module):
"""Prediction module for the discriminator, made up of two dense layers."""
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.hidden_size)
self.activation = get_activation(config.hidden_act... | class_definition | 28,355 | 29,031 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_electra.py | null | 3,858 |
class ElectraGeneratorPredictions(nn.Module):
"""Prediction module for the generator, made up of two dense layers."""
def __init__(self, config):
super().__init__()
self.activation = get_activation("gelu")
self.LayerNorm = nn.LayerNorm(config.embedding_size, eps=config.layer_norm_eps)
... | class_definition | 29,034 | 29,675 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_electra.py | null | 3,859 |
class ElectraPreTrainedModel(PreTrainedModel):
"""
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
models.
"""
config_class = ElectraConfig
load_tf_weights = load_tf_weights_in_electra
base_model_prefix = "electra"
support... | class_definition | 29,678 | 30,931 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_electra.py | null | 3,860 |
class ElectraForPreTrainingOutput(ModelOutput):
"""
Output type of [`ElectraForPreTraining`].
Args:
loss (*optional*, returned when `labels` is provided, `torch.FloatTensor` of shape `(1,)`):
Total loss of the ELECTRA objective.
logits (`torch.FloatTensor` of shape `(batch_size,... | class_definition | 30,945 | 32,457 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_electra.py | null | 3,861 |
class ElectraModel(ElectraPreTrainedModel):
def __init__(self, config):
super().__init__(config)
self.embeddings = ElectraEmbeddings(config)
if config.embedding_size != config.hidden_size:
self.embeddings_project = nn.Linear(config.embedding_size, config.hidden_size)
se... | class_definition | 37,095 | 42,673 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_electra.py | null | 3,862 |
class ElectraClassificationHead(nn.Module):
"""Head for sentence-level classification tasks."""
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.hidden_size)
classifier_dropout = (
config.classifier_dropout if config.classifier... | class_definition | 42,676 | 43,576 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_electra.py | null | 3,863 |
class ElectraForSequenceClassification(ElectraPreTrainedModel):
def __init__(self, config):
super().__init__(config)
self.num_labels = config.num_labels
self.config = config
self.electra = ElectraModel(config)
self.classifier = ElectraClassificationHead(config)
# Ini... | class_definition | 43,804 | 47,724 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_electra.py | null | 3,864 |
class ElectraForPreTraining(ElectraPreTrainedModel):
def __init__(self, config):
super().__init__(config)
self.electra = ElectraModel(config)
self.discriminator_predictions = ElectraDiscriminatorPredictions(config)
# Initialize weights and apply final processing
self.post_in... | class_definition | 47,995 | 52,218 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_electra.py | null | 3,865 |
class ElectraForMaskedLM(ElectraPreTrainedModel):
_tied_weights_keys = ["generator_lm_head.weight"]
def __init__(self, config):
super().__init__(config)
self.electra = ElectraModel(config)
self.generator_predictions = ElectraGeneratorPredictions(config)
self.generator_lm_head ... | class_definition | 52,540 | 55,966 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_electra.py | null | 3,866 |
class ElectraForTokenClassification(ElectraPreTrainedModel):
def __init__(self, config):
super().__init__(config)
self.num_labels = config.num_labels
self.electra = ElectraModel(config)
classifier_dropout = (
config.classifier_dropout if config.classifier_dropout is not ... | class_definition | 56,172 | 59,343 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_electra.py | null | 3,867 |
class ElectraForQuestionAnswering(ElectraPreTrainedModel):
config_class = ElectraConfig
base_model_prefix = "electra"
def __init__(self, config):
super().__init__(config)
self.num_labels = config.num_labels
self.electra = ElectraModel(config)
self.qa_outputs = nn.Linear(con... | class_definition | 59,636 | 64,164 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_electra.py | null | 3,868 |
class ElectraForMultipleChoice(ElectraPreTrainedModel):
def __init__(self, config):
super().__init__(config)
self.electra = ElectraModel(config)
self.sequence_summary = SequenceSummary(config)
self.classifier = nn.Linear(config.hidden_size, 1)
# Initialize weights and apply... | class_definition | 64,401 | 68,014 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_electra.py | null | 3,869 |
class ElectraForCausalLM(ElectraPreTrainedModel, GenerationMixin):
_tied_weights_keys = ["generator_lm_head.weight"]
def __init__(self, config):
super().__init__(config)
if not config.is_decoder:
logger.warning("If you want to use `ElectraForCausalLM` as a standalone, add `is_decod... | class_definition | 68,151 | 74,820 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/electra/modeling_electra.py | null | 3,870 |
class BitImageProcessor(BaseImageProcessor):
r"""
Constructs a BiT image processor.
Args:
do_resize (`bool`, *optional*, defaults to `True`):
Whether to resize the image's (height, width) dimensions to the specified `size`. Can be overridden by
`do_resize` in the `preprocess... | class_definition | 1,424 | 15,789 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bit/image_processing_bit.py | null | 3,871 |
class WeightStandardizedConv2d(nn.Conv2d):
"""Conv2d with Weight Standardization. Includes TensorFlow compatible SAME padding. Used for ViT Hybrid model.
Paper: [Micro-Batch Training with Batch-Channel Normalization and Weight
Standardization](https://arxiv.org/abs/1903.10520v2)
"""
def __init__(
... | class_definition | 3,558 | 5,079 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bit/modeling_bit.py | null | 3,872 |
class BitGroupNormActivation(nn.GroupNorm):
r"""
A module that combines group normalization with an activation function.
"""
def __init__(self, config, num_channels, eps=1e-5, affine=True, apply_activation=True):
super(BitGroupNormActivation, self).__init__(config.num_groups, num_channels, eps=... | class_definition | 5,082 | 5,796 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bit/modeling_bit.py | null | 3,873 |
class DynamicPad2d(nn.Module):
r"""
A module that wraps dynamic padding of any input, given the parameters of the convolutional layer and the input
hidden states.
"""
def __init__(self, kernel_size, stride, dilation, value=0):
super().__init__()
# Safety checkers
if isinstan... | class_definition | 5,799 | 7,514 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bit/modeling_bit.py | null | 3,874 |
class BitMaxPool2d(nn.MaxPool2d):
"""Tensorflow like 'SAME' wrapper for 2D max pooling"""
def __init__(
self,
kernel_size: int,
stride=None,
dilation=1,
ceil_mode=False,
padding=(0, 0),
padding_value=0,
use_dynamic_padding=True,
):
ker... | class_definition | 7,517 | 8,623 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bit/modeling_bit.py | null | 3,875 |
class BitEmbeddings(nn.Module):
"""
BiT Embeddings (stem) composed of a single aggressive convolution.
"""
def __init__(self, config: BitConfig):
super().__init__()
self.convolution = WeightStandardizedConv2d(
config.num_channels,
config.embedding_size,
... | class_definition | 8,626 | 10,217 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bit/modeling_bit.py | null | 3,876 |
class BitDropPath(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) -> torch.... | class_definition | 11,464 | 11,941 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bit/modeling_bit.py | null | 3,877 |
class BitPreActivationBottleneckLayer(nn.Module):
"""Pre-activation (v2) bottleneck block.
Follows the implementation of "Identity Mappings in Deep Residual Networks":
https://github.com/KaimingHe/resnet-1k-layers/blob/master/resnet-pre-act.lua
Except it puts the stride on 3x3 conv when available.
... | class_definition | 12,162 | 14,507 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bit/modeling_bit.py | null | 3,878 |
class BitBottleneckLayer(nn.Module):
"""Non Pre-activation bottleneck block, equivalent to V1.5/V1b bottleneck. Used for ViT Hybrid."""
def __init__(
self,
config,
in_channels,
out_channels=None,
bottle_ratio=0.25,
stride=1,
dilation=1,
first_dila... | class_definition | 14,510 | 16,952 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bit/modeling_bit.py | null | 3,879 |
class BitDownsampleConv(nn.Module):
def __init__(
self,
config,
in_channels,
out_channels,
stride=1,
preact=True,
):
super().__init__()
self.conv = WeightStandardizedConv2d(
in_channels, out_channels, 1, stride=stride, eps=1e-8, padding... | class_definition | 16,955 | 17,552 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bit/modeling_bit.py | null | 3,880 |
class BitStage(nn.Module):
"""
A ResNet v2 stage composed by stacked layers.
"""
def __init__(
self,
config,
in_channels,
out_channels,
stride,
dilation,
depth,
bottle_ratio=0.25,
layer_dropout=None,
):
super().__init__... | class_definition | 17,555 | 19,685 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bit/modeling_bit.py | null | 3,881 |
class BitEncoder(nn.Module):
def __init__(self, config: BitConfig):
super().__init__()
self.stages = nn.ModuleList([])
prev_chs = config.embedding_size
# These needs to stay hardcoded
current_stride = 4
dilation = 1
layer_dropouts = [
x.tolist()... | class_definition | 19,688 | 22,071 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bit/modeling_bit.py | null | 3,882 |
class BitPreTrainedModel(PreTrainedModel):
"""
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
models.
"""
config_class = BitConfig
base_model_prefix = "bit"
main_input_name = "pixel_values"
_no_split_modules = ["BitEmbedd... | class_definition | 22,074 | 23,178 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bit/modeling_bit.py | null | 3,883 |
class BitModel(BitPreTrainedModel):
def __init__(self, config):
super().__init__(config)
self.config = config
self.embedder = BitEmbeddings(config)
self.encoder = BitEncoder(config)
self.norm = (
BitGroupNormActivation(config, num_channels=config.hidden_sizes[-1... | class_definition | 24,537 | 26,519 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bit/modeling_bit.py | null | 3,884 |
class BitForImageClassification(BitPreTrainedModel):
def __init__(self, config):
super().__init__(config)
self.num_labels = config.num_labels
self.bit = BitModel(config)
# classification head
self.classifier = nn.Sequential(
nn.Flatten(),
nn.Linear(con... | class_definition | 26,715 | 29,841 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bit/modeling_bit.py | null | 3,885 |
class BitBackbone(BitPreTrainedModel, BackboneMixin):
def __init__(self, config):
super().__init__(config)
super()._init_backbone(config)
self.bit = BitModel(config)
self.num_features = [config.embedding_size] + config.hidden_sizes
# initialize weights and apply final proce... | class_definition | 29,982 | 32,198 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bit/modeling_bit.py | null | 3,886 |
class BitConfig(BackboneConfigMixin, PretrainedConfig):
r"""
This is the configuration class to store the configuration of a [`BitModel`]. It is used to instantiate an BiT
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
defaults will yi... | class_definition | 880 | 6,268 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bit/configuration_bit.py | null | 3,887 |
class LukeConfig(PretrainedConfig):
r"""
This is the configuration class to store the configuration of a [`LukeModel`]. It is used to instantiate a LUKE
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
defaults will yield a similar confi... | class_definition | 766 | 6,592 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/luke/configuration_luke.py | null | 3,888 |
class BaseLukeModelOutputWithPooling(BaseModelOutputWithPooling):
"""
Base class for outputs of the LUKE model.
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 model.
... | class_definition | 1,443 | 3,714 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/luke/modeling_luke.py | null | 3,889 |
class BaseLukeModelOutput(BaseModelOutput):
"""
Base class for model's outputs, with potential hidden states and attentions.
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 ... | class_definition | 3,728 | 5,738 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/luke/modeling_luke.py | null | 3,890 |
class LukeMaskedLMOutput(ModelOutput):
"""
Base class for model's outputs, with potential hidden states and attentions.
Args:
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
The sum of masked language modeling (MLM) loss and entity prediction ... | class_definition | 5,752 | 8,589 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/luke/modeling_luke.py | null | 3,891 |
class EntityClassificationOutput(ModelOutput):
"""
Outputs of entity classification models.
Args:
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
Classification loss.
logits (`torch.FloatTensor` of shape `(batch_size, config.num_labels... | class_definition | 8,603 | 10,602 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/luke/modeling_luke.py | null | 3,892 |
class EntityPairClassificationOutput(ModelOutput):
"""
Outputs of entity pair classification models.
Args:
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
Classification loss.
logits (`torch.FloatTensor` of shape `(batch_size, config.n... | class_definition | 10,616 | 12,624 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/luke/modeling_luke.py | null | 3,893 |
class EntitySpanClassificationOutput(ModelOutput):
"""
Outputs of entity span classification models.
Args:
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
Classification loss.
logits (`torch.FloatTensor` of shape `(batch_size, entity_l... | class_definition | 12,638 | 14,661 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/luke/modeling_luke.py | null | 3,894 |
class LukeSequenceClassifierOutput(ModelOutput):
"""
Outputs of sentence classification models.
Args:
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
Classification (or regression if config.num_labels==1) loss.
logits (`torch.FloatTens... | class_definition | 14,675 | 16,819 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/luke/modeling_luke.py | null | 3,895 |
class LukeTokenClassifierOutput(ModelOutput):
"""
Base class for outputs of token classification models.
Args:
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided) :
Classification loss.
logits (`torch.FloatTensor` of shape `(batch_size, seq... | class_definition | 16,833 | 18,924 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/luke/modeling_luke.py | null | 3,896 |
class LukeQuestionAnsweringModelOutput(ModelOutput):
"""
Outputs of question answering models.
Args:
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
Total span extraction loss is the sum of a Cross-Entropy for the start and end positions.
... | class_definition | 18,938 | 21,246 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/luke/modeling_luke.py | null | 3,897 |
class LukeMultipleChoiceModelOutput(ModelOutput):
"""
Outputs of multiple choice models.
Args:
loss (`torch.FloatTensor` of shape *(1,)*, *optional*, returned when `labels` is provided):
Classification loss.
logits (`torch.FloatTensor` of shape `(batch_size, num_choices)`):
... | class_definition | 21,260 | 23,409 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/luke/modeling_luke.py | null | 3,898 |
class LukeEmbeddings(nn.Module):
"""
Same as BertEmbeddings with a tiny tweak for positional embeddings indexing.
"""
def __init__(self, config):
super().__init__()
self.word_embeddings = nn.Embedding(config.vocab_size, config.hidden_size, padding_idx=config.pad_token_id)
self.p... | class_definition | 23,412 | 26,316 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/luke/modeling_luke.py | null | 3,899 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.