-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Reformat docstring for get_timestep_embedding
#8811
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
Conversation
The original docstring formatting was off (looks like a bad line-wrap mangling the parameters), but I figured I might as well reformat to match the same docstring style as the rest of the file.
| These may be fractional. | ||
| :param embedding_dim: the dimension of the output. :param max_period: controls the minimum frequency of the | ||
| embeddings. :return: an [N x dim] Tensor of positional embeddings. | ||
| Args |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
can we also add the other 2 arguments that are missing from the doc string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can try -- TBH I haven't examined the function closely to really understand what downscale_freq_shift and scale actually do.
This simplifies the implementation (IMO) by getting rid of the redundant `torch.exp(-math.log(a) * b))` with `torch.pow(a, -b)` and updates the docstring to capture what each argument does.
| assert len(timesteps.shape) == 1, "Timesteps should be a 1d-array" | ||
|
|
||
| half_dim = embedding_dim // 2 | ||
| exponent = -math.log(max_period) * torch.arange( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we not change the implementation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure -- I find the current implementation to be needlessly complex, but hapy to revert.
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
|
thank you for your contribution! |
* Reformat docstring for `get_timestep_embedding` --------- Co-authored-by: YiYi Xu <yixu310@gmail.com>
The original docstring formatting was off (looks like a bad line-wrap mangling the parameters), but I figured I might as well reformat to match the same docstring style as the rest of the file.
What does this PR do?
Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.