Unverified Commit 95113d13 authored by Yulv-git's avatar Yulv-git Committed by GitHub
Browse files

Fix some typos. (#17560)



* Fix some typos.
Signed-off-by: default avatarYulv-git <yulvchi@qq.com>

* Fix typo.
Signed-off-by: default avatarYulv-git <yulvchi@qq.com>

* make fixup.
parent ad28ca29
...@@ -174,7 +174,7 @@ def _compute_mask_indices( ...@@ -174,7 +174,7 @@ def _compute_mask_indices(
) )
spec_aug_mask_idxs = spec_aug_mask_idxs.reshape(batch_size, max_num_masked_span * mask_length) spec_aug_mask_idxs = spec_aug_mask_idxs.reshape(batch_size, max_num_masked_span * mask_length)
# add offset to the starting indexes so that that indexes now create a span # add offset to the starting indexes so that indexes now create a span
offsets = np.arange(mask_length)[None, None, :] offsets = np.arange(mask_length)[None, None, :]
offsets = np.broadcast_to(offsets, (batch_size, max_num_masked_span, mask_length)).reshape( offsets = np.broadcast_to(offsets, (batch_size, max_num_masked_span, mask_length)).reshape(
batch_size, max_num_masked_span * mask_length batch_size, max_num_masked_span * mask_length
......
...@@ -203,7 +203,7 @@ def _compute_mask_indices( ...@@ -203,7 +203,7 @@ def _compute_mask_indices(
Computes random mask spans for a given shape Computes random mask spans for a given shape
Args: Args:
shape: the the shape for which to compute masks. shape: the shape for which to compute masks.
should be of size 2 where first element is batch size and 2nd is timesteps should be of size 2 where first element is batch size and 2nd is timesteps
attention_mask: optional padding mask of the same size as shape, which will prevent masking padded elements attention_mask: optional padding mask of the same size as shape, which will prevent masking padded elements
mask_prob: mask_prob:
......
...@@ -2330,7 +2330,7 @@ class TFLEDForConditionalGeneration(TFLEDPreTrainedModel): ...@@ -2330,7 +2330,7 @@ class TFLEDForConditionalGeneration(TFLEDPreTrainedModel):
super().__init__(config, *inputs, **kwargs) super().__init__(config, *inputs, **kwargs)
self.led = TFLEDMainLayer(config, name="led") self.led = TFLEDMainLayer(config, name="led")
self.use_cache = config.use_cache self.use_cache = config.use_cache
# final_bias_logits is registered as a buffer in pytorch, so not trainable for the the sake of consistency. # final_bias_logits is registered as a buffer in pytorch, so not trainable for the sake of consistency.
self.final_logits_bias = self.add_weight( self.final_logits_bias = self.add_weight(
name="final_logits_bias", shape=[1, config.vocab_size], initializer="zeros", trainable=False name="final_logits_bias", shape=[1, config.vocab_size], initializer="zeros", trainable=False
) )
......
...@@ -1110,7 +1110,7 @@ class LxmertForPreTraining(LxmertPreTrainedModel): ...@@ -1110,7 +1110,7 @@ class LxmertForPreTraining(LxmertPreTrainedModel):
def get_qa_logit_layer(self) -> nn.Module: def get_qa_logit_layer(self) -> nn.Module:
""" """
Returns the the linear layer that produces question answering logits. Returns the linear layer that produces question answering logits.
Returns: Returns:
`nn.Module`: A torch module mapping the question answering prediction hidden states or `None` if LXMERT `nn.Module`: A torch module mapping the question answering prediction hidden states or `None` if LXMERT
...@@ -1341,7 +1341,7 @@ class LxmertForQuestionAnswering(LxmertPreTrainedModel): ...@@ -1341,7 +1341,7 @@ class LxmertForQuestionAnswering(LxmertPreTrainedModel):
def get_qa_logit_layer(self) -> nn.Module: def get_qa_logit_layer(self) -> nn.Module:
""" """
Returns the the linear layer that produces question answering logits Returns the linear layer that produces question answering logits
Returns: Returns:
`nn.Module`: A torch module mapping the question answering prediction hidden states. `None`: A NoneType `nn.Module`: A torch module mapping the question answering prediction hidden states. `None`: A NoneType
......
...@@ -1283,7 +1283,7 @@ class TFMarianMTModel(TFMarianPreTrainedModel, TFCausalLanguageModelingLoss): ...@@ -1283,7 +1283,7 @@ class TFMarianMTModel(TFMarianPreTrainedModel, TFCausalLanguageModelingLoss):
super().__init__(config, *inputs, **kwargs) super().__init__(config, *inputs, **kwargs)
self.model = TFMarianMainLayer(config, name="model") self.model = TFMarianMainLayer(config, name="model")
self.use_cache = config.use_cache self.use_cache = config.use_cache
# final_bias_logits is registered as a buffer in pytorch, so not trainable for the the sake of consistency. # final_bias_logits is registered as a buffer in pytorch, so not trainable for the sake of consistency.
self.final_logits_bias = self.add_weight( self.final_logits_bias = self.add_weight(
name="final_logits_bias", shape=[1, config.vocab_size], initializer="zeros", trainable=False name="final_logits_bias", shape=[1, config.vocab_size], initializer="zeros", trainable=False
) )
......
...@@ -1912,7 +1912,7 @@ class MaskFormerLoss(nn.Module): ...@@ -1912,7 +1912,7 @@ class MaskFormerLoss(nn.Module):
def get_num_masks(self, class_labels: torch.Tensor, device: torch.device) -> torch.Tensor: def get_num_masks(self, class_labels: torch.Tensor, device: torch.device) -> torch.Tensor:
""" """
Computes the average number of target masks accross the batch, for normalization purposes. Computes the average number of target masks across the batch, for normalization purposes.
""" """
num_masks = sum([len(classes) for classes in class_labels]) num_masks = sum([len(classes) for classes in class_labels])
num_masks_pt = torch.as_tensor([num_masks], dtype=torch.float, device=device) num_masks_pt = torch.as_tensor([num_masks], dtype=torch.float, device=device)
......
...@@ -1280,7 +1280,7 @@ class TFMBartForConditionalGeneration(TFMBartPreTrainedModel, TFCausalLanguageMo ...@@ -1280,7 +1280,7 @@ class TFMBartForConditionalGeneration(TFMBartPreTrainedModel, TFCausalLanguageMo
super().__init__(config, *inputs, **kwargs) super().__init__(config, *inputs, **kwargs)
self.model = TFMBartMainLayer(config, name="model") self.model = TFMBartMainLayer(config, name="model")
self.use_cache = config.use_cache self.use_cache = config.use_cache
# final_bias_logits is registered as a buffer in pytorch, so not trainable for the the sake of consistency. # final_bias_logits is registered as a buffer in pytorch, so not trainable for the sake of consistency.
self.final_logits_bias = self.add_weight( self.final_logits_bias = self.add_weight(
name="final_logits_bias", shape=[1, config.vocab_size], initializer="zeros", trainable=False name="final_logits_bias", shape=[1, config.vocab_size], initializer="zeros", trainable=False
) )
......
...@@ -1292,7 +1292,7 @@ class TFPegasusForConditionalGeneration(TFPegasusPreTrainedModel, TFCausalLangua ...@@ -1292,7 +1292,7 @@ class TFPegasusForConditionalGeneration(TFPegasusPreTrainedModel, TFCausalLangua
super().__init__(config, *inputs, **kwargs) super().__init__(config, *inputs, **kwargs)
self.model = TFPegasusMainLayer(config, name="model") self.model = TFPegasusMainLayer(config, name="model")
self.use_cache = config.use_cache self.use_cache = config.use_cache
# final_bias_logits is registered as a buffer in pytorch, so not trainable for the the sake of consistency. # final_bias_logits is registered as a buffer in pytorch, so not trainable for the sake of consistency.
self.final_logits_bias = self.add_weight( self.final_logits_bias = self.add_weight(
name="final_logits_bias", shape=[1, config.vocab_size], initializer="zeros", trainable=False name="final_logits_bias", shape=[1, config.vocab_size], initializer="zeros", trainable=False
) )
......
...@@ -28,7 +28,7 @@ RAG_CONFIG_DOC = r""" ...@@ -28,7 +28,7 @@ RAG_CONFIG_DOC = r"""
title_sep (`str`, *optional*, defaults to `" / "`): title_sep (`str`, *optional*, defaults to `" / "`):
Separator inserted between the title and the text of the retrieved document when calling [`RagRetriever`]. Separator inserted between the title and the text of the retrieved document when calling [`RagRetriever`].
doc_sep (`str`, *optional*, defaults to `" // "`): doc_sep (`str`, *optional*, defaults to `" // "`):
Separator inserted between the the text of the retrieved document and the original input when calling Separator inserted between the text of the retrieved document and the original input when calling
[`RagRetriever`]. [`RagRetriever`].
n_docs (`int`, *optional*, defaults to 5): n_docs (`int`, *optional*, defaults to 5):
Number of documents to retrieve. Number of documents to retrieve.
......
...@@ -81,10 +81,10 @@ class SEWConfig(PretrainedConfig): ...@@ -81,10 +81,10 @@ class SEWConfig(PretrainedConfig):
feature encoder. The length of *conv_dim* defines the number of 1D convolutional layers. feature encoder. The length of *conv_dim* defines the number of 1D convolutional layers.
conv_stride (`Tuple[int]` or `List[int]`, *optional*, defaults to `(5, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1)`): conv_stride (`Tuple[int]` or `List[int]`, *optional*, defaults to `(5, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1)`):
A tuple of integers defining the stride of each 1D convolutional layer in the feature encoder. The length A tuple of integers defining the stride of each 1D convolutional layer in the feature encoder. The length
of *conv_stride* defines the number of convolutional layers and has to match the the length of *conv_dim*. of *conv_stride* defines the number of convolutional layers and has to match the length of *conv_dim*.
conv_kernel (`Tuple[int]` or `List[int]`, *optional*, defaults to `(10, 3, 1, 3, 1, 3, 1, 3, 1, 2, 1, 2, 1)`): conv_kernel (`Tuple[int]` or `List[int]`, *optional*, defaults to `(10, 3, 1, 3, 1, 3, 1, 3, 1, 2, 1, 2, 1)`):
A tuple of integers defining the kernel size of each 1D convolutional layer in the feature encoder. The A tuple of integers defining the kernel size of each 1D convolutional layer in the feature encoder. The
length of *conv_kernel* defines the number of convolutional layers and has to match the the length of length of *conv_kernel* defines the number of convolutional layers and has to match the length of
*conv_dim*. *conv_dim*.
conv_bias (`bool`, *optional*, defaults to `False`): conv_bias (`bool`, *optional*, defaults to `False`):
Whether the 1D convolutional layers have a bias. Whether the 1D convolutional layers have a bias.
......
...@@ -174,7 +174,7 @@ def _compute_mask_indices( ...@@ -174,7 +174,7 @@ def _compute_mask_indices(
) )
spec_aug_mask_idxs = spec_aug_mask_idxs.reshape(batch_size, max_num_masked_span * mask_length) spec_aug_mask_idxs = spec_aug_mask_idxs.reshape(batch_size, max_num_masked_span * mask_length)
# add offset to the starting indexes so that that indexes now create a span # add offset to the starting indexes so that indexes now create a span
offsets = np.arange(mask_length)[None, None, :] offsets = np.arange(mask_length)[None, None, :]
offsets = np.broadcast_to(offsets, (batch_size, max_num_masked_span, mask_length)).reshape( offsets = np.broadcast_to(offsets, (batch_size, max_num_masked_span, mask_length)).reshape(
batch_size, max_num_masked_span * mask_length batch_size, max_num_masked_span * mask_length
......
...@@ -99,10 +99,10 @@ class SEWDConfig(PretrainedConfig): ...@@ -99,10 +99,10 @@ class SEWDConfig(PretrainedConfig):
feature encoder. The length of *conv_dim* defines the number of 1D convolutional layers. feature encoder. The length of *conv_dim* defines the number of 1D convolutional layers.
conv_stride (`Tuple[int]` or `List[int]`, *optional*, defaults to `(5, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1)`): conv_stride (`Tuple[int]` or `List[int]`, *optional*, defaults to `(5, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1)`):
A tuple of integers defining the stride of each 1D convolutional layer in the feature encoder. The length A tuple of integers defining the stride of each 1D convolutional layer in the feature encoder. The length
of *conv_stride* defines the number of convolutional layers and has to match the the length of *conv_dim*. of *conv_stride* defines the number of convolutional layers and has to match the length of *conv_dim*.
conv_kernel (`Tuple[int]` or `List[int]`, *optional*, defaults to `(10, 3, 1, 3, 1, 3, 1, 3, 1, 2, 1, 2, 1)`): conv_kernel (`Tuple[int]` or `List[int]`, *optional*, defaults to `(10, 3, 1, 3, 1, 3, 1, 3, 1, 2, 1, 2, 1)`):
A tuple of integers defining the kernel size of each 1D convolutional layer in the feature encoder. The A tuple of integers defining the kernel size of each 1D convolutional layer in the feature encoder. The
length of *conv_kernel* defines the number of convolutional layers and has to match the the length of length of *conv_kernel* defines the number of convolutional layers and has to match the length of
*conv_dim*. *conv_dim*.
conv_bias (`bool`, *optional*, defaults to `False`): conv_bias (`bool`, *optional*, defaults to `False`):
Whether the 1D convolutional layers have a bias. Whether the 1D convolutional layers have a bias.
......
...@@ -175,7 +175,7 @@ def _compute_mask_indices( ...@@ -175,7 +175,7 @@ def _compute_mask_indices(
) )
spec_aug_mask_idxs = spec_aug_mask_idxs.reshape(batch_size, max_num_masked_span * mask_length) spec_aug_mask_idxs = spec_aug_mask_idxs.reshape(batch_size, max_num_masked_span * mask_length)
# add offset to the starting indexes so that that indexes now create a span # add offset to the starting indexes so that indexes now create a span
offsets = np.arange(mask_length)[None, None, :] offsets = np.arange(mask_length)[None, None, :]
offsets = np.broadcast_to(offsets, (batch_size, max_num_masked_span, mask_length)).reshape( offsets = np.broadcast_to(offsets, (batch_size, max_num_masked_span, mask_length)).reshape(
batch_size, max_num_masked_span * mask_length batch_size, max_num_masked_span * mask_length
......
...@@ -85,10 +85,10 @@ class UniSpeechConfig(PretrainedConfig): ...@@ -85,10 +85,10 @@ class UniSpeechConfig(PretrainedConfig):
feature encoder. The length of *conv_dim* defines the number of 1D convolutional layers. feature encoder. The length of *conv_dim* defines the number of 1D convolutional layers.
conv_stride (`Tuple[int]` or `List[int]`, *optional*, defaults to `(5, 2, 2, 2, 2, 2, 2)`): conv_stride (`Tuple[int]` or `List[int]`, *optional*, defaults to `(5, 2, 2, 2, 2, 2, 2)`):
A tuple of integers defining the stride of each 1D convolutional layer in the feature encoder. The length A tuple of integers defining the stride of each 1D convolutional layer in the feature encoder. The length
of *conv_stride* defines the number of convolutional layers and has to match the the length of *conv_dim*. of *conv_stride* defines the number of convolutional layers and has to match the length of *conv_dim*.
conv_kernel (`Tuple[int]` or `List[int]`, *optional*, defaults to `(10, 3, 3, 3, 3, 3, 3)`): conv_kernel (`Tuple[int]` or `List[int]`, *optional*, defaults to `(10, 3, 3, 3, 3, 3, 3)`):
A tuple of integers defining the kernel size of each 1D convolutional layer in the feature encoder. The A tuple of integers defining the kernel size of each 1D convolutional layer in the feature encoder. The
length of *conv_kernel* defines the number of convolutional layers and has to match the the length of length of *conv_kernel* defines the number of convolutional layers and has to match the length of
*conv_dim*. *conv_dim*.
conv_bias (`bool`, *optional*, defaults to `False`): conv_bias (`bool`, *optional*, defaults to `False`):
Whether the 1D convolutional layers have a bias. Whether the 1D convolutional layers have a bias.
......
...@@ -210,7 +210,7 @@ def _compute_mask_indices( ...@@ -210,7 +210,7 @@ def _compute_mask_indices(
) )
spec_aug_mask_idxs = spec_aug_mask_idxs.reshape(batch_size, max_num_masked_span * mask_length) spec_aug_mask_idxs = spec_aug_mask_idxs.reshape(batch_size, max_num_masked_span * mask_length)
# add offset to the starting indexes so that that indexes now create a span # add offset to the starting indexes so that indexes now create a span
offsets = np.arange(mask_length)[None, None, :] offsets = np.arange(mask_length)[None, None, :]
offsets = np.broadcast_to(offsets, (batch_size, max_num_masked_span, mask_length)).reshape( offsets = np.broadcast_to(offsets, (batch_size, max_num_masked_span, mask_length)).reshape(
batch_size, max_num_masked_span * mask_length batch_size, max_num_masked_span * mask_length
......
...@@ -86,10 +86,10 @@ class UniSpeechSatConfig(PretrainedConfig): ...@@ -86,10 +86,10 @@ class UniSpeechSatConfig(PretrainedConfig):
feature encoder. The length of *conv_dim* defines the number of 1D convolutional layers. feature encoder. The length of *conv_dim* defines the number of 1D convolutional layers.
conv_stride (`Tuple[int]` or `List[int]`, *optional*, defaults to `(5, 2, 2, 2, 2, 2, 2)`): conv_stride (`Tuple[int]` or `List[int]`, *optional*, defaults to `(5, 2, 2, 2, 2, 2, 2)`):
A tuple of integers defining the stride of each 1D convolutional layer in the feature encoder. The length A tuple of integers defining the stride of each 1D convolutional layer in the feature encoder. The length
of *conv_stride* defines the number of convolutional layers and has to match the the length of *conv_dim*. of *conv_stride* defines the number of convolutional layers and has to match the length of *conv_dim*.
conv_kernel (`Tuple[int]` or `List[int]`, *optional*, defaults to `(10, 3, 3, 3, 3, 3, 3)`): conv_kernel (`Tuple[int]` or `List[int]`, *optional*, defaults to `(10, 3, 3, 3, 3, 3, 3)`):
A tuple of integers defining the kernel size of each 1D convolutional layer in the feature encoder. The A tuple of integers defining the kernel size of each 1D convolutional layer in the feature encoder. The
length of *conv_kernel* defines the number of convolutional layers and has to match the the length of length of *conv_kernel* defines the number of convolutional layers and has to match the length of
*conv_dim*. *conv_dim*.
conv_bias (`bool`, *optional*, defaults to `False`): conv_bias (`bool`, *optional*, defaults to `False`):
Whether the 1D convolutional layers have a bias. Whether the 1D convolutional layers have a bias.
......
...@@ -224,7 +224,7 @@ def _compute_mask_indices( ...@@ -224,7 +224,7 @@ def _compute_mask_indices(
) )
spec_aug_mask_idxs = spec_aug_mask_idxs.reshape(batch_size, max_num_masked_span * mask_length) spec_aug_mask_idxs = spec_aug_mask_idxs.reshape(batch_size, max_num_masked_span * mask_length)
# add offset to the starting indexes so that that indexes now create a span # add offset to the starting indexes so that indexes now create a span
offsets = np.arange(mask_length)[None, None, :] offsets = np.arange(mask_length)[None, None, :]
offsets = np.broadcast_to(offsets, (batch_size, max_num_masked_span, mask_length)).reshape( offsets = np.broadcast_to(offsets, (batch_size, max_num_masked_span, mask_length)).reshape(
batch_size, max_num_masked_span * mask_length batch_size, max_num_masked_span * mask_length
......
...@@ -120,7 +120,7 @@ def _compute_mask_indices( ...@@ -120,7 +120,7 @@ def _compute_mask_indices(
CPU as part of the preprocessing during training. CPU as part of the preprocessing during training.
Args: Args:
shape: the the shape for which to compute masks. shape: the shape for which to compute masks.
should be of size 2 where first element is batch size and 2nd is timesteps should be of size 2 where first element is batch size and 2nd is timesteps
mask_prob: mask_prob:
probability for each token to be chosen as start of the span to be masked. this will be multiplied by probability for each token to be chosen as start of the span to be masked. this will be multiplied by
......
...@@ -244,7 +244,7 @@ def _compute_mask_indices( ...@@ -244,7 +244,7 @@ def _compute_mask_indices(
Computes random mask spans for a given shape Computes random mask spans for a given shape
Args: Args:
shape: the the shape for which to compute masks. shape: the shape for which to compute masks.
should be of size 2 where first element is batch size and 2nd is timesteps should be of size 2 where first element is batch size and 2nd is timesteps
attention_mask: optional padding mask of the same size as shape, which will prevent masking padded elements attention_mask: optional padding mask of the same size as shape, which will prevent masking padded elements
mask_prob: mask_prob:
......
...@@ -234,7 +234,7 @@ def _compute_mask_indices( ...@@ -234,7 +234,7 @@ def _compute_mask_indices(
) )
spec_aug_mask_idxs = spec_aug_mask_idxs.reshape(batch_size, max_num_masked_span * mask_length) spec_aug_mask_idxs = spec_aug_mask_idxs.reshape(batch_size, max_num_masked_span * mask_length)
# add offset to the starting indexes so that that indexes now create a span # add offset to the starting indexes so that indexes now create a span
offsets = np.arange(mask_length)[None, None, :] offsets = np.arange(mask_length)[None, None, :]
offsets = np.broadcast_to(offsets, (batch_size, max_num_masked_span, mask_length)).reshape( offsets = np.broadcast_to(offsets, (batch_size, max_num_masked_span, mask_length)).reshape(
batch_size, max_num_masked_span * mask_length batch_size, max_num_masked_span * mask_length
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment