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

When I should use --attn-res-layers and what principle to setup values at this parameter? #31

Open
Dok11 opened this issue Dec 23, 2020 · 8 comments

Comments

@Dok11
Copy link
Contributor

Dok11 commented Dec 23, 2020

Why default is [32] and when it need to increase count of items ([32,64,128] for example) or values?
I see what it use more memory so I think it must increase quality but where is tradeoff?

@Mut1nyJD
Copy link

Mut1nyJD commented Dec 23, 2020

Yes using attention does improve quality at least reflected in the FID scores they tend to go lower.
Tradeoff is larger more memory usage and longer training time.

@Dok11
Copy link
Contributor Author

Dok11 commented Dec 23, 2020

What is better? Change [32] to [96] or [32,64]? What is the different?

@woctezuma
Copy link

What is better? Change [32] to [96] or [32,64]? What is the different?

I think it should be a power of 2, so 96 would not be valid.

for (res, (chan_in, chan_out)) in zip(self.res_layers, in_out_features):
image_width = 2 ** res
attn = None
if image_width in attn_res_layers:
attn = Rezero(GSA(dim = chan_in, norm_queries = True))

@Dok11
Copy link
Contributor Author

Dok11 commented Dec 23, 2020

Of course, but my question about different beween one large value vs. two smaller values

@Mut1nyJD
Copy link

@Dok11 I think you are misunderstanding the value, it puts multiple attention layers at the resolutions you specify into the neural network graph, so at more resolutions the better of course as you'll get attention at different levels. It's the same as convolutions. If you can only effort one it depends on your training data has it lot of global structure (then lower resolution layer is beneficial) or lot of local structure (then a higher resolution layer is more beneficial)

@Dok11
Copy link
Contributor Author

Dok11 commented Dec 23, 2020

I thought same but I hoped someone can help me with some examples with this values.
For example, for some purpose we use param is [32], for other purpose/images we use params if [8,16,32,64].
Maybe have reason to create some synthetic dataset to test this parameters in practice? Like this:
image

@Dok11
Copy link
Contributor Author

Dok11 commented Jan 23, 2021

@Mut1nyJD I still not undrestanding attn layers, but I think have reasonable question. By changing attn-res-layers from [32] to [32,64,128,256] the model file size does not increase more then two megabytes. So does it really must improve quality?
Yes, model trainig requires more memory and time. So I confused, trainig slower, but model size still same size (almost). I think it mean that model doesnt increse own possibilities. How model will make more detailed images with same size..
If you know some sources with simple description of this technique let me know please.

@woctezuma
Copy link

woctezuma commented Jan 23, 2021

Implementation of GSA in the code is from:

Based on lucidrains' repository, one could refer to this for prior work:

Efficient attention is an attention mechanism that substantially optimizes the memory and computational efficiency while retaining exactly the same expressive power as the conventional dot-product attention.

Apparently, it is a cheaper way to have attention.
It brings attention mechanism to the model, but does not increase its size a lot because it does not add new features, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants