Uh oh!
There was an error while loading. Please reload this page.
Reformat docstring for get_timestep_embedding - #8811
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.
thanks!
can we also add the other 2 arguments that are missing from the doc string?
There was a problem hiding this comment.
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.
can we not change the implementation?
There was a problem hiding this comment.
Sure -- I find the current implementation to be needlessly complex, but hapy to revert.
Uh oh!
There was an error while loading. Please reload this page.
HuggingFaceDocBuilderDev
commented
Jul 11, 2024
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. |
yiyixuxu
commented
Jul 11, 2024
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.