@@ -85,6 +85,10 @@ class FlaxUNet2DConditionModel(nn.Module, FlaxModelMixin, ConfigMixin):
8585 The dimension of the cross attention features.
8686 dropout (`float`, *optional*, defaults to 0):
8787 Dropout probability for down, up and bottleneck blocks.
88+ flip_sin_to_cos (`bool`, *optional*, defaults to `True`):
89+ Whether to flip the sin to cos in the time embedding.
90+ freq_shift (`int`, *optional*, defaults to 0): The frequency shift to apply to the time embedding.
91+
8892 """
8993
9094 sample_size : int = 32
@@ -105,6 +109,7 @@ class FlaxUNet2DConditionModel(nn.Module, FlaxModelMixin, ConfigMixin):
105109 dropout : float = 0.0
106110 use_linear_projection : bool = False
107111 dtype : jnp .dtype = jnp .float32
112+ flip_sin_to_cos : bool = True
108113 freq_shift : int = 0
109114
110115 def init_weights (self , rng : jax .random .PRNGKey ) -> FrozenDict :
@@ -133,7 +138,9 @@ def setup(self):
133138 )
134139
135140 # time
136- self .time_proj = FlaxTimesteps (block_out_channels [0 ], freq_shift = self .config .freq_shift )
141+ self .time_proj = FlaxTimesteps (
142+ block_out_channels [0 ], flip_sin_to_cos = self .flip_sin_to_cos , freq_shift = self .config .freq_shift
143+ )
137144 self .time_embedding = FlaxTimestepEmbedding (time_embed_dim , dtype = self .dtype )
138145
139146 only_cross_attention = self .only_cross_attention
0 commit comments