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 TFConvNextV2GRN(keras.layers.Layer):
"""GRN (Global Response Normalization) layer"""
def __init__(self, config: ConvNextV2Config, dim: int, **kwargs):
super().__init__(**kwargs)
self.dim = dim
def build(self, input_shape: tf.TensorShape = None):
# PT's `nn.Parameters` must be... | class_definition | 2,671 | 3,818 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/convnextv2/modeling_tf_convnextv2.py | null | 2,900 |
class TFConvNextV2Embeddings(keras.layers.Layer):
"""This class is comparable to (and inspired by) the SwinEmbeddings class
found in src/transformers/models/swin/modeling_swin.py.
"""
def __init__(self, config: ConvNextV2Config, **kwargs):
super().__init__(**kwargs)
self.patch_embedding... | class_definition | 3,932 | 6,052 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/convnextv2/modeling_tf_convnextv2.py | null | 2,901 |
class TFConvNextV2Layer(keras.layers.Layer):
"""This corresponds to the `Block` class in the original implementation.
There are two equivalent implementations: [DwConv, LayerNorm (channels_first), Conv, GELU,1x1 Conv]; all in (N, C,
H, W) (2) [DwConv, Permute to (N, H, W, C), LayerNorm (channels_last), Lin... | class_definition | 6,055 | 9,896 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/convnextv2/modeling_tf_convnextv2.py | null | 2,902 |
class TFConvNextV2Stage(keras.layers.Layer):
"""ConvNextV2 stage, consisting of an optional downsampling layer + multiple residual blocks.
Args:
config (`ConvNextV2V2Config`):
Model configuration class.
in_channels (`int`):
Number of input channels.
out_channels ... | class_definition | 10,005 | 13,214 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/convnextv2/modeling_tf_convnextv2.py | null | 2,903 |
class TFConvNextV2Encoder(keras.layers.Layer):
def __init__(self, config: ConvNextV2Config, **kwargs):
super().__init__(**kwargs)
self.stages = []
drop_path_rates = tf.linspace(0.0, config.drop_path_rate, sum(config.depths))
drop_path_rates = tf.split(drop_path_rates, config.depths)
... | class_definition | 13,217 | 15,124 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/convnextv2/modeling_tf_convnextv2.py | null | 2,904 |
class TFConvNextV2MainLayer(keras.layers.Layer):
config_class = ConvNextV2Config
def __init__(self, config: ConvNextV2Config, **kwargs):
super().__init__(**kwargs)
self.config = config
self.embeddings = TFConvNextV2Embeddings(config, name="embeddings")
self.encoder = TFConvNext... | class_definition | 15,147 | 18,262 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/convnextv2/modeling_tf_convnextv2.py | null | 2,905 |
class TFConvNextV2PreTrainedModel(TFPreTrainedModel):
"""
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
models.
"""
config_class = ConvNextV2Config
base_model_prefix = "convnextv2"
main_input_name = "pixel_values" | class_definition | 18,265 | 18,574 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/convnextv2/modeling_tf_convnextv2.py | null | 2,906 |
class TFConvNextV2Model(TFConvNextV2PreTrainedModel):
def __init__(self, config: ConvNextV2Config, *inputs, **kwargs):
super().__init__(config, *inputs, **kwargs)
self.convnextv2 = TFConvNextV2MainLayer(config, name="convnextv2")
@unpack_inputs
@add_start_docstrings_to_model_forward(CONVNEX... | class_definition | 22,165 | 24,150 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/convnextv2/modeling_tf_convnextv2.py | null | 2,907 |
class TFConvNextV2ForImageClassification(TFConvNextV2PreTrainedModel, TFSequenceClassificationLoss):
def __init__(self, config: ConvNextV2Config, *inputs, **kwargs):
super().__init__(config, *inputs, **kwargs)
self.num_labels = config.num_labels
self.convnextv2 = TFConvNextV2MainLayer(confi... | class_definition | 24,360 | 27,604 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/convnextv2/modeling_tf_convnextv2.py | null | 2,908 |
class ConvNextV2DropPath(nn.Module):
"""Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks)."""
def __init__(self, drop_prob: Optional[float] = None) -> None:
super().__init__()
self.drop_prob = drop_prob
def forward(self, hidden_states: torch.Tensor) ->... | class_definition | 2,994 | 3,478 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/convnextv2/modeling_convnextv2.py | null | 2,909 |
class ConvNextV2GRN(nn.Module):
"""GRN (Global Response Normalization) layer"""
def __init__(self, dim: int):
super().__init__()
self.weight = nn.Parameter(torch.zeros(1, 1, 1, dim))
self.bias = nn.Parameter(torch.zeros(1, 1, 1, dim))
def forward(self, hidden_states: torch.FloatTen... | class_definition | 3,481 | 4,192 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/convnextv2/modeling_convnextv2.py | null | 2,910 |
class ConvNextV2LayerNorm(nn.Module):
r"""LayerNorm that supports two data formats: channels_last (default) or channels_first.
The ordering of the dimensions in the inputs. channels_last corresponds to inputs with shape (batch_size, height,
width, channels) while channels_first corresponds to inputs with sh... | class_definition | 4,300 | 5,778 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/convnextv2/modeling_convnextv2.py | null | 2,911 |
class ConvNextV2Embeddings(nn.Module):
"""This class is comparable to (and inspired by) the SwinEmbeddings class
found in src/transformers/models/swin/modeling_swin.py.
"""
def __init__(self, config):
super().__init__()
self.patch_embeddings = nn.Conv2d(
config.num_channels,... | class_definition | 5,887 | 6,913 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/convnextv2/modeling_convnextv2.py | null | 2,912 |
class ConvNextV2Layer(nn.Module):
"""This corresponds to the `Block` class in the original implementation.
There are two equivalent implementations: [DwConv, LayerNorm (channels_first), Conv, GELU,1x1 Conv]; all in (N, C,
H, W) (2) [DwConv, Permute to (N, H, W, C), LayerNorm (channels_last), Linear, GELU, ... | class_definition | 6,916 | 8,699 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/convnextv2/modeling_convnextv2.py | null | 2,913 |
class ConvNextV2Stage(nn.Module):
"""ConvNeXTV2 stage, consisting of an optional downsampling layer + multiple residual blocks.
Args:
config ([`ConvNextV2Config`]): Model configuration class.
in_channels (`int`): Number of input channels.
out_channels (`int`): Number of output channels.... | class_definition | 8,825 | 10,229 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/convnextv2/modeling_convnextv2.py | null | 2,914 |
class ConvNextV2Encoder(nn.Module):
def __init__(self, config):
super().__init__()
self.stages = nn.ModuleList()
drop_path_rates = [
x.tolist() for x in torch.linspace(0, config.drop_path_rate, sum(config.depths)).split(config.depths)
]
prev_chs = config.hidden_si... | class_definition | 10,335 | 11,987 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/convnextv2/modeling_convnextv2.py | null | 2,915 |
class ConvNextV2PreTrainedModel(PreTrainedModel):
"""
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
models.
"""
config_class = ConvNextV2Config
base_model_prefix = "convnextv2"
main_input_name = "pixel_values"
_no_split_... | class_definition | 12,123 | 13,055 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/convnextv2/modeling_convnextv2.py | null | 2,916 |
class ConvNextV2Model(ConvNextV2PreTrainedModel):
def __init__(self, config):
super().__init__(config)
self.config = config
self.embeddings = ConvNextV2Embeddings(config)
self.encoder = ConvNextV2Encoder(config)
# final layernorm layer
self.layernorm = nn.LayerNorm(... | class_definition | 14,580 | 16,674 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/convnextv2/modeling_convnextv2.py | null | 2,917 |
class ConvNextV2ForImageClassification(ConvNextV2PreTrainedModel):
def __init__(self, config):
super().__init__(config)
self.num_labels = config.num_labels
self.convnextv2 = ConvNextV2Model(config)
# Classifier head
self.classifier = (
nn.Linear(config.hidden_si... | class_definition | 17,044 | 20,313 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/convnextv2/modeling_convnextv2.py | null | 2,918 |
class ConvNextV2Backbone(ConvNextV2PreTrainedModel, BackboneMixin):
def __init__(self, config):
super().__init__(config)
super()._init_backbone(config)
self.embeddings = ConvNextV2Embeddings(config)
self.encoder = ConvNextV2Encoder(config)
self.num_features = [config.hidden_... | class_definition | 20,654 | 23,594 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/convnextv2/modeling_convnextv2.py | null | 2,919 |
class ConvNextV2Config(BackboneConfigMixin, PretrainedConfig):
r"""
This is the configuration class to store the configuration of a [`ConvNextV2Model`]. It is used to instantiate an
ConvNeXTV2 model according to the specified arguments, defining the model architecture. Instantiating a
configuration with... | class_definition | 912 | 5,530 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/convnextv2/configuration_convnextv2.py | null | 2,920 |
class VitPoseConfig(PretrainedConfig):
r"""
This is the configuration class to store the configuration of a [`VitPoseForPoseEstimation`]. It is used to instantiate a
VitPose model according to the specified arguments, defining the model architecture. Instantiating a configuration
with the defaults will ... | class_definition | 906 | 5,710 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/vitpose/configuration_vitpose.py | null | 2,921 |
class VitPoseEstimatorOutput(ModelOutput):
"""
Class for outputs of pose estimation models.
Args:
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
Loss is not supported at this moment. See https://github.com/ViTAE-Transformer/ViTPose/tree/main/... | class_definition | 1,231 | 2,859 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/vitpose/modeling_vitpose.py | null | 2,922 |
class VitPosePreTrainedModel(PreTrainedModel):
"""
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
models.
"""
config_class = VitPoseConfig
base_model_prefix = "vit"
main_input_name = "pixel_values"
supports_gradient_check... | class_definition | 2,862 | 3,929 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/vitpose/modeling_vitpose.py | null | 2,923 |
class VitPoseSimpleDecoder(nn.Module):
"""
Simple decoding head consisting of a ReLU activation, 4x upsampling and a 3x3 convolution, turning the
feature maps into heatmaps.
"""
def __init__(self, config) -> None:
super().__init__()
self.activation = nn.ReLU()
self.upsampli... | class_definition | 8,034 | 9,004 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/vitpose/modeling_vitpose.py | null | 2,924 |
class VitPoseClassicDecoder(nn.Module):
"""
Classic decoding head consisting of a 2 deconvolutional blocks, followed by a 1x1 convolution layer,
turning the feature maps into heatmaps.
"""
def __init__(self, config: VitPoseConfig):
super().__init__()
self.deconv1 = nn.ConvTranspose... | class_definition | 9,007 | 10,344 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/vitpose/modeling_vitpose.py | null | 2,925 |
class VitPoseForPoseEstimation(VitPosePreTrainedModel):
def __init__(self, config: VitPoseConfig) -> None:
super().__init__(config)
self.backbone = load_backbone(config)
# add backbone attributes
if not hasattr(self.backbone.config, "hidden_size"):
raise ValueError("The... | class_definition | 10,462 | 14,634 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/vitpose/modeling_vitpose.py | null | 2,926 |
class VitPoseImageProcessor(BaseImageProcessor):
r"""
Constructs a VitPose image processor.
Args:
do_affine_transform (`bool`, *optional*, defaults to `True`):
Whether to apply an affine transformation to the input images.
size (`Dict[str, int]` *optional*, defaults to `{"height... | class_definition | 12,663 | 29,499 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/vitpose/image_processing_vitpose.py | null | 2,927 |
class MistralConverter:
"""
A general tiktoken converter.
"""
def __init__(
self,
vocab=None,
pattern=r"""(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\r\n\p{L}\p{N}]?\p{L}+|\p{N}{1,3}| ?[^\s\p{L}\p{N}]+[\r\n]*|\s*[\r\n]+|\s+(?!\S)|\s+""",
add_prefix_space=False,
additional_sp... | class_definition | 4,435 | 7,162 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pixtral/convert_pixtral_weights_to_hf.py | null | 2,928 |
class PixtralVisionConfig(PretrainedConfig):
r"""
This is the configuration class to store the configuration of a [`PixtralVisionModel`]. It is used to instantiate an
Pixtral vision encoder according to the specified arguments, defining the model architecture. Instantiating a configuration
with the defa... | class_definition | 778 | 4,200 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pixtral/configuration_pixtral.py | null | 2,929 |
class PixtralProcessorKwargs(ProcessingKwargs, total=False):
_defaults = {
"text_kwargs": {
"padding": False,
},
"images_kwargs": {},
"common_kwargs": {
"return_tensors": "pt",
},
} | class_definition | 1,093 | 1,346 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pixtral/processing_pixtral.py | null | 2,930 |
class BatchMixFeature(BatchFeature):
def to(self, *args, **kwargs) -> "BatchMixFeature":
"""
Send all values to device by calling `v.to(*args, **kwargs)` (PyTorch only). This should support casting in
different `dtypes` and sending the `BatchFeature` to a different `device`.
Args:
... | class_definition | 1,756 | 3,937 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pixtral/processing_pixtral.py | null | 2,931 |
class PixtralProcessor(ProcessorMixin):
r"""
Constructs a Pixtral processor which wraps a Pixtral image processor and a Pixtral tokenizer into a single processor.
[`PixtralProcessor`] offers all the functionalities of [`CLIPImageProcessor`] and [`LlamaTokenizerFast`]. See the
[`~PixtralProcessor.__call... | class_definition | 3,940 | 13,948 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pixtral/processing_pixtral.py | null | 2,932 |
class PixtralRotaryEmbedding(nn.Module):
"""
The key with pixtral embedding is just that you have a frequency for each pixel positions.
If you have height x width pixels (or embedding pixels), then the frequency used for ROPE
is given by indexing the pre_computed frequency on the width and height.
... | class_definition | 1,535 | 5,079 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pixtral/modeling_pixtral.py | null | 2,933 |
class PixtralAttention(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... | class_definition | 6,874 | 9,352 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pixtral/modeling_pixtral.py | null | 2,934 |
class PixtralMLP(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 | 9,447 | 10,117 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pixtral/modeling_pixtral.py | null | 2,935 |
class PixtralRMSNorm(nn.Module):
def __init__(self, hidden_size, eps=1e-6):
"""
PixtralRMSNorm 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 | 10,208 | 10,932 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pixtral/modeling_pixtral.py | null | 2,936 |
class PixtralAttentionLayer(nn.Module):
def __init__(self, config):
super().__init__()
self.attention_norm = PixtralRMSNorm(config.hidden_size, eps=1e-5)
self.feed_forward = PixtralMLP(config)
self.attention = PixtralAttention(config)
self.ffn_norm = PixtralRMSNorm(config.hid... | class_definition | 10,935 | 12,829 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pixtral/modeling_pixtral.py | null | 2,937 |
class PixtralTransformer(nn.Module):
def __init__(self, config):
super().__init__()
self.config = config
self.layers = torch.nn.ModuleList()
for _ in range(config.num_hidden_layers):
self.layers.append(PixtralAttentionLayer(config))
self.gradient_checkpointing = F... | class_definition | 12,832 | 16,473 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pixtral/modeling_pixtral.py | null | 2,938 |
class PixtralPreTrainedModel(PreTrainedModel):
config_class = PixtralVisionConfig
base_model_prefix = "model"
supports_gradient_checkpointing = True
_no_split_modules = ["PixtralVisionAttention"]
_skip_keys_device_placement = "past_key_values"
_supports_cache_class = True
def _init_weights(... | class_definition | 17,371 | 18,287 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pixtral/modeling_pixtral.py | null | 2,939 |
class PixtralVisionModel(PixtralPreTrainedModel):
base_model_prefix = "vision_encoder"
def __init__(self, config):
super().__init__(config)
self.config = config
self.patch_conv = nn.Conv2d(
in_channels=config.num_channels,
out_channels=config.hidden_size,
... | class_definition | 19,890 | 22,034 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pixtral/modeling_pixtral.py | null | 2,940 |
class BatchMixFeature(BatchFeature):
def to(self, *args, **kwargs) -> "BatchMixFeature":
"""
Send all values to device by calling `v.to(*args, **kwargs)` (PyTorch only). This should support casting in
different `dtypes` and sending the `BatchFeature` to a different `device`.
Args:
... | class_definition | 1,453 | 3,634 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pixtral/image_processing_pixtral.py | null | 2,941 |
class PixtralImageProcessor(BaseImageProcessor):
r"""
Constructs a Pixtral 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 `pr... | class_definition | 8,721 | 23,867 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pixtral/image_processing_pixtral.py | null | 2,942 |
class PixtralImageProcessorFast(BaseImageProcessorFast):
r"""
Constructs a fast Pixtral image processor that leverages torchvision.
Args:
do_resize (`bool`, *optional*, defaults to `True`):
Whether to resize the image's (height, width) dimensions to the specified `size`. Can be overridd... | class_definition | 1,771 | 17,028 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/pixtral/image_processing_pixtral_fast.py | null | 2,943 |
class GLPNConfig(PretrainedConfig):
r"""
This is the configuration class to store the configuration of a [`GLPNModel`]. It is used to instantiate an GLPN
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
defaults will yield a similar conf... | class_definition | 791 | 5,970 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/glpn/configuration_glpn.py | null | 2,944 |
class GLPNImageProcessor(BaseImageProcessor):
r"""
Constructs a GLPN image processor.
Args:
do_resize (`bool`, *optional*, defaults to `True`):
Whether to resize the image's (height, width) dimensions, rounding them down to the closest multiple of
`size_divisor`. Can be over... | class_definition | 1,443 | 12,655 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/glpn/image_processing_glpn.py | null | 2,945 |
class GLPNDropPath(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 | 2,670 | 3,148 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/glpn/modeling_glpn.py | null | 2,946 |
class GLPNOverlapPatchEmbeddings(nn.Module):
"""Construct the overlapping patch embeddings."""
def __init__(self, patch_size, stride, num_channels, hidden_size):
super().__init__()
self.proj = nn.Conv2d(
num_channels,
hidden_size,
kernel_size=patch_size,
... | class_definition | 3,246 | 4,156 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/glpn/modeling_glpn.py | null | 2,947 |
class GLPNEfficientSelfAttention(nn.Module):
"""SegFormer's efficient self-attention mechanism. Employs the sequence reduction process introduced in the [PvT
paper](https://arxiv.org/abs/2102.12122)."""
def __init__(self, config, hidden_size, num_attention_heads, sequence_reduction_ratio):
super().... | class_definition | 4,254 | 7,898 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/glpn/modeling_glpn.py | null | 2,948 |
class GLPNSelfOutput(nn.Module):
def __init__(self, config, hidden_size):
super().__init__()
self.dense = nn.Linear(hidden_size, hidden_size)
self.dropout = nn.Dropout(config.hidden_dropout_prob)
def forward(self, hidden_states, input_tensor):
hidden_states = self.dense(hidden_s... | class_definition | 7,984 | 8,391 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/glpn/modeling_glpn.py | null | 2,949 |
class GLPNAttention(nn.Module):
def __init__(self, config, hidden_size, num_attention_heads, sequence_reduction_ratio):
super().__init__()
self.self = GLPNEfficientSelfAttention(
config=config,
hidden_size=hidden_size,
num_attention_heads=num_attention_heads,
... | class_definition | 8,497 | 10,192 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/glpn/modeling_glpn.py | null | 2,950 |
class GLPNDWConv(nn.Module):
def __init__(self, dim=768):
super().__init__()
self.dwconv = nn.Conv2d(dim, dim, 3, 1, 1, bias=True, groups=dim)
def forward(self, hidden_states, height, width):
batch_size, seq_len, num_channels = hidden_states.shape
hidden_states = hidden_states.t... | class_definition | 10,274 | 10,800 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/glpn/modeling_glpn.py | null | 2,951 |
class GLPNMixFFN(nn.Module):
def __init__(self, config, in_features, hidden_features=None, out_features=None):
super().__init__()
out_features = out_features or in_features
self.dense1 = nn.Linear(in_features, hidden_features)
self.dwconv = GLPNDWConv(hidden_features)
if isin... | class_definition | 10,903 | 11,934 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/glpn/modeling_glpn.py | null | 2,952 |
class GLPNLayer(nn.Module):
"""This corresponds to the Block class in the original implementation."""
def __init__(self, config, hidden_size, num_attention_heads, drop_path, sequence_reduction_ratio, mlp_ratio):
super().__init__()
self.layer_norm_1 = nn.LayerNorm(hidden_size)
self.atten... | class_definition | 12,036 | 13,819 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/glpn/modeling_glpn.py | null | 2,953 |
class GLPNEncoder(nn.Module):
def __init__(self, config):
super().__init__()
self.config = config
# stochastic depth decay rule
dpr = [x.item() for x in torch.linspace(0, config.drop_path_rate, sum(config.depths))]
# patch embeddings
embeddings = []
for i in... | class_definition | 13,822 | 17,308 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/glpn/modeling_glpn.py | null | 2,954 |
class GLPNPreTrainedModel(PreTrainedModel):
"""
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
models.
"""
config_class = GLPNConfig
base_model_prefix = "glpn"
main_input_name = "pixel_values"
_no_split_modules = []
... | class_definition | 17,311 | 18,555 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/glpn/modeling_glpn.py | null | 2,955 |
class GLPNModel(GLPNPreTrainedModel):
# Copied from transformers.models.segformer.modeling_segformer.SegformerModel.__init__ with Segformer->GLPN
def __init__(self, config):
super().__init__(config)
self.config = config
# hierarchical Transformer encoder
self.encoder = GLPNEncod... | class_definition | 20,207 | 22,548 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/glpn/modeling_glpn.py | null | 2,956 |
class GLPNSelectiveFeatureFusion(nn.Module):
"""
Selective Feature Fusion module, as explained in the [paper](https://arxiv.org/abs/2201.07436) (section 3.4). This
module adaptively selects and integrates local and global features by attaining an attention map for each feature.
"""
def __init__(sel... | class_definition | 22,551 | 24,327 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/glpn/modeling_glpn.py | null | 2,957 |
class GLPNDecoderStage(nn.Module):
def __init__(self, in_channels, out_channels):
super().__init__()
should_skip = in_channels == out_channels
self.convolution = nn.Conv2d(in_channels, out_channels, kernel_size=1) if not should_skip else nn.Identity()
self.fusion = GLPNSelectiveFeatu... | class_definition | 24,330 | 25,125 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/glpn/modeling_glpn.py | null | 2,958 |
class GLPNDecoder(nn.Module):
def __init__(self, config):
super().__init__()
# we use features from end -> start
reserved_hidden_sizes = config.hidden_sizes[::-1]
out_channels = config.decoder_hidden_size
self.stages = nn.ModuleList(
[GLPNDecoderStage(hidden_size... | class_definition | 25,128 | 26,150 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/glpn/modeling_glpn.py | null | 2,959 |
class SiLogLoss(nn.Module):
r"""
Implements the Scale-invariant log scale loss [Eigen et al., 2014](https://arxiv.org/abs/1406.2283).
$$L=\frac{1}{n} \sum_{i} d_{i}^{2}-\frac{1}{2 n^{2}}\left(\sum_{i} d_{i}^{2}\right)$$ where $d_{i}=\log y_{i}-\log
y_{i}^{*}$.
"""
def __init__(self, lambd=0.5... | class_definition | 26,153 | 26,812 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/glpn/modeling_glpn.py | null | 2,960 |
class GLPNDepthEstimationHead(nn.Module):
def __init__(self, config):
super().__init__()
self.config = config
channels = config.decoder_hidden_size
self.head = nn.Sequential(
nn.Conv2d(channels, channels, kernel_size=3, stride=1, padding=1),
nn.ReLU(inplace=... | class_definition | 26,815 | 27,626 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/glpn/modeling_glpn.py | null | 2,961 |
class GLPNForDepthEstimation(GLPNPreTrainedModel):
def __init__(self, config):
super().__init__(config)
self.glpn = GLPNModel(config)
self.decoder = GLPNDecoder(config)
self.head = GLPNDepthEstimationHead(config)
# Initialize weights and apply final processing
self.... | class_definition | 27,785 | 31,401 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/glpn/modeling_glpn.py | null | 2,962 |
class GLPNFeatureExtractor(GLPNImageProcessor):
def __init__(self, *args, **kwargs) -> None:
warnings.warn(
"The class GLPNFeatureExtractor is deprecated and will be removed in version 5 of Transformers. Please"
" use GLPNImageProcessor instead.",
FutureWarning,
)... | class_definition | 809 | 1,171 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/glpn/feature_extraction_glpn.py | null | 2,963 |
class BigBirdPegasusConfig(PretrainedConfig):
r"""
This is the configuration class to store the configuration of a [`BigBirdPegasusModel`]. It is used to instantiate
an BigBirdPegasus model according to the specified arguments, defining the model architecture. Instantiating a
configuration with the defa... | class_definition | 1,090 | 8,820 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bigbird_pegasus/configuration_bigbird_pegasus.py | null | 2,964 |
class BigBirdPegasusOnnxConfig(OnnxSeq2SeqConfigWithPast):
@property
def inputs(self) -> Mapping[str, Mapping[int, str]]:
if self.task in ["default", "seq2seq-lm"]:
common_inputs = OrderedDict(
[
("input_ids", {0: "batch", 1: "encoder_sequence"}),
... | class_definition | 8,896 | 19,214 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bigbird_pegasus/configuration_bigbird_pegasus.py | null | 2,965 |
class BigBirdPegasusLearnedPositionalEmbedding(nn.Embedding):
"""
This module learns positional embeddings up to a fixed maximum size.
"""
def __init__(self, num_embeddings: int, embedding_dim: int):
super().__init__(num_embeddings, embedding_dim)
def forward(self, input_ids_shape: torch.S... | class_definition | 2,408 | 3,075 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bigbird_pegasus/modeling_bigbird_pegasus.py | null | 2,966 |
class BigBirdPegasusScaledWordEmbedding(nn.Embedding):
"""
This module overrides nn.Embeddings' forward by multiplying with embeddings scale.
"""
def __init__(self, num_embeddings: int, embedding_dim: int, padding_idx: int, embed_scale: Optional[float] = 1.0):
super().__init__(num_embeddings, e... | class_definition | 3,181 | 3,676 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bigbird_pegasus/modeling_bigbird_pegasus.py | null | 2,967 |
class BigBirdPegasusSelfAttention(nn.Module):
def __init__(self, config):
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}) is not a multiple of ... | class_definition | 3,790 | 8,877 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bigbird_pegasus/modeling_bigbird_pegasus.py | null | 2,968 |
class BigBirdPegasusBlockSparseAttention(nn.Module):
def __init__(self, config, seed=None):
super().__init__()
self.max_seqlen = config.max_position_embeddings
self.seed = seed
if config.hidden_size % config.num_attention_heads != 0:
raise ValueError(
f"... | class_definition | 8,998 | 52,118 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bigbird_pegasus/modeling_bigbird_pegasus.py | null | 2,969 |
class BigBirdPegasusEncoderAttention(nn.Module):
def __init__(self, config, seed=None):
super().__init__()
self.config = config
self.seed = seed
self.attention_type = config.attention_type
if self.attention_type == "original_full":
self.self = BigBirdPegasusSelf... | class_definition | 52,121 | 54,971 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bigbird_pegasus/modeling_bigbird_pegasus.py | null | 2,970 |
class BigBirdPegasusDecoderAttention(nn.Module):
"""Multi-headed attention from 'Attention Is All You Need' paper"""
def __init__(
self,
embed_dim: int,
num_heads: int,
dropout: float = 0.0,
is_decoder: bool = False,
bias: bool = True,
is_causal: bool = F... | class_definition | 55,108 | 62,525 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bigbird_pegasus/modeling_bigbird_pegasus.py | null | 2,971 |
class BigBirdPegasusEncoderLayer(nn.Module):
def __init__(self, config: BigBirdPegasusConfig, seed=None):
super().__init__()
self.attention_type = config.attention_type
self.embed_dim = config.d_model
self.self_attn = BigBirdPegasusEncoderAttention(config, seed=seed)
self.sel... | class_definition | 62,528 | 66,117 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bigbird_pegasus/modeling_bigbird_pegasus.py | null | 2,972 |
class BigBirdPegasusDecoderLayer(nn.Module):
def __init__(self, config: BigBirdPegasusConfig):
super().__init__()
self.embed_dim = config.d_model
self.self_attn = BigBirdPegasusDecoderAttention(
embed_dim=self.embed_dim,
num_heads=config.decoder_attention_heads,
... | class_definition | 66,120 | 72,040 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bigbird_pegasus/modeling_bigbird_pegasus.py | null | 2,973 |
class BigBirdPegasusClassificationHead(nn.Module):
"""Head for sentence-level classification tasks."""
def __init__(
self,
input_dim: int,
inner_dim: int,
num_classes: int,
pooler_dropout: float,
):
super().__init__()
self.dense = nn.Linear(input_dim,... | class_definition | 72,145 | 72,941 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bigbird_pegasus/modeling_bigbird_pegasus.py | null | 2,974 |
class BigBirdPegasusPreTrainedModel(PreTrainedModel):
config_class = BigBirdPegasusConfig
base_model_prefix = "model"
supports_gradient_checkpointing = True
_no_split_modules = ["BigBirdPegasusEncoderLayer", "BigBirdPegasusDecoderLayer"]
_skip_keys_device_placement = "past_key_values"
_supports_... | class_definition | 72,944 | 74,105 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bigbird_pegasus/modeling_bigbird_pegasus.py | null | 2,975 |
class BigBirdPegasusEncoder(BigBirdPegasusPreTrainedModel):
"""
Transformer encoder consisting of *config.encoder_layers* self attention layers. Each layer is a
[`BigBirdPegasusEncoderLayer`].
Args:
config: BigBirdPegasusConfig
embed_tokens (nn.Embedding): output embedding
"""
... | class_definition | 83,146 | 97,305 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bigbird_pegasus/modeling_bigbird_pegasus.py | null | 2,976 |
class BigBirdPegasusDecoder(BigBirdPegasusPreTrainedModel):
"""
Transformer decoder consisting of *config.decoder_layers* layers. Each layer is a [`BigBirdPegasusDecoderLayer`]
Args:
config: BigBirdPegasusConfig
embed_tokens (nn.Embedding): output embedding
"""
def __init__(self, c... | class_definition | 97,308 | 110,111 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bigbird_pegasus/modeling_bigbird_pegasus.py | null | 2,977 |
class BigBirdPegasusModel(BigBirdPegasusPreTrainedModel):
_tied_weights_keys = ["encoder.embed_tokens.weight", "decoder.embed_tokens.weight"]
def __init__(self, config: BigBirdPegasusConfig):
super().__init__(config)
padding_idx, vocab_size = config.pad_token_id, config.vocab_size
embe... | class_definition | 110,276 | 116,291 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bigbird_pegasus/modeling_bigbird_pegasus.py | null | 2,978 |
class BigBirdPegasusForConditionalGeneration(BigBirdPegasusPreTrainedModel, GenerationMixin):
base_model_prefix = "model"
_tied_weights_keys = ["encoder.embed_tokens.weight", "decoder.embed_tokens.weight", "lm_head.weight"]
_keys_to_ignore_on_load_missing = ["final_logits_bias"]
def __init__(self, conf... | class_definition | 116,581 | 123,024 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bigbird_pegasus/modeling_bigbird_pegasus.py | null | 2,979 |
class BigBirdPegasusForSequenceClassification(BigBirdPegasusPreTrainedModel):
_tied_weights_keys = ["encoder.embed_tokens.weight", "decoder.embed_tokens.weight"]
def __init__(self, config: BigBirdPegasusConfig, **kwargs):
super().__init__(config, **kwargs)
self.model = BigBirdPegasusModel(confi... | class_definition | 123,244 | 128,876 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bigbird_pegasus/modeling_bigbird_pegasus.py | null | 2,980 |
class BigBirdPegasusForQuestionAnswering(BigBirdPegasusPreTrainedModel):
_tied_weights_keys = ["encoder.embed_tokens.weight", "decoder.embed_tokens.weight"]
def __init__(self, config):
super().__init__(config)
config.num_labels = 2
self.num_labels = config.num_labels
self.mode... | class_definition | 129,183 | 134,650 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bigbird_pegasus/modeling_bigbird_pegasus.py | null | 2,981 |
class BigBirdPegasusDecoderWrapper(BigBirdPegasusPreTrainedModel):
"""
This wrapper class is a helper class to correctly load pretrained checkpoints when the causal language model is
used in combination with the [`EncoderDecoderModel`] framework.
"""
def __init__(self, config):
super().__in... | class_definition | 134,763 | 135,234 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bigbird_pegasus/modeling_bigbird_pegasus.py | null | 2,982 |
class BigBirdPegasusForCausalLM(BigBirdPegasusPreTrainedModel, GenerationMixin):
_tied_weights_keys = ["lm_head.weight"]
def __init__(self, config):
config = copy.deepcopy(config)
config.is_decoder = True
config.is_encoder_decoder = False
super().__init__(config)
self.mo... | class_definition | 135,237 | 144,489 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/bigbird_pegasus/modeling_bigbird_pegasus.py | null | 2,983 |
class BioGptTokenizer(PreTrainedTokenizer):
"""
Construct an FAIRSEQ Transformer tokenizer. Moses tokenization followed by Byte-Pair Encoding.
This tokenizer inherits from [`PreTrainedTokenizer`] which contains most of the main methods. Users should refer to
this superclass for more information regardi... | class_definition | 1,286 | 13,256 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/biogpt/tokenization_biogpt.py | null | 2,984 |
class BioGptLearnedPositionalEmbedding(nn.Embedding):
"""
This module learns positional embeddings up to a fixed maximum size.
"""
def __init__(self, num_embeddings: int, embedding_dim: int):
# BioGpt is set up so that if padding_idx is specified then offset the embedding ids by 2
# and... | class_definition | 1,741 | 2,771 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/biogpt/modeling_biogpt.py | null | 2,985 |
class BioGptScaledWordEmbedding(nn.Embedding):
"""
This module overrides nn.Embeddings' forward by multiplying with embeddings scale.
"""
def __init__(self, num_embeddings: int, embedding_dim: int, padding_idx: int, embed_scale: Optional[float] = 1.0):
super().__init__(num_embeddings, embedding... | class_definition | 2,869 | 3,356 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/biogpt/modeling_biogpt.py | null | 2,986 |
class BioGptAttention(nn.Module):
"""Multi-headed attention from 'Attention Is All You Need' paper"""
def __init__(
self,
embed_dim: int,
num_heads: int,
dropout: float = 0.0,
is_decoder: bool = False,
bias: bool = True,
is_causal: bool = False,
c... | class_definition | 3,444 | 10,838 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/biogpt/modeling_biogpt.py | null | 2,987 |
class BioGptSdpaAttention(BioGptAttention):
def forward(
self,
hidden_states: torch.Tensor,
key_value_states: Optional[torch.Tensor] = None,
past_key_value: Optional[Tuple[torch.Tensor]] = None,
attention_mask: Optional[torch.Tensor] = None,
layer_head_mask: Optional[... | class_definition | 10,930 | 16,715 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/biogpt/modeling_biogpt.py | null | 2,988 |
class BioGptDecoderLayer(nn.Module):
def __init__(self, config: BioGptConfig):
super().__init__()
self.embed_dim = config.hidden_size
self.self_attn = BIOGPT_ATTENTION_CLASSES[config._attn_implementation](
embed_dim=self.embed_dim,
num_heads=config.num_attention_head... | class_definition | 16,814 | 20,721 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/biogpt/modeling_biogpt.py | null | 2,989 |
class BioGptPreTrainedModel(PreTrainedModel):
"""
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
models.
"""
config_class = BioGptConfig
base_model_prefix = "biogpt"
supports_gradient_checkpointing = True
_supports_sdpa =... | class_definition | 20,724 | 21,860 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/biogpt/modeling_biogpt.py | null | 2,990 |
class BioGptModel(BioGptPreTrainedModel):
def __init__(self, config: BioGptConfig):
super().__init__(config)
self.config = config
self.layerdrop = config.layerdrop
self.dropout = config.hidden_dropout_prob
self.embed_dim = config.hidden_size
self.padding_idx = config.... | class_definition | 26,191 | 33,799 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/biogpt/modeling_biogpt.py | null | 2,991 |
class BioGptForCausalLM(BioGptPreTrainedModel, GenerationMixin):
_tied_weights_keys = ["output_projection.weight"]
def __init__(self, config):
super().__init__(config)
self.biogpt = BioGptModel(config)
self.output_projection = nn.Linear(config.hidden_size, config.vocab_size, bias=False... | class_definition | 33,934 | 37,718 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/biogpt/modeling_biogpt.py | null | 2,992 |
class BioGptForTokenClassification(BioGptPreTrainedModel):
def __init__(self, config):
super().__init__(config)
self.num_labels = config.num_labels
self.biogpt = BioGptModel(config)
if hasattr(config, "classifier_dropout") and config.classifier_dropout is not None:
class... | class_definition | 37,951 | 41,521 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/biogpt/modeling_biogpt.py | null | 2,993 |
class BioGptForSequenceClassification(BioGptPreTrainedModel):
def __init__(self, config: BioGptConfig):
super().__init__(config)
self.num_labels = config.num_labels
self.biogpt = BioGptModel(config)
self.score = nn.Linear(config.hidden_size, self.num_labels, bias=False)
# In... | class_definition | 42,320 | 47,209 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/biogpt/modeling_biogpt.py | null | 2,994 |
class BioGptConfig(PretrainedConfig):
r"""
This is the configuration class to store the configuration of a [`BioGptModel`]. It is used to instantiate an
BioGPT model according to the specified arguments, defining the model architecture. Instantiating a configuration
with the defaults will yield a simila... | class_definition | 811 | 6,177 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/biogpt/configuration_biogpt.py | null | 2,995 |
class Dictionary:
"""A mapping from symbols to consecutive integers"""
def __init__(
self,
*, # begin keyword-only arguments
bos="<s>",
pad="<pad>",
eos="</s>",
unk="<unk>",
extra_special_symbols=None,
):
self.bos_word, self.unk_word, self.pa... | class_definition | 1,132 | 4,808 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/biogpt/convert_biogpt_original_pytorch_checkpoint_to_pytorch.py | null | 2,996 |
class VisualBertConfig(PretrainedConfig):
r"""
This is the configuration class to store the configuration of a [`VisualBertModel`]. It is used to instantiate an
VisualBERT model according to the specified arguments, defining the model architecture. Instantiating a
configuration with the defaults will yi... | class_definition | 787 | 6,733 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/visual_bert/configuration_visual_bert.py | null | 2,997 |
class VisualBertEmbeddings(nn.Module):
"""Construct the embeddings from word, position and token_type embeddings and visual embeddings."""
def __init__(self, config):
super().__init__()
self.word_embeddings = nn.Embedding(config.vocab_size, config.hidden_size, padding_idx=config.pad_token_id)
... | class_definition | 1,585 | 7,965 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/visual_bert/modeling_visual_bert.py | null | 2,998 |
class VisualBertSelfAttention(nn.Module):
def __init__(self, config):
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}) is not a multiple of the ... | class_definition | 7,968 | 10,886 | 0 | /Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/models/visual_bert/modeling_visual_bert.py | null | 2,999 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.