code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def image_guided_detection(
self,
pixel_values: torch.FloatTensor,
query_pixel_values: Optional[torch.FloatTensor] = None,
output_attentions: Optional[bool] = None,
output_hidden_states: Optional[bool] = None,
interpolate_pos_encoding: bool = False,
return_dict: O... |
query_pixel_values (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)`):
Pixel values of query image(s) to be detected. Pass in one query image per target image.
Examples:
```python
>>> import requests
>>> from PIL import Image
>>> impo... | image_guided_detection | python | huggingface/transformers | src/transformers/models/owlvit/modeling_owlvit.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/owlvit/modeling_owlvit.py | Apache-2.0 |
def forward(
self,
input_ids: torch.Tensor,
pixel_values: torch.FloatTensor,
attention_mask: Optional[torch.Tensor] = None,
output_attentions: Optional[bool] = None,
output_hidden_states: Optional[bool] = None,
interpolate_pos_encoding: bool = False,
retur... |
input_ids (`torch.LongTensor` of shape `(batch_size * num_max_text_queries, sequence_length)`, *optional*):
Indices of input sequence tokens in the vocabulary. Indices can be obtained using [`AutoTokenizer`]. See
[`PreTrainedTokenizer.encode`] and [`PreTrainedTokenizer.__call__`] for de... | forward | python | huggingface/transformers | src/transformers/models/owlvit/modeling_owlvit.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/owlvit/modeling_owlvit.py | Apache-2.0 |
def post_process_object_detection(self, *args, **kwargs):
"""
This method forwards all its arguments to [`OwlViTImageProcessor.post_process_object_detection`]. Please refer
to the docstring of this method for more information.
"""
warnings.warn(
"`post_process_object_... |
This method forwards all its arguments to [`OwlViTImageProcessor.post_process_object_detection`]. Please refer
to the docstring of this method for more information.
| post_process_object_detection | python | huggingface/transformers | src/transformers/models/owlvit/processing_owlvit.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/owlvit/processing_owlvit.py | Apache-2.0 |
def post_process_grounded_object_detection(
self,
outputs: "OwlViTObjectDetectionOutput",
threshold: float = 0.1,
target_sizes: Optional[Union[TensorType, List[Tuple]]] = None,
text_labels: Optional[List[List[str]]] = None,
):
"""
Converts the raw output of [`... |
Converts the raw output of [`OwlViTForObjectDetection`] into final bounding boxes in (top_left_x, top_left_y,
bottom_right_x, bottom_right_y) format.
Args:
outputs ([`OwlViTObjectDetectionOutput`]):
Raw outputs of the model.
threshold (`float`, *optional... | post_process_grounded_object_detection | python | huggingface/transformers | src/transformers/models/owlvit/processing_owlvit.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/owlvit/processing_owlvit.py | Apache-2.0 |
def post_process_image_guided_detection(
self,
outputs: "OwlViTImageGuidedObjectDetectionOutput",
threshold: float = 0.0,
nms_threshold: float = 0.3,
target_sizes: Optional[Union[TensorType, List[Tuple]]] = None,
):
"""
Converts the output of [`OwlViTForObject... |
Converts the output of [`OwlViTForObjectDetection.image_guided_detection`] into the format expected by the COCO
api.
Args:
outputs ([`OwlViTImageGuidedObjectDetectionOutput`]):
Raw outputs of the model.
threshold (`float`, *optional*, defaults to 0.0):
... | post_process_image_guided_detection | python | huggingface/transformers | src/transformers/models/owlvit/processing_owlvit.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/owlvit/processing_owlvit.py | Apache-2.0 |
def convert_paligemma2_checkpoint(
checkpoint_path,
pytorch_dump_folder_path,
variant: str,
precision: str,
do_convert_weights=False,
):
"""
Read checkpoints from flax npz files, rename/reshape, send result to state dict and verify logits if needed.
"""
config = get_paligemma2_config... |
Read checkpoints from flax npz files, rename/reshape, send result to state dict and verify logits if needed.
| convert_paligemma2_checkpoint | python | huggingface/transformers | src/transformers/models/paligemma/convert_paligemma2_weights_to_hf.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/paligemma/convert_paligemma2_weights_to_hf.py | Apache-2.0 |
def forward(
self,
input_ids: torch.LongTensor = None,
pixel_values: torch.FloatTensor = None,
attention_mask: Optional[torch.Tensor] = None,
position_ids: Optional[torch.LongTensor] = None,
past_key_values: Optional[Union[List[torch.FloatTensor], Cache]] = None,
... |
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
config.text_config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are igno... | forward | python | huggingface/transformers | src/transformers/models/paligemma/modeling_paligemma.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/paligemma/modeling_paligemma.py | Apache-2.0 |
def __call__(
self,
images: ImageInput = None,
text: Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None,
audio=None,
videos=None,
**kwargs: Unpack[PaliGemmaProcessorKwargs],
) -> BatchFeature:
"""
Main method to prepar... |
Main method to prepare for the model one or several sequences(s) and image(s). This method forwards the `text`
and `kwargs` arguments to GemmaTokenizerFast's [`~GemmaTokenizerFast.__call__`] if `text` is not `None` to encode
the text. To prepare the image(s), this method forwards the `images` a... | __call__ | python | huggingface/transformers | src/transformers/models/paligemma/processing_paligemma.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/paligemma/processing_paligemma.py | Apache-2.0 |
def forward(self, inputs: torch.Tensor):
"""
Parameters:
inputs (`torch.Tensor` of shape `(batch_size, sequence_length, d_model)`):
input for Batch norm calculation
Returns:
`torch.Tensor` of shape `(batch_size, sequence_length, d_model)`
"""
... |
Parameters:
inputs (`torch.Tensor` of shape `(batch_size, sequence_length, d_model)`):
input for Batch norm calculation
Returns:
`torch.Tensor` of shape `(batch_size, sequence_length, d_model)`
| forward | python | huggingface/transformers | src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | Apache-2.0 |
def forward(self, inputs: torch.Tensor):
"""
Args:
inputs (`torch.Tensor` of shape `((batch_size, num_channels, num_patches, d_model))`):
Input to the normalization layer.
Returns:
`torch.Tensor` of shape `((batch_size, num_channels, num_patches, d_model))... |
Args:
inputs (`torch.Tensor` of shape `((batch_size, num_channels, num_patches, d_model))`):
Input to the normalization layer.
Returns:
`torch.Tensor` of shape `((batch_size, num_channels, num_patches, d_model))`
| forward | python | huggingface/transformers | src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | Apache-2.0 |
def forward(self, inputs: torch.Tensor):
"""
Args:
inputs (`torch.Tensor` of shape `((batch_size, num_channels, num_patches, d_model))`):
Input to the MLP layer.
Returns:
`torch.Tensor` of the same shape as `inputs`
"""
inputs = self.dropou... |
Args:
inputs (`torch.Tensor` of shape `((batch_size, num_channels, num_patches, d_model))`):
Input to the MLP layer.
Returns:
`torch.Tensor` of the same shape as `inputs`
| forward | python | huggingface/transformers | src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | Apache-2.0 |
def forward(self, inputs: torch.Tensor):
"""
Args:
inputs (`torch.Tensor` of shape `((batch_size, num_channels, num_patches, d_model))`):
input to the MLP layer
Returns:
`torch.Tensor` of the same shape as `inputs`
"""
residual = inputs
... |
Args:
inputs (`torch.Tensor` of shape `((batch_size, num_channels, num_patches, d_model))`):
input to the MLP layer
Returns:
`torch.Tensor` of the same shape as `inputs`
| forward | python | huggingface/transformers | src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | Apache-2.0 |
def forward(self, hidden_state):
"""
Args:
hidden_state (`torch.Tensor`): Input tensor.
Returns:
`torch.Tensor`: Transformed tensor.
"""
residual = hidden_state
hidden_state = self.norm(hidden_state)
if self.self_attn:
batch_... |
Args:
hidden_state (`torch.Tensor`): Input tensor.
Returns:
`torch.Tensor`: Transformed tensor.
| forward | python | huggingface/transformers | src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | Apache-2.0 |
def forward(self, hidden: torch.Tensor):
"""
Args:
hidden (`torch.Tensor` of shape `(batch_size, num_patches, d_model)`):
Input tensor to the layer.
Returns:
`torch.Tensor`: Transformed tensor.
"""
residual = hidden
hidden = self.n... |
Args:
hidden (`torch.Tensor` of shape `(batch_size, num_patches, d_model)`):
Input tensor to the layer.
Returns:
`torch.Tensor`: Transformed tensor.
| forward | python | huggingface/transformers | src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | Apache-2.0 |
def forward(self, hidden_state, output_hidden_states: bool = False):
"""
Args:
hidden_state (`torch.Tensor`): The input tensor.
output_hidden_states (`bool`, *optional*, defaults to False.):
Whether to output the hidden states as well.
Returns:
... |
Args:
hidden_state (`torch.Tensor`): The input tensor.
output_hidden_states (`bool`, *optional*, defaults to False.):
Whether to output the hidden states as well.
Returns:
`torch.Tensor`: The embedding. `list`: List of all hidden states if `output_hi... | forward | python | huggingface/transformers | src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | Apache-2.0 |
def forward(self, hidden_features):
"""
Args:
hidden_features (`torch.Tensor` of shape `(batch_size, num_patch, d_model)` in `flatten` mode
or `(batch_size, n_vars, num_patch, d_model)` in `common_channel`/`mix_channel` mode.): Input hidden
features.
... |
Args:
hidden_features (`torch.Tensor` of shape `(batch_size, num_patch, d_model)` in `flatten` mode
or `(batch_size, n_vars, num_patch, d_model)` in `common_channel`/`mix_channel` mode.): Input hidden
features.
Returns:
`torch.Tensor` of shape `... | forward | python | huggingface/transformers | src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | Apache-2.0 |
def forward(self, hidden_features):
"""
Args:
hidden_features (`torch.Tensor` of shape `(batch_size x num_patch x d_model)` in `flatten` mode
or `(batch_size x n_vars x num_patch x d_model)` in `common_channel`/`mix_channel` mode.): Input hidden
features.
... |
Args:
hidden_features (`torch.Tensor` of shape `(batch_size x num_patch x d_model)` in `flatten` mode
or `(batch_size x n_vars x num_patch x d_model)` in `common_channel`/`mix_channel` mode.): Input hidden
features.
Returns:
`torch.Tensor` of sha... | forward | python | huggingface/transformers | src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | Apache-2.0 |
def forward(self, hidden_features):
"""
Args:
hidden_features (`torch.Tensor` of shape `(batch_size x num_patch x d_model)` in `flatten` mode
or `(batch_size x n_vars x num_patch x d_model)` in `common_channel`/`mix_channel` mode.): Input hidden
features.
... |
Args:
hidden_features (`torch.Tensor` of shape `(batch_size x num_patch x d_model)` in `flatten` mode
or `(batch_size x n_vars x num_patch x d_model)` in `common_channel`/`mix_channel` mode.): Input hidden
features.
Returns:
`torch.Tensor` of sha... | forward | python | huggingface/transformers | src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | Apache-2.0 |
def random_masking(
inputs: torch.Tensor,
mask_ratio: float,
unmasked_channel_indices: Optional[list] = None,
channel_consistent_masking: bool = False,
mask_value: int = 0,
):
"""random_masking: Mask the input considering the control variables.
Args:
inputs (`torch.Tensor` of shape ... | random_masking: Mask the input considering the control variables.
Args:
inputs (`torch.Tensor` of shape `(batch_size, num_channels, sequence_length, num_features)`):
The input tensor to mask.
mask_ratio (`float`):
Masking ratio applied to mask the input data during random pr... | random_masking | python | huggingface/transformers | src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | Apache-2.0 |
def forecast_masking(
inputs: torch.Tensor,
num_forecast_mask_patches: Union[list, int],
unmasked_channel_indices: Optional[list] = None,
mask_value: int = 0,
):
"""Forecast masking that masks the last K patches where K is from the num_forecast_mask_patches.
If num_forecast_mask_patches is a lis... | Forecast masking that masks the last K patches where K is from the num_forecast_mask_patches.
If num_forecast_mask_patches is a list, samples in the batch will be randomly masked by numbers defined in the list.
Parameters:
inputs (`torch.Tensor`):
Input of shape `(bs, num_channels, num_patc... | forecast_masking | python | huggingface/transformers | src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | Apache-2.0 |
def forward(self, past_values: torch.Tensor):
"""
Parameters:
past_values (`torch.Tensor` of shape `(batch_size, sequence_length, num_channels)`, *required*):
Input for patchification
Returns:
`torch.Tensor` of shape `(batch_size, num_channels, num_patche... |
Parameters:
past_values (`torch.Tensor` of shape `(batch_size, sequence_length, num_channels)`, *required*):
Input for patchification
Returns:
`torch.Tensor` of shape `(batch_size, num_channels, num_patches, patch_length)`
| forward | python | huggingface/transformers | src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | Apache-2.0 |
def forward(self, patch_input: torch.Tensor):
"""
Parameters:
patch_input (`torch.Tensor` of shape `(batch_size, num_channels, num_patches, patch_length)`, *required*):
Patch input
Return:
masked_input (`torch.Tensor` of shape `(batch_size, num_channels, ... |
Parameters:
patch_input (`torch.Tensor` of shape `(batch_size, num_channels, num_patches, patch_length)`, *required*):
Patch input
Return:
masked_input (`torch.Tensor` of shape `(batch_size, num_channels, num_patches, patch_length)`)
Masked patch... | forward | python | huggingface/transformers | src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | Apache-2.0 |
def forward(
self,
past_values: torch.Tensor,
output_hidden_states: Optional[bool] = False,
return_dict: Optional[bool] = None,
) -> Union[Tuple, PatchTSMixerEncoderOutput]:
r"""
past_values (`torch.FloatTensor` of shape `(batch_size, seq_length, num_input_channels)`)... |
past_values (`torch.FloatTensor` of shape `(batch_size, seq_length, num_input_channels)`):
Context values of the time series. For a pretraining task, this denotes the input time series to
predict the masked portion. For a forecasting task, this denotes the history/past time series value... | forward | python | huggingface/transformers | src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | Apache-2.0 |
def __init__(self, config: PatchTSMixerConfig, mask_input: bool = False):
r"""
mask_input (bool, *optional*, defaults to `False`):
Whether to mask the input using the [`PatchTSMixerMasking`] module.
"""
super().__init__(config)
self.use_return_dict = config.use_retur... |
mask_input (bool, *optional*, defaults to `False`):
Whether to mask the input using the [`PatchTSMixerMasking`] module.
| __init__ | python | huggingface/transformers | src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | Apache-2.0 |
def forward(
self,
past_values: torch.Tensor,
observed_mask: Optional[torch.Tensor] = None,
output_hidden_states: Optional[bool] = False,
return_dict: Optional[bool] = None,
) -> PatchTSMixerModelOutput:
r"""
past_values (`torch.FloatTensor` of shape `(batch_s... |
past_values (`torch.FloatTensor` of shape `(batch_size, seq_length, num_input_channels)`):
Context values of the time series. For a pretraining task, this denotes the input time series to predict
the masked portion. For a forecasting task, this denotes the history/past time series value... | forward | python | huggingface/transformers | src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | Apache-2.0 |
def forward(
self,
past_values: torch.Tensor,
observed_mask: Optional[torch.Tensor] = None,
output_hidden_states: Optional[bool] = False,
return_loss: bool = True,
return_dict: Optional[bool] = None,
) -> PatchTSMixerForPreTrainingOutput:
r"""
past_val... |
past_values (`torch.FloatTensor` of shape `(batch_size, seq_length, num_input_channels)`):
Context values of the time series. For a pretraining task, this denotes the input time series to predict
the masked portion. For a forecasting task, this denotes the history/past time series value... | forward | python | huggingface/transformers | src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | Apache-2.0 |
def forward(
self,
past_values: torch.Tensor,
observed_mask: Optional[torch.Tensor] = None,
future_values: Optional[torch.Tensor] = None,
output_hidden_states: Optional[bool] = False,
return_loss: bool = True,
return_dict: Optional[bool] = None,
) -> PatchTSMi... |
past_values (`torch.FloatTensor` of shape `(batch_size, seq_length, num_input_channels)`):
Context values of the time series. For a pretraining task, this denotes the input time series to predict
the masked portion. For a forecasting task, this denotes the history/past time series value... | forward | python | huggingface/transformers | src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | Apache-2.0 |
def generate(
self,
past_values: torch.Tensor,
observed_mask: Optional[torch.Tensor] = None,
) -> SamplePatchTSMixerPredictionOutput:
"""
Generate sequences of sample predictions from a model with a probability distribution head.
Args:
past_values (`torch... |
Generate sequences of sample predictions from a model with a probability distribution head.
Args:
past_values (`torch.FloatTensor` of shape `(batch_size, sequence_length, num_input_channels)`):
Past values of the time series that serves as context in order to predict the fu... | generate | python | huggingface/transformers | src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | Apache-2.0 |
def forward(
self,
past_values: torch.Tensor,
target_values: Optional[torch.Tensor] = None,
output_hidden_states: Optional[bool] = False,
return_loss: bool = True,
return_dict: Optional[bool] = None,
) -> PatchTSMixerForTimeSeriesClassificationOutput:
r"""
... |
past_values (`torch.FloatTensor` of shape `(batch_size, seq_length, num_input_channels)`):
Context values of the time series. For a pretraining task, this denotes the input time series to predict
the masked portion. For a forecasting task, this denotes the history/past time series value... | forward | python | huggingface/transformers | src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | Apache-2.0 |
def forward(self, inputs: torch.Tensor, loc: torch.Tensor, scale: torch.Tensor):
"""
Args:
inputs (`torch.Tensor` of shape `(batch_size, num_input_channels, num_patch, d_model)`)
loc (`torch.Tensor` of shape `(batch_size, 1, num_input_channels)`)
scale (`torch.Tensor`... |
Args:
inputs (`torch.Tensor` of shape `(batch_size, num_input_channels, num_patch, d_model)`)
loc (`torch.Tensor` of shape `(batch_size, 1, num_input_channels)`)
scale (`torch.Tensor` of shape `(batch_size, 1, num_input_channels)`)
Returns:
`torch.Tensor`... | forward | python | huggingface/transformers | src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | Apache-2.0 |
def forward(
self,
past_values: torch.Tensor,
target_values: Optional[torch.Tensor] = None,
output_hidden_states: Optional[bool] = False,
return_loss: bool = True,
return_dict: Optional[bool] = None,
) -> PatchTSMixerForRegressionOutput:
r"""
past_valu... |
past_values (`torch.FloatTensor` of shape `(batch_size, seq_length, num_input_channels)`):
Context values of the time series. For a pretraining task, this denotes the input time series to predict
the masked portion. For a forecasting task, this denotes the history/past time series value... | forward | python | huggingface/transformers | src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | Apache-2.0 |
def generate(
self,
past_values: torch.Tensor,
) -> SamplePatchTSMixerRegressionOutput:
"""
Generate sequences of sample predictions from a model with a probability distribution head.
Args:
past_values (`torch.FloatTensor` of shape `(batch_size, sequence_length, ... |
Generate sequences of sample predictions from a model with a probability distribution head.
Args:
past_values (`torch.FloatTensor` of shape `(batch_size, sequence_length, num_input_channels)`):
Past values of the time series that serves as context in order to predict the ta... | generate | python | huggingface/transformers | src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtsmixer/modeling_patchtsmixer.py | Apache-2.0 |
def forward(self, hidden_state: torch.Tensor, output_attentions: Optional[bool] = None):
"""
Parameters:
hidden_state (`torch.Tensor` of shape `(batch_size, num_channels, sequence_length, d_model)`, *required*):
Past values of the time series
output_attentions (`b... |
Parameters:
hidden_state (`torch.Tensor` of shape `(batch_size, num_channels, sequence_length, d_model)`, *required*):
Past values of the time series
output_attentions (`bool`, *optional*):
Whether or not to return the output attention of all layers
... | forward | python | huggingface/transformers | src/transformers/models/patchtst/modeling_patchtst.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtst/modeling_patchtst.py | Apache-2.0 |
def forward(self, patch_input: torch.Tensor):
"""
Parameters:
patch_input (`torch.Tensor` of shape `(batch_size, num_channels, num_patches, patch_length)`, *required*):
Patch input for embedding
return:
`torch.Tensor` of shape `(batch_size, num_channels, n... |
Parameters:
patch_input (`torch.Tensor` of shape `(batch_size, num_channels, num_patches, patch_length)`, *required*):
Patch input for embedding
return:
`torch.Tensor` of shape `(batch_size, num_channels, num_patches, d_model)`
| forward | python | huggingface/transformers | src/transformers/models/patchtst/modeling_patchtst.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtst/modeling_patchtst.py | Apache-2.0 |
def forward(
self,
patch_input: torch.Tensor,
output_hidden_states: Optional[bool] = None,
output_attentions: Optional[bool] = None,
) -> BaseModelOutput:
"""
Parameters:
patch_input (`torch.Tensor` of shape `(batch_size, num_channels, num_patches, patch_l... |
Parameters:
patch_input (`torch.Tensor` of shape `(batch_size, num_channels, num_patches, patch_length)`, *required*):
Past values of the time series
output_hidden_states (bool, optional): Indicates if hidden states should be outputted.
output_attentions (boo... | forward | python | huggingface/transformers | src/transformers/models/patchtst/modeling_patchtst.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtst/modeling_patchtst.py | Apache-2.0 |
def forward(
self, data: torch.Tensor, observed_indicator: torch.Tensor
) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
"""
Parameters:
data (`torch.Tensor` of shape `(batch_size, sequence_length, num_input_channels)`):
Input for scaler calculation
... |
Parameters:
data (`torch.Tensor` of shape `(batch_size, sequence_length, num_input_channels)`):
Input for scaler calculation
observed_indicator (`torch.BoolTensor` of shape `(batch_size, sequence_length, num_input_channels)`):
Calculating the scale on the... | forward | python | huggingface/transformers | src/transformers/models/patchtst/modeling_patchtst.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtst/modeling_patchtst.py | Apache-2.0 |
def forward(
self,
past_values: torch.Tensor,
past_observed_mask: Optional[torch.Tensor] = None,
future_values: Optional[torch.Tensor] = None,
output_hidden_states: Optional[bool] = None,
output_attentions: Optional[bool] = None,
return_dict: Optional[bool] = None... |
Parameters:
past_values (`torch.Tensor` of shape `(bs, sequence_length, num_input_channels)`, *required*):
Input sequence to the model
past_observed_mask (`torch.BoolTensor` of shape `(batch_size, sequence_length, num_input_channels)`, *optional*):
Boolea... | forward | python | huggingface/transformers | src/transformers/models/patchtst/modeling_patchtst.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtst/modeling_patchtst.py | Apache-2.0 |
def forward(self, embedding: torch.Tensor) -> torch.Tensor:
"""
Parameters:
embedding (`torch.Tensor` of shape `(bs, num_channels, num_patches, d_model)` or
`(bs, num_channels, num_patches+1, d_model)` if `cls_token` is set to True, *required*):
Embedding ... |
Parameters:
embedding (`torch.Tensor` of shape `(bs, num_channels, num_patches, d_model)` or
`(bs, num_channels, num_patches+1, d_model)` if `cls_token` is set to True, *required*):
Embedding from the model
Returns:
`torch.Tensor` of shape `(b... | forward | python | huggingface/transformers | src/transformers/models/patchtst/modeling_patchtst.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtst/modeling_patchtst.py | Apache-2.0 |
def forward(
self,
past_values: torch.Tensor,
past_observed_mask: Optional[torch.Tensor] = None,
output_hidden_states: Optional[bool] = None,
output_attentions: Optional[bool] = None,
return_dict: Optional[bool] = None,
) -> Union[Tuple, PatchTSTForPretrainingOutput]:... |
Parameters:
past_values (`torch.Tensor` of shape `(bs, sequence_length, num_input_channels)`, *required*):
Input sequence to the model
past_observed_mask (`torch.BoolTensor` of shape `(batch_size, sequence_length, num_input_channels)`, *optional*):
Boolea... | forward | python | huggingface/transformers | src/transformers/models/patchtst/modeling_patchtst.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtst/modeling_patchtst.py | Apache-2.0 |
def forward(self, embedding: torch.Tensor):
"""
Parameters:
embedding (`torch.Tensor` of shape `(bs, num_channels, num_patches, d_model)` or
`(bs, num_channels, num_patches+1, d_model)` if `cls_token` is set to True, *required*):
Embedding from the model
... |
Parameters:
embedding (`torch.Tensor` of shape `(bs, num_channels, num_patches, d_model)` or
`(bs, num_channels, num_patches+1, d_model)` if `cls_token` is set to True, *required*):
Embedding from the model
Returns:
`torch.Tensor` of shape `(... | forward | python | huggingface/transformers | src/transformers/models/patchtst/modeling_patchtst.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtst/modeling_patchtst.py | Apache-2.0 |
def forward(
self,
past_values: torch.Tensor,
target_values: Optional[torch.Tensor] = None,
past_observed_mask: Optional[bool] = None,
output_hidden_states: Optional[bool] = None,
output_attentions: Optional[bool] = None,
return_dict: Optional[bool] = None,
) ... |
past_values (`torch.Tensor` of shape `(bs, sequence_length, num_input_channels)`, *required*):
Input sequence to the model
target_values (`torch.Tensor`, *optional*):
Labels associates with the `past_values`
past_observed_mask (`torch.BoolTensor` of shape `(batch_size, s... | forward | python | huggingface/transformers | src/transformers/models/patchtst/modeling_patchtst.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtst/modeling_patchtst.py | Apache-2.0 |
def __init__(self, config: PatchTSTConfig, num_patches: int, distribution_output=None):
r"""
num_patches (`int`):
The number of patches in the input sequence.
distribution_output (`DistributionOutput`, *optional*):
The distribution output layer for probabilistic forecasti... |
num_patches (`int`):
The number of patches in the input sequence.
distribution_output (`DistributionOutput`, *optional*):
The distribution output layer for probabilistic forecasting. If None, a linear output layer is used.
| __init__ | python | huggingface/transformers | src/transformers/models/patchtst/modeling_patchtst.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtst/modeling_patchtst.py | Apache-2.0 |
def forward(self, embedding: torch.Tensor):
"""
Parameters:
embedding (`torch.Tensor` of shape `(bs, num_channels, num_patches, d_model)` or
`(bs, num_channels, num_patches+1, d_model)` if `cls_token` is set to True, *required*):
Embedding from the model
... |
Parameters:
embedding (`torch.Tensor` of shape `(bs, num_channels, num_patches, d_model)` or
`(bs, num_channels, num_patches+1, d_model)` if `cls_token` is set to True, *required*):
Embedding from the model
Returns:
`torch.Tensor` of shape `(... | forward | python | huggingface/transformers | src/transformers/models/patchtst/modeling_patchtst.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtst/modeling_patchtst.py | Apache-2.0 |
def forward(
self,
past_values: torch.Tensor,
past_observed_mask: Optional[torch.Tensor] = None,
future_values: Optional[torch.Tensor] = None,
output_hidden_states: Optional[bool] = None,
output_attentions: Optional[bool] = None,
return_dict: Optional[bool] = None... |
Parameters:
past_values (`torch.Tensor` of shape `(bs, sequence_length, num_input_channels)`, *required*):
Input sequence to the model
past_observed_mask (`torch.BoolTensor` of shape `(batch_size, sequence_length, num_input_channels)`, *optional*):
Boolea... | forward | python | huggingface/transformers | src/transformers/models/patchtst/modeling_patchtst.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtst/modeling_patchtst.py | Apache-2.0 |
def generate(
self,
past_values: torch.Tensor,
past_observed_mask: Optional[torch.Tensor] = None,
) -> SamplePatchTSTOutput:
"""
Generate sequences of sample predictions from a model with a probability distribution head.
Parameters:
past_values (`torch.Fl... |
Generate sequences of sample predictions from a model with a probability distribution head.
Parameters:
past_values (`torch.FloatTensor` of shape `(batch_size, sequence_length, num_input_channels)`):
Past values of the time series that serves as context in order to predict ... | generate | python | huggingface/transformers | src/transformers/models/patchtst/modeling_patchtst.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtst/modeling_patchtst.py | Apache-2.0 |
def forward(self, embedding: torch.Tensor):
"""
Parameters:
embedding (`torch.Tensor` of shape `(bs, num_channels, num_patches, d_model)` or
`(bs, num_channels, num_patches+1, d_model)` if `cls_token` is set to True, *required*):
Embedding from the model
... |
Parameters:
embedding (`torch.Tensor` of shape `(bs, num_channels, num_patches, d_model)` or
`(bs, num_channels, num_patches+1, d_model)` if `cls_token` is set to True, *required*):
Embedding from the model
Returns:
`torch.Tensor` of shape `(b... | forward | python | huggingface/transformers | src/transformers/models/patchtst/modeling_patchtst.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtst/modeling_patchtst.py | Apache-2.0 |
def forward(
self,
past_values: torch.Tensor,
target_values: Optional[torch.Tensor] = None,
past_observed_mask: Optional[torch.Tensor] = None,
output_hidden_states: Optional[bool] = None,
output_attentions: Optional[bool] = None,
return_dict: Optional[bool] = None... |
past_values (`torch.Tensor` of shape `(bs, sequence_length, num_input_channels)`, *required*):
Input sequence to the model
target_values (`torch.Tensor` of shape `(bs, num_input_channels)`):
Target values associates with the `past_values`
past_observed_mask (`torch.BoolT... | forward | python | huggingface/transformers | src/transformers/models/patchtst/modeling_patchtst.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtst/modeling_patchtst.py | Apache-2.0 |
def generate(
self,
past_values: torch.Tensor,
past_observed_mask: Optional[torch.Tensor] = None,
) -> SamplePatchTSTOutput:
"""
Generate sequences of sample predictions from a model with a probability distribution head.
Parameters:
past_values (`torch.Fl... |
Generate sequences of sample predictions from a model with a probability distribution head.
Parameters:
past_values (`torch.FloatTensor` of shape `(batch_size, sequence_length, num_input_channels)`):
Past values of the time series that serves as context in order to predict ... | generate | python | huggingface/transformers | src/transformers/models/patchtst/modeling_patchtst.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/patchtst/modeling_patchtst.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.Tensor] = None,
attention_mask: Optional[torch.Tensor] = None,
decoder_input_ids: Optional[torch.Tensor] = None,
decoder_attention_mask: Optional[torch.Tensor] = None,
head_mask: Optional[torch.Tensor] = None,
decoder_h... |
decoder_input_ids (`torch.LongTensor` of shape `(batch_size, target_sequence_length)`, *optional*):
Indices of decoder input sequence tokens in the vocabulary.
Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
[`PreTrainedTokenizer.__ca... | forward | python | huggingface/transformers | src/transformers/models/pegasus/modeling_pegasus.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/pegasus/modeling_pegasus.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.Tensor] = None,
attention_mask: Optional[torch.Tensor] = None,
decoder_input_ids: Optional[torch.Tensor] = None,
decoder_attention_mask: Optional[torch.Tensor] = None,
head_mask: Optional[torch.Tensor] = None,
decoder_h... |
decoder_input_ids (`torch.LongTensor` of shape `(batch_size, target_sequence_length)`, *optional*):
Indices of decoder input sequence tokens in the vocabulary.
Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
[`PreTrainedTokenizer.__ca... | forward | python | huggingface/transformers | src/transformers/models/pegasus/modeling_pegasus.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/pegasus/modeling_pegasus.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.Tensor] = None,
encoder_hidden_states: Optional[torch.FloatTensor] = None,
encoder_attention_mask: Optional[torch.FloatTensor] = None,
head_mask: Optional[torch.Tensor] = None,... |
cross_attn_head_mask (`torch.Tensor` of shape `(decoder_layers, decoder_attention_heads)`, *optional*):
Mask to nullify selected heads of the cross-attention modules. Mask values selected in `[0, 1]`:
- 1 indicates the head is **not masked**,
- 0 indicates the head is **mas... | forward | python | huggingface/transformers | src/transformers/models/pegasus/modeling_pegasus.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/pegasus/modeling_pegasus.py | Apache-2.0 |
def forward(
self,
hidden_states: torch.Tensor,
attention_mask: Optional[torch.Tensor] = None,
encoder_hidden_states: Optional[torch.Tensor] = None,
encoder_attention_mask: Optional[torch.Tensor] = None,
past_key_value: Optional[Cache] = None,
output_attentions: O... |
Args:
hidden_states (`torch.FloatTensor`): input to the layer of shape *(seq_len, batch, embed_dim)*
attention_mask (`torch.FloatTensor`): attention mask of size
*(batch, 1, tgt_len, src_len)* where padding elements are indicated by very large negative values.
... | forward | python | huggingface/transformers | src/transformers/models/pegasus_x/modeling_pegasus_x.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/pegasus_x/modeling_pegasus_x.py | Apache-2.0 |
def forward(
self,
input_ids=None,
attention_mask=None,
encoder_hidden_states=None,
encoder_attention_mask=None,
past_key_values=None,
inputs_embeds=None,
use_cache=None,
output_attentions=None,
output_hidden_states=None,
return_dic... |
Args:
input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you
provide it.
Indices can be obtained using [`AutoTokenizer`]. See [`PreTra... | forward | python | huggingface/transformers | src/transformers/models/pegasus_x/modeling_pegasus_x.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/pegasus_x/modeling_pegasus_x.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.Tensor] = None,
attention_mask: Optional[torch.Tensor] = None,
decoder_input_ids: Optional[torch.Tensor] = None,
decoder_attention_mask: Optional[torch.Tensor] = None,
encoder_outputs: Optional[Tuple[torch.FloatTensor]] = None,... |
decoder_input_ids (`torch.LongTensor` of shape `(batch_size, target_sequence_length)`, *optional*):
Indices of decoder input sequence tokens in the vocabulary.
Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
[`PreTrainedTokenizer.__ca... | forward | python | huggingface/transformers | src/transformers/models/pegasus_x/modeling_pegasus_x.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/pegasus_x/modeling_pegasus_x.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.Tensor] = None,
attention_mask: Optional[torch.Tensor] = None,
decoder_input_ids: Optional[torch.Tensor] = None,
decoder_attention_mask: Optional[torch.Tensor] = None,
encoder_outputs: Optional[Tuple[torch.FloatTensor]] = None,... |
decoder_input_ids (`torch.LongTensor` of shape `(batch_size, target_sequence_length)`, *optional*):
Indices of decoder input sequence tokens in the vocabulary.
Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
[`PreTrainedTokenizer.__ca... | forward | python | huggingface/transformers | src/transformers/models/pegasus_x/modeling_pegasus_x.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/pegasus_x/modeling_pegasus_x.py | Apache-2.0 |
def center_crop(
self,
image: "torch.Tensor",
crop_size: dict[str, int],
size: dict[str, int],
**kwargs,
) -> "torch.Tensor":
"""
Center crop an image to `(size["height"] / crop_size["height"] * min_dim, size["width"] / crop_size["width"] *
min_dim)`. ... |
Center crop an image to `(size["height"] / crop_size["height"] * min_dim, size["width"] / crop_size["width"] *
min_dim)`. Where `min_dim = min(size["height"], size["width"])`.
If the input size is smaller than `crop_size` along any edge, the image will be padded with zeros and then
cen... | center_crop | python | huggingface/transformers | src/transformers/models/perceiver/image_processing_perceiver_fast.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/perceiver/image_processing_perceiver_fast.py | Apache-2.0 |
def __init__(
self,
config,
decoder: Optional["PerceiverAbstractDecoder"] = None,
input_preprocessor: PreprocessorType = None,
output_postprocessor: PostprocessorType = None,
):
r"""
decoder (`PerceiverDecoder`, *optional*):
Decoder module that tra... |
decoder (`PerceiverDecoder`, *optional*):
Decoder module that transforms latent representations into task predictions.
input_preprocessor (`PreprocessorType`, *optional*):
Preprocessor that encodes raw inputs into tensors for the model.
output_postprocessor (`Postprocess... | __init__ | python | huggingface/transformers | src/transformers/models/perceiver/modeling_perceiver.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/perceiver/modeling_perceiver.py | Apache-2.0 |
def forward(
self,
inputs: torch.FloatTensor,
attention_mask: Optional[torch.FloatTensor] = None,
subsampled_output_points: Optional[Dict[str, torch.Tensor]] = None,
head_mask: Optional[torch.FloatTensor] = None,
output_attentions: Optional[bool] = None,
output_hi... |
inputs (`torch.FloatTensor`):
Inputs to the perceiver. Can be anything: images, text, audio, video, etc.
subsampled_output_points (`Dict[str, torch.Tensor]`, *optional*):
Dictionary of tensors used as queries for the decoder. The decoder maps these queries to the latent
... | forward | python | huggingface/transformers | src/transformers/models/perceiver/modeling_perceiver.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/perceiver/modeling_perceiver.py | Apache-2.0 |
def forward(
self,
inputs: Optional[torch.Tensor] = None,
attention_mask: Optional[torch.Tensor] = None,
head_mask: Optional[torch.Tensor] = None,
output_attentions: Optional[bool] = None,
output_hidden_states: Optional[bool] = None,
labels: Optional[torch.Tensor]... |
inputs (`torch.FloatTensor`):
Inputs to the perceiver. Can be anything: images, text, audio, video, etc.
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
Labels for computing the masked language modeling loss. Indices should be in `[-100, 0, ...,... | forward | python | huggingface/transformers | src/transformers/models/perceiver/modeling_perceiver.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/perceiver/modeling_perceiver.py | Apache-2.0 |
def forward(
self,
inputs: Optional[torch.Tensor] = None,
attention_mask: Optional[torch.Tensor] = None,
head_mask: Optional[torch.Tensor] = None,
output_attentions: Optional[bool] = None,
output_hidden_states: Optional[bool] = None,
labels: Optional[torch.Tensor]... |
inputs (`torch.FloatTensor`):
Inputs to the perceiver. Can be anything: images, text, audio, video, etc.
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
Labels for computing the classification/regression loss. Indices should be in `[0, ..., config.num_labels -
... | forward | python | huggingface/transformers | src/transformers/models/perceiver/modeling_perceiver.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/perceiver/modeling_perceiver.py | Apache-2.0 |
def forward(
self,
inputs: Optional[torch.Tensor] = None,
attention_mask: Optional[torch.Tensor] = None,
head_mask: Optional[torch.Tensor] = None,
output_attentions: Optional[bool] = None,
output_hidden_states: Optional[bool] = None,
labels: Optional[torch.Tensor]... |
inputs (`torch.FloatTensor`):
Inputs to the perceiver. Can be anything: images, text, audio, video, etc.
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
Labels for computing the image classification/regression loss. Indices should be in `[0, ...,
co... | forward | python | huggingface/transformers | src/transformers/models/perceiver/modeling_perceiver.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/perceiver/modeling_perceiver.py | Apache-2.0 |
def forward(
self,
inputs: Optional[torch.Tensor] = None,
attention_mask: Optional[torch.Tensor] = None,
head_mask: Optional[torch.Tensor] = None,
output_attentions: Optional[bool] = None,
output_hidden_states: Optional[bool] = None,
labels: Optional[torch.Tensor]... |
inputs (`torch.FloatTensor`):
Inputs to the perceiver. Can be anything: images, text, audio, video, etc.
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
Labels for computing the image classification/regression loss. Indices should be in `[0, ...,
co... | forward | python | huggingface/transformers | src/transformers/models/perceiver/modeling_perceiver.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/perceiver/modeling_perceiver.py | Apache-2.0 |
def forward(
self,
inputs: Optional[torch.Tensor] = None,
attention_mask: Optional[torch.Tensor] = None,
head_mask: Optional[torch.Tensor] = None,
output_attentions: Optional[bool] = None,
output_hidden_states: Optional[bool] = None,
labels: Optional[torch.Tensor]... |
inputs (`torch.FloatTensor`):
Inputs to the perceiver. Can be anything: images, text, audio, video, etc.
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
Labels for computing the image classification/regression loss. Indices should be in `[0, ...,
co... | forward | python | huggingface/transformers | src/transformers/models/perceiver/modeling_perceiver.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/perceiver/modeling_perceiver.py | Apache-2.0 |
def forward(
self,
inputs: Optional[torch.Tensor] = None,
attention_mask: Optional[torch.Tensor] = None,
head_mask: Optional[torch.Tensor] = None,
output_attentions: Optional[bool] = None,
output_hidden_states: Optional[bool] = None,
labels: Optional[torch.Tensor]... |
inputs (`torch.FloatTensor`):
Inputs to the perceiver. Can be anything: images, text, audio, video, etc.
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
Labels for computing the optical flow loss. Indices should be in `[0, ..., config.num_labels - 1]`.
... | forward | python | huggingface/transformers | src/transformers/models/perceiver/modeling_perceiver.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/perceiver/modeling_perceiver.py | Apache-2.0 |
def forward(
self,
inputs: Optional[torch.Tensor] = None,
attention_mask: Optional[torch.Tensor] = None,
subsampled_output_points: Optional[Dict[str, torch.Tensor]] = None,
head_mask: Optional[torch.Tensor] = None,
output_attentions: Optional[bool] = None,
output_... |
inputs (`torch.FloatTensor`):
Inputs to the perceiver. Can be anything: images, text, audio, video, etc.
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
Labels for computing the image classification/regression loss. Indices should be in `[0, ...,
co... | forward | python | huggingface/transformers | src/transformers/models/perceiver/modeling_perceiver.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/perceiver/modeling_perceiver.py | Apache-2.0 |
def _split_heads(self, fused_qkv: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
"""
Split the last dimension into (num_heads, head_dim) without making any copies, results share same memory
storage as `fused_qkv`
Args:
fused_qkv (`torch.tensor`): [batch_si... |
Split the last dimension into (num_heads, head_dim) without making any copies, results share same memory
storage as `fused_qkv`
Args:
fused_qkv (`torch.tensor`): [batch_size, seq_length, num_heads * 3 * head_dim]
Returns:
query: [batch_size, seq_length, num_hea... | _split_heads | python | huggingface/transformers | src/transformers/models/persimmon/modeling_persimmon.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/persimmon/modeling_persimmon.py | Apache-2.0 |
def forward(
self,
hidden_states: torch.Tensor,
attention_mask: Optional[torch.Tensor] = None,
position_ids: Optional[torch.LongTensor] = None,
past_key_value: Optional[Tuple[torch.Tensor]] = None,
output_attentions: Optional[bool] = False,
use_cache: Optional[boo... |
Args:
hidden_states (`torch.FloatTensor`): input to the layer of shape `(batch, seq_len, embed_dim)`
attention_mask (`torch.FloatTensor`, *optional*): attention mask of size
`(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values... | forward | python | huggingface/transformers | src/transformers/models/persimmon/modeling_persimmon.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/persimmon/modeling_persimmon.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.Tensor] = None,
position_ids: Optional[torch.LongTensor] = None,
past_key_values: Optional[Cache] = None,
inputs_embeds: Optional[torch.FloatTensor] = None,
labels: Opt... |
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
... | forward | python | huggingface/transformers | src/transformers/models/phi/modeling_phi.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/phi/modeling_phi.py | Apache-2.0 |
def forward(
self,
hidden_states: torch.Tensor,
attention_mask: Optional[torch.Tensor] = None,
position_ids: Optional[torch.LongTensor] = None,
past_key_value: Optional[Cache] = None,
output_attentions: Optional[bool] = False,
use_cache: Optional[bool] = False,
... |
Args:
hidden_states (`torch.FloatTensor`):
input to the layer of shape `(batch, seq_len, embed_dim)`
attention_mask (`torch.FloatTensor`, *optional*): attention mask of size
`(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large... | forward | python | huggingface/transformers | src/transformers/models/phi3/modeling_phi3.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/phi3/modeling_phi3.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.Tensor] = None,
position_ids: Optional[torch.LongTensor] = None,
past_key_values: Optional[Cache] = None,
inputs_embeds: Optional[torch.FloatTensor] = None,
labels: Opt... |
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
... | forward | python | huggingface/transformers | src/transformers/models/phi3/modeling_phi3.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/phi3/modeling_phi3.py | Apache-2.0 |
def extract_adapters_data(input_dir: str, output_dir: str):
"""Extract adapters data from the state dict and save weights and configs."""
speech_lora = {}
vision_lora = {}
shards = [file for file in os.listdir(input_dir) if file.endswith(".safetensors")]
for shard_file in shards:
original_st... | Extract adapters data from the state dict and save weights and configs. | extract_adapters_data | python | huggingface/transformers | src/transformers/models/phi4_multimodal/convert_phi4_multimodal_weights_to_hf.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/phi4_multimodal/convert_phi4_multimodal_weights_to_hf.py | Apache-2.0 |
def __call__(
self,
raw_speech: AudioInput,
sampling_rate: Optional[int] = None,
pad_to_multiple_of: Optional[int] = None,
padding: Optional[str] = "longest",
max_length: Optional[int] = None,
truncation: bool = False,
return_tensors: Optional[Union[str, T... |
Main method to featurize and prepare for the model one or several audio sequence(s). Implementation uses PyTorch for
the STFT computation if available, otherwise a slower NumPy based one.
Args:
raw_speech (`np.ndarray`, `torch.Tensor`, `List[np.ndarray]`, `List[torch.Tensor]`):
... | __call__ | python | huggingface/transformers | src/transformers/models/phi4_multimodal/feature_extraction_phi4_multimodal.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/phi4_multimodal/feature_extraction_phi4_multimodal.py | Apache-2.0 |
def _torch_extract_fbank_features(
self, waveform: "torch.FloatTensor", audio_lengths: "torch.Tensor", device: str = "cpu"
) -> "torch.FloatTensor":
"""
Compute the log mel-scaled spectrogram of batched waveforms using PyTorch's FFT implementation.
Args:
waveform (torch.... |
Compute the log mel-scaled spectrogram of batched waveforms using PyTorch's FFT implementation.
Args:
waveform (torch.FloatTensor` of shape `(batch_size, max_audio_length)`):
The batched waveforms.
audio_lengths (`torch.Tensor` of shape `(batch_size,)`):
... | _torch_extract_fbank_features | python | huggingface/transformers | src/transformers/models/phi4_multimodal/feature_extraction_phi4_multimodal.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/phi4_multimodal/feature_extraction_phi4_multimodal.py | Apache-2.0 |
def unfold_tensor(tensor, max_seq_len):
"""
For a given tensor with shape of (N, T, D), if sequence length T is longer than max_seq_len,
this function unfold it to a (NT', max_seq_len, D) where T' is T // max_seq_len.
Args:
tensor: N, T, D
"""
_, _, D = tensor.shape
tensor = tensor.t... |
For a given tensor with shape of (N, T, D), if sequence length T is longer than max_seq_len,
this function unfold it to a (NT', max_seq_len, D) where T' is T // max_seq_len.
Args:
tensor: N, T, D
| unfold_tensor | python | huggingface/transformers | src/transformers/models/phi4_multimodal/modeling_phi4_multimodal.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/phi4_multimodal/modeling_phi4_multimodal.py | Apache-2.0 |
def adaptive_enc_mask(x_len, chunk_start_idx, left_window=0, right_window=0):
"""
The function is very important for Transformer Transducer Streaming mode
Args:
xs_len (int): sequence length
chunk_start_idx (list): first idx of each chunk, such as [0,18,36,48]. It also supports adaptive chun... |
The function is very important for Transformer Transducer Streaming mode
Args:
xs_len (int): sequence length
chunk_start_idx (list): first idx of each chunk, such as [0,18,36,48]. It also supports adaptive chunk size [0,10,15,45]
left_window (int): how many left chunks can be seen
... | adaptive_enc_mask | python | huggingface/transformers | src/transformers/models/phi4_multimodal/modeling_phi4_multimodal.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/phi4_multimodal/modeling_phi4_multimodal.py | Apache-2.0 |
def forward_embeddings(self, hidden_states, masks):
"""Forwarding the inputs through the top embedding layers"""
seq_len = math.ceil(hidden_states.shape[1] / self.config.time_reduction)
if seq_len <= 0:
raise ValueError(
f"The sequence length after time reduction is i... | Forwarding the inputs through the top embedding layers | forward_embeddings | python | huggingface/transformers | src/transformers/models/phi4_multimodal/modeling_phi4_multimodal.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/phi4_multimodal/modeling_phi4_multimodal.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.Tensor] = None,
position_ids: Optional[torch.LongTensor] = None,
past_key_values: Optional[List[torch.FloatTensor]] = None,
inputs_embeds: Optional[torch.FloatTensor] = None,
... |
image_pixel_values (`torch.FloatTensor`, *optional*):
If the input contains images, these correspond to the pixel values after transformations (as returned by
the Processor)
image_sizes (`torch.LongTensor`, *optional*):
If the input contains images, these correspond ... | forward | python | huggingface/transformers | src/transformers/models/phi4_multimodal/modeling_phi4_multimodal.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/phi4_multimodal/modeling_phi4_multimodal.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.Tensor] = None,
position_ids: Optional[torch.LongTensor] = None,
past_key_values: Optional[List[torch.FloatTensor]] = None,
inputs_embeds: Optional[torch.FloatTensor] = None,
... |
image_pixel_values (`torch.FloatTensor`, *optional*):
If the input contains images, these correspond to the pixel values after transformations (as returned by
the Processor)
image_sizes (`torch.LongTensor`, *optional*):
If the input contains images, these correspond ... | forward | python | huggingface/transformers | src/transformers/models/phi4_multimodal/modeling_phi4_multimodal.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/phi4_multimodal/modeling_phi4_multimodal.py | Apache-2.0 |
def __call__(
self,
text: Union[TextInput, List[TextInput]],
images: Optional[ImageInput] = None,
audio: Optional[AudioInput] = None,
**kwargs: Unpack[ProcessingKwargs],
) -> BatchFeature:
"""
Main method to prepare for the model one or several sequences(s) an... |
Main method to prepare for the model one or several sequences(s) and image(s). This method forards the `text`
and `kwargs` arguments to GPT2Tokenizer's [`~GPT2Tokenizer.__call__`] if `text` is not `None` to encode
the text. To prepare the image(s), this method forwards the `images` and `kwrags`... | __call__ | python | huggingface/transformers | src/transformers/models/phi4_multimodal/processing_phi4_multimodal.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/phi4_multimodal/processing_phi4_multimodal.py | Apache-2.0 |
def forward(
ctx,
scores: torch.Tensor,
multiplier: torch.Tensor,
selected_experts: torch.Tensor,
masked_gates: torch.Tensor,
mask_for_one: torch.Tensor,
):
"""
Forward pass for the custom autograd function.
Args:
ctx: Context obje... |
Forward pass for the custom autograd function.
Args:
ctx: Context object to save information for backward computation.
scores (torch.Tensor): Input scores tensor.
multiplier (torch.Tensor): Multiplier tensor.
selected_experts (torch.Tensor): Tensor of se... | forward | python | huggingface/transformers | src/transformers/models/phimoe/modeling_phimoe.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/phimoe/modeling_phimoe.py | Apache-2.0 |
def backward(
ctx,
grad_at_output: torch.Tensor,
):
"""
Backward pass for the custom autograd function.
Args:
ctx: Context object with saved tensors from the forward pass.
grad_at_output (torch.Tensor): Gradient at the output.
Returns:
... |
Backward pass for the custom autograd function.
Args:
ctx: Context object with saved tensors from the forward pass.
grad_at_output (torch.Tensor): Gradient at the output.
Returns:
Tuple[torch.Tensor, None, None, None, None]: Gradients for the inputs.
... | backward | python | huggingface/transformers | src/transformers/models/phimoe/modeling_phimoe.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/phimoe/modeling_phimoe.py | Apache-2.0 |
def _prepare_4d_causal_attention_mask_with_cache_position(
attention_mask: torch.Tensor,
sequence_length: int,
target_length: int,
dtype: torch.dtype,
cache_position: torch.Tensor,
batch_size: int,
config: PhimoeConfig,
past_key_values: Cache,
):
... |
Creates a causal 4D mask of shape `(batch_size, 1, query_length, key_value_length)` from a 2D mask of shape
`(batch_size, key_value_length)`, or if the input `attention_mask` is already 4D, do nothing.
Args:
attention_mask (`torch.Tensor`):
A 2D attention mask of sh... | _prepare_4d_causal_attention_mask_with_cache_position | python | huggingface/transformers | src/transformers/models/phimoe/modeling_phimoe.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/phimoe/modeling_phimoe.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.Tensor] = None,
position_ids: Optional[torch.LongTensor] = None,
past_key_values: Optional[List[torch.FloatTensor]] = None,
inputs_embeds: Optional[torch.FloatTensor] = None,
... |
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
... | forward | python | huggingface/transformers | src/transformers/models/phimoe/modeling_phimoe.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/phimoe/modeling_phimoe.py | Apache-2.0 |
def forward(
self,
flattened_patches: Optional[torch.Tensor] = None,
attention_mask: Optional[torch.Tensor] = None,
head_mask: Optional[torch.Tensor] = None,
output_attentions: Optional[bool] = None,
output_hidden_states: Optional[bool] = None,
return_dict: Option... |
flattened_patches (`torch.FloatTensor` of shape `(batch_size, sequence_length, num_channels x patch_height x patch_width)`):
Flattened and padded pixel values. These values can be obtained using [`AutoImageProcessor`]. See
[`Pix2StructVisionImageProcessor.__call__`] for details. Check t... | forward | python | huggingface/transformers | src/transformers/models/pix2struct/modeling_pix2struct.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/pix2struct/modeling_pix2struct.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.FloatTensor] = None,
encoder_hidden_states: Optional[torch.FloatTensor] = None,
encoder_attention_mask: Optional[torch.FloatTensor] = None,
inputs_embeds: Optional[torch.LongTe... |
input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
Indices of input sequence tokens in the vocabulary. Pix2StructText is a model with relative position
embeddings so you should be able to pad the inputs on both the right and the left.
Indices can be ob... | forward | python | huggingface/transformers | src/transformers/models/pix2struct/modeling_pix2struct.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/pix2struct/modeling_pix2struct.py | Apache-2.0 |
def forward(
self,
flattened_patches: Optional[torch.FloatTensor] = None,
attention_mask: Optional[torch.FloatTensor] = None,
decoder_input_ids: Optional[torch.LongTensor] = None,
decoder_attention_mask: Optional[torch.BoolTensor] = None,
head_mask: Optional[torch.FloatTe... |
flattened_patches (`torch.FloatTensor` of shape `(batch_size, seq_length, hidden_size)`):
Flattened pixel patches. the `hidden_size` is obtained by the following formula: `hidden_size` =
`num_channels` * `patch_size` * `patch_size`
The process of flattening the pixel patche... | forward | python | huggingface/transformers | src/transformers/models/pix2struct/modeling_pix2struct.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/pix2struct/modeling_pix2struct.py | Apache-2.0 |
def _num_image_tokens(image_size: Tuple[int, int], patch_size: Tuple[int, int]) -> int:
"""
Calculate the number of image tokens given the image size and patch size.
Args:
image_size (`Tuple[int, int]`):
The size of the image as `(height, width)`.
patch_size (`Tuple[int, int]`):... |
Calculate the number of image tokens given the image size and patch size.
Args:
image_size (`Tuple[int, int]`):
The size of the image as `(height, width)`.
patch_size (`Tuple[int, int]`):
The patch size as `(height, width)`.
Returns:
`int`: The number of im... | _num_image_tokens | python | huggingface/transformers | src/transformers/models/pixtral/image_processing_pixtral.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/pixtral/image_processing_pixtral.py | Apache-2.0 |
def get_resize_output_image_size(
input_image: ImageInput,
size: Union[int, Tuple[int, int], List[int], Tuple[int]],
patch_size: Union[int, Tuple[int, int], List[int], Tuple[int]],
input_data_format: Optional[Union[str, ChannelDimension]] = None,
) -> tuple:
"""
Find the target (height, width) d... |
Find the target (height, width) dimension of the output image after resizing given the input image and the desired
size.
Args:
input_image (`ImageInput`):
The image to resize.
size (`int` or `Tuple[int, int]`):
Max image size an input image can be. Must be a diction... | get_resize_output_image_size | python | huggingface/transformers | src/transformers/models/pixtral/image_processing_pixtral.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/pixtral/image_processing_pixtral.py | Apache-2.0 |
def resize(
self,
image: np.ndarray,
size: Dict[str, int],
patch_size: Dict[str, int],
resample: PILImageResampling = PILImageResampling.BICUBIC,
data_format: Optional[Union[str, ChannelDimension]] = None,
input_data_format: Optional[Union[str, ChannelDimension]] ... |
Resize an image. The shortest edge of the image is resized to size["shortest_edge"], with the longest edge
resized to keep the input aspect ratio.
Args:
image (`np.ndarray`):
Image to resize.
size (`Dict[str, int]`):
Dict containing the l... | resize | python | huggingface/transformers | src/transformers/models/pixtral/image_processing_pixtral.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/pixtral/image_processing_pixtral.py | Apache-2.0 |
def _pad_for_batching(
self,
pixel_values: List[np.ndarray],
image_sizes: List[List[int]],
data_format: Optional[Union[str, ChannelDimension]] = None,
input_data_format: Optional[Union[str, ChannelDimension]] = None,
):
"""
Pads images on the `num_of_patches` ... |
Pads images on the `num_of_patches` dimension with zeros to form a batch of same number of patches.
Args:
pixel_values (`List[np.ndarray]`):
An array of pixel values of each images of shape (`batch_size`, `height`, `width`, `channels`)
image_sizes (`List[List[int... | _pad_for_batching | python | huggingface/transformers | src/transformers/models/pixtral/image_processing_pixtral.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/pixtral/image_processing_pixtral.py | Apache-2.0 |
def preprocess(
self,
images: ImageInput,
do_resize: Optional[bool] = None,
size: Optional[Dict[str, int]] = None,
patch_size: Optional[Dict[str, int]] = None,
resample: PILImageResampling = None,
do_rescale: Optional[bool] = None,
rescale_factor: Optional... |
Preprocess an image or batch of images.
Args:
images (`ImageInput`):
Image to preprocess. Expects a single or batch of images with pixel values ranging from 0 to 255. If
passing in images with pixel values between 0 and 1, set `do_rescale=False`.
... | preprocess | python | huggingface/transformers | src/transformers/models/pixtral/image_processing_pixtral.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/pixtral/image_processing_pixtral.py | Apache-2.0 |
def resize(
self,
image: torch.Tensor,
size: SizeDict,
patch_size: SizeDict,
interpolation: "F.InterpolationMode" = None,
**kwargs,
) -> torch.Tensor:
"""
Resize an image. The shortest edge of the image is resized to size["shortest_edge"], with the lon... |
Resize an image. The shortest edge of the image is resized to size["shortest_edge"], with the longest edge
resized to keep the input aspect ratio.
Args:
image (`torch.Tensor`):
Image to resize.
size (`SizeDict`):
Dict containing the longe... | resize | python | huggingface/transformers | src/transformers/models/pixtral/image_processing_pixtral_fast.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/pixtral/image_processing_pixtral_fast.py | Apache-2.0 |
def _pad_for_batching(
self,
pixel_values: List[torch.Tensor],
image_sizes: List[List[int]],
):
"""
Pads images on the `num_of_patches` dimension with zeros to form a batch of same number of patches.
Args:
pixel_values (`List[torch.Tensor]`):
... |
Pads images on the `num_of_patches` dimension with zeros to form a batch of same number of patches.
Args:
pixel_values (`List[torch.Tensor]`):
An array of pixel values of each images of shape (`batch_size`, `channels`, `height`, `width`)
image_sizes (`List[List[i... | _pad_for_batching | python | huggingface/transformers | src/transformers/models/pixtral/image_processing_pixtral_fast.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/pixtral/image_processing_pixtral_fast.py | Apache-2.0 |
def forward(
self,
inputs_embeds,
attention_mask: Optional[torch.Tensor] = None,
position_embeddings: Optional[Tuple[torch.Tensor, torch.Tensor]] = None,
output_attentions: Optional[bool] = None,
output_hidden_states: Optional[bool] = None,
return_dict: Optional[b... |
Args:
inputs_embeds (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`):
Embeddings which serve as input to the Transformer.
attention_mask (`torch.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
Mask to avoid perfor... | forward | python | huggingface/transformers | src/transformers/models/pixtral/modeling_pixtral.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/pixtral/modeling_pixtral.py | Apache-2.0 |
def __call__(
self,
images: ImageInput = None,
text: Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None,
audio=None,
videos=None,
**kwargs: Unpack[PixtralProcessorKwargs],
) -> BatchFeature:
"""
Main method to prepare ... |
Main method to prepare for the model one or several sequences(s) and image(s). This method forwards the `text`
and `kwargs` arguments to LlamaTokenizerFast's [`~LlamaTokenizerFast.__call__`] if `text` is not `None` to encode
the text. To prepare the image(s), this method forwards the `images` a... | __call__ | python | huggingface/transformers | src/transformers/models/pixtral/processing_pixtral.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/pixtral/processing_pixtral.py | Apache-2.0 |
def shift_tokens_right(input_ids: torch.Tensor, pad_token_id: int):
"""
Shift input ids one token to the right, and wrap the last non pad token (the <LID> token) Note that PLBart does not
have a single `decoder_start_token_id` in contrast to other Bart-like models.
"""
prev_output_tokens = input_ids... |
Shift input ids one token to the right, and wrap the last non pad token (the <LID> token) Note that PLBart does not
have a single `decoder_start_token_id` in contrast to other Bart-like models.
| shift_tokens_right | python | huggingface/transformers | src/transformers/models/plbart/modeling_plbart.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/plbart/modeling_plbart.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.LongTensor] = None,
decoder_input_ids: Optional[torch.LongTensor] = None,
decoder_attention_mask: Optional[torch.Tensor] = None,
head_mask: Optional[torch.Tensor] = None,
... |
decoder_input_ids (`torch.LongTensor` of shape `(batch_size, target_sequence_length)`, *optional*):
Indices of decoder input sequence tokens in the vocabulary.
Indices can be obtained using [`AutoTokenizer`] or [`PLBartMultiTokenizer`] depending on the checkpoint.
See [`Pre... | forward | python | huggingface/transformers | src/transformers/models/plbart/modeling_plbart.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/plbart/modeling_plbart.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.LongTensor] = None,
decoder_input_ids: Optional[torch.LongTensor] = None,
decoder_attention_mask: Optional[torch.Tensor] = None,
head_mask: Optional[torch.Tensor] = None,
... |
decoder_input_ids (`torch.LongTensor` of shape `(batch_size, target_sequence_length)`, *optional*):
Indices of decoder input sequence tokens in the vocabulary.
Indices can be obtained using [`AutoTokenizer`] or [`PLBartMultiTokenizer`] depending on the checkpoint.
See [`Pre... | forward | python | huggingface/transformers | src/transformers/models/plbart/modeling_plbart.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/plbart/modeling_plbart.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.Tensor] = None,
decoder_input_ids: Optional[torch.LongTensor] = None,
decoder_attention_mask: Optional[torch.LongTensor] = None,
head_mask: Optional[torch.Tensor] = None,
... |
decoder_input_ids (`torch.LongTensor` of shape `(batch_size, target_sequence_length)`, *optional*):
Indices of decoder input sequence tokens in the vocabulary.
Indices can be obtained using [`AutoTokenizer`] or [`PLBartMultiTokenizer`] depending on the checkpoint.
See [`Pre... | forward | python | huggingface/transformers | src/transformers/models/plbart/modeling_plbart.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/plbart/modeling_plbart.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.Tensor] = None,
encoder_hidden_states: Optional[torch.FloatTensor] = None,
encoder_attention_mask: Optional[torch.FloatTensor] = None,
head_mask: Optional[torch.Tensor] = None,... |
cross_attn_head_mask (`torch.Tensor` of shape `(decoder_layers, decoder_attention_heads)`, *optional*):
Mask to nullify selected heads of the cross-attention modules. Mask values selected in `[0, 1]`:
- 1 indicates the head is **not masked**,
- 0 indicates the head is **mas... | forward | python | huggingface/transformers | src/transformers/models/plbart/modeling_plbart.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/plbart/modeling_plbart.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.