MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / TimestepEmbedding

Class TimestepEmbedding

diffusers/src/diffusers/models/embeddings.py:717–762  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

715
716
717class TimestepEmbedding(nn.Module):
718 def __init__(
719 self,
720 in_channels: int,
721 time_embed_dim: int,
722 act_fn: str = "silu",
723 out_dim: int = None,
724 post_act_fn: Optional[str] = None,
725 cond_proj_dim=None,
726 sample_proj_bias=True,
727 ):
728 super().__init__()
729
730 self.linear_1 = nn.Linear(in_channels, time_embed_dim, sample_proj_bias)
731
732 if cond_proj_dim is not None:
733 self.cond_proj = nn.Linear(cond_proj_dim, in_channels, bias=False)
734 else:
735 self.cond_proj = None
736
737 self.act = get_activation(act_fn)
738
739 if out_dim is not None:
740 time_embed_dim_out = out_dim
741 else:
742 time_embed_dim_out = time_embed_dim
743 self.linear_2 = nn.Linear(time_embed_dim, time_embed_dim_out, sample_proj_bias)
744
745 if post_act_fn is None:
746 self.post_act = None
747 else:
748 self.post_act = get_activation(post_act_fn)
749
750 def forward(self, sample, condition=None):
751 if condition is not None:
752 sample = sample + self.cond_proj(condition)
753 sample = self.linear_1(sample)
754
755 if self.act is not None:
756 sample = self.act(sample)
757
758 sample = self.linear_2(sample)
759
760 if self.post_act is not None:
761 sample = self.post_act(sample)
762 return sample
763
764
765class Timesteps(nn.Module):

Callers 15

__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected