Skip to content

Commit

Permalink
condition strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
lucidtronix committed Dec 16, 2024
1 parent 82a9d67 commit d85a97d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ml4h/models/diffusion_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,12 @@ def condition_layer_film(input_tensor, control_vector, filters):
beta = layers.Dense(filters, activation="linear")(control_vector)

# Reshape gamma and beta to match the spatial dimensions
gamma = tf.reshape(gamma, (-1, 1, 1, filters))
beta = tf.reshape(beta, (-1, 1, 1, filters))

if 4 == len(input_tensor.shape):
gamma = tf.reshape(gamma, (-1, 1, 1, filters))
beta = tf.reshape(beta, (-1, 1, 1, filters))
elif 3 == len(input_tensor.shape):
gamma = tf.reshape(gamma, (-1, 1, filters))
beta = tf.reshape(beta, (-1, 1, filters))
# Apply FiLM (Feature-wise Linear Modulation)
return input_tensor * gamma + beta

Expand Down

0 comments on commit d85a97d

Please sign in to comment.