A Transformer model for video-like data. Parameters: num_attention_heads (`int`, *optional*, defaults to 16): The number of heads to use for multi-head attention. attention_head_dim (`int`, *optional*, defaults to 88): The number of channels in each head. in_channel
| 25 | |
| 26 | |
| 27 | class TransformerTemporalModel(ModelMixin, ConfigMixin): |
| 28 | """ |
| 29 | A Transformer model for video-like data. |
| 30 | |
| 31 | Parameters: |
| 32 | num_attention_heads (`int`, *optional*, defaults to 16): The number of heads to use for multi-head attention. |
| 33 | attention_head_dim (`int`, *optional*, defaults to 88): The number of channels in each head. |
| 34 | in_channels (`int`, *optional*): |
| 35 | The number of channels in the input and output (specify if the input is **continuous**). |
| 36 | num_layers (`int`, *optional*, defaults to 1): The number of layers of Transformer blocks to use. |
| 37 | dropout (`float`, *optional*, defaults to 0.0): The dropout probability to use. |
| 38 | cross_attention_dim (`int`, *optional*): The number of `encoder_hidden_states` dimensions to use. |
| 39 | attention_bias (`bool`, *optional*): |
| 40 | Configure if the `TransformerBlock` attention should contain a bias parameter. |
| 41 | sample_size (`int`, *optional*): The width of the latent images (specify if the input is **discrete**). |
| 42 | This is fixed during training since it is used to learn a number of position embeddings. |
| 43 | activation_fn (`str`, *optional*, defaults to `"geglu"`): |
| 44 | Activation function to use in feed-forward. See `diffusers.models.activations.get_activation` for supported |
| 45 | activation functions. |
| 46 | norm_elementwise_affine (`bool`, *optional*): |
| 47 | Configure if the `TransformerBlock` should use learnable elementwise affine parameters for normalization. |
| 48 | double_self_attention (`bool`, *optional*): |
| 49 | Configure if each `TransformerBlock` should contain two self-attention layers. |
| 50 | positional_embeddings: (`str`, *optional*): |
| 51 | The type of positional embeddings to apply to the sequence input before passing use. |
| 52 | num_positional_embeddings: (`int`, *optional*): |
| 53 | The maximum length of the sequence over which to apply positional embeddings. |
| 54 | """ |
| 55 | |
| 56 | @register_to_config |
| 57 | def __init__( |
| 58 | self, |
| 59 | num_attention_heads: int = 16, |
| 60 | attention_head_dim: int = 88, |
| 61 | in_channels: Optional[int] = None, |
| 62 | out_channels: Optional[int] = None, |
| 63 | num_layers: int = 1, |
| 64 | dropout: float = 0.0, |
| 65 | norm_num_groups: int = 32, |
| 66 | cross_attention_dim: Optional[int] = None, |
| 67 | attention_bias: bool = False, |
| 68 | sample_size: Optional[int] = None, |
| 69 | activation_fn: str = "geglu", |
| 70 | norm_elementwise_affine: bool = True, |
| 71 | double_self_attention: bool = True, |
| 72 | positional_embeddings: Optional[str] = None, |
| 73 | num_positional_embeddings: Optional[int] = None, |
| 74 | ): |
| 75 | super().__init__() |
| 76 | self.num_attention_heads = num_attention_heads |
| 77 | self.attention_head_dim = attention_head_dim |
| 78 | inner_dim = num_attention_heads * attention_head_dim |
| 79 | |
| 80 | self.in_channels = in_channels |
| 81 | |
| 82 | self.norm = torch.nn.GroupNorm(num_groups=norm_num_groups, num_channels=in_channels, eps=1e-6, affine=True) |
| 83 | self.proj_in = nn.Linear(in_channels, inner_dim) |
| 84 |
nothing calls this directly
no outgoing calls
no test coverage detected