diffusers icon indicating copy to clipboard operation
diffusers copied to clipboard

Frozen parameters in GaussianFourierProjection

Open vvvm23 opened this issue 3 years ago • 1 comments

Hi, just a beginner with diffusion models and have been using your implementations as reference. I have a question about this class

Why is requires_grad set to false in the weight parameter? Won't this mean, during training, the noise level embeddings won't be updated?

Thanks!

vvvm23 avatar Aug 11 '22 17:08 vvvm23

cc @patrickvonplaten

patil-suraj avatar Aug 12 '22 15:08 patil-suraj

Hey @vvvm23,

It's set to False because we don't want to train those parameters. I followed the implementaton of the original model here: https://github.com/yang-song/score_sde_pytorch/blob/1618ddea340f3e4a2ed7852a0694a809775cf8d0/models/layerspp.py#L37

Does this make sense?

patrickvonplaten avatar Aug 23 '22 12:08 patrickvonplaten

Hi @patrickvonplaten

I somewhat misphrased my original question, I'm aware setting requires_grad to False prevents that particular parameter from accumulating gradients, essentially stopping the training of those parameters.

But why would we not want to train the noise level embeddings? Or is this just a simple, fixed (albeit randomly initialised) projection from a per-batch noise value to a different space, which would later have some learned transformation applied to it?

Thanks!

vvvm23 avatar Aug 26 '22 09:08 vvvm23

Hey @vvvm23,

sinusoidal position features like GaussianFourierProjection don't need training because every embedding already has a distinctly different vector that the model can use a "cue" to know what time position has been passed to it.

If one wants to train position embedding vectors (or time embedding vectors here), one can just randomly initialize such a vector and let the model learn it. If however we use sinusoidal embeddings, there is no need to learn it

patrickvonplaten avatar Aug 30 '22 13:08 patrickvonplaten

Okay thank you @patrickvonplaten ! That explanation makes a lot of sense~

vvvm23 avatar Aug 31 '22 08:08 vvvm23