Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add masked loss implementation #589

Closed
wants to merge 7 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add back mask rescale by mean
  • Loading branch information
recris committed Oct 16, 2023
commit a34222a2f033ec78d1e583392446f93664d76dd4
6 changes: 6 additions & 0 deletions library/custom_train_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 458,12 @@ def apply_noise_offset(latents, noise, noise_offset, adaptive_noise_scale):


def get_latent_masks(image_masks, latent_shape, device):
# given that masks lower the average loss this will counteract the effect
factor = torch.sqrt(image_masks.mean([1, 2]))
factor = torch.where(factor != 0.0, factor, 1.0)
factor = factor.reshape(factor.shape (1,) * 2)
image_masks = image_masks / factor

masks = (
image_masks
.to(device)
Expand Down