-
Notifications
You must be signed in to change notification settings - Fork 111
[2D LDM tutorial code] the scale factor #437
hello,
I am curious about the scaling factor.
In latent diffusion model, 0.18215 is mostly used scaling factor.
However in the 2D LDM tutorial code, another equation is used as below.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
with torch.no_grad():
with autocast(enabled=True):
z = autoencoderkl.encode_stage_2_inputs(check_data["image"].to(device))
print(f"Scaling factor set to {1/torch.std(z)}")
scale_factor = 1 / torch.std(z)
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
What is different?
All reactions
Replies: 1 comment
The value of 0.18215 was is the value of 1 / torch.std(z) determined in the latent diffusion model paper - see an explanation here, to ensure the inputs to the diffusion model have roughly unit variance.
We just calculate the scaling factor for our specific dataset in case the variance is different.