[clap] Add clap#6028
Merged
Merged
Conversation
|
Thanks for your contribution! |
Codecov Report
@@ Coverage Diff @@
## develop #6028 +/- ##
===========================================
+ Coverage 62.52% 62.97% +0.44%
===========================================
Files 492 505 +13
Lines 69317 70949 +1632
===========================================
+ Hits 43342 44680 +1338
- Misses 25975 26269 +294
|
JunnYu
reviewed
May 31, 2023
| self.local_att = nn.Sequential( | ||
| nn.Conv2D(channels, inter_channels, kernel_size=1, stride=1, padding=0), | ||
| nn.BatchNorm2D(inter_channels), | ||
| nn.ReLU(inplace=True), |
| def _get_arguments_from_pretrained(cls, pretrained_model_name_or_path, **kwargs): | ||
| args = [] | ||
| for attribute_name in cls.attributes: | ||
| # breakpoint() |
| # Copied from paddlenlp.transformers.models.bert.modeling_bert.BertEmbeddings.__init__ | ||
| def __init__(self, config): | ||
| super().__init__() | ||
| self.word_embeddings = nn.Embedding(config.vocab_size, config.hidden_size, padding_idx=config.pad_token_id) |
| # End copy | ||
| self.padding_idx = config.pad_token_id | ||
| self.position_embeddings = nn.Embedding( | ||
| config.max_position_embeddings, config.hidden_size, padding_idx=self.padding_idx |
| if token_type_ids is None: | ||
| if hasattr(self, "token_type_ids"): | ||
| buffered_token_type_ids = self.token_type_ids[:, :seq_length] | ||
| buffered_token_type_ids_expanded = buffered_token_type_ids.expand(input_shape[0], seq_length) |
| self.projection_hidden_act = projection_hidden_act | ||
|
|
||
| @classmethod | ||
| def from_pretrained(cls, pretrained_model_name_or_path: Union[str, os.PathLike], **kwargs) -> "PretrainedConfig": |
Member
There was a problem hiding this comment.
@classmethod
def from_pretrained(
cls,
pretrained_model_name_or_path: Union[str, os.PathLike],
from_hf_hub: bool = False,
cache_dir: Optional[str] = None,
**kwargs
) -> PretrainedConfig:
kwargs.update({"from_hf_hub": from_hf_hub, "cache_dir": cache_dir})
这样
| self.projection_dim = projection_dim | ||
|
|
||
| @classmethod | ||
| def from_pretrained(cls, pretrained_model_name_or_path: Union[str, os.PathLike], **kwargs) -> "PretrainedConfig": |
| The ratio of the length of the output to the length of the input. | ||
| """ | ||
| (batch_size, time_length, classes_num) = hidden_states.shape | ||
| upsampled = hidden_states[:, :, None, :].repeat(1, 1, ratio, 1) |
|
|
||
| random_tensor = keep_prob + paddle.rand(shape, dtype=hidden_states.dtype) | ||
| random_tensor.floor_() # binarize | ||
| output = hidden_states.div(keep_prob) * random_tensor |
|
|
||
| config_class = ClapConfig | ||
| base_model_prefix = "clap" | ||
| supports_gradient_checkpointing = False |
Member
There was a problem hiding this comment.
supports_gradient_checkpointing = True
JunnYu
reviewed
May 31, 2023
|
|
||
| >>> outputs = model(**inputs) | ||
| >>> logits_per_audio = outputs.logits_per_audio # this is the audio-text similarity score | ||
| >>> probs = logits_per_audio.softmax(dim=-1) # we can take the softmax to get the label probabilities |
JunnYu
approved these changes
Jun 1, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR types
PR changes
Description
TODO: